Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Word32/Word64: Replace RTS calls with assembly code on X86.

git-svn-id: https://polyml.svn.sourceforge.net/svnroot/polyml/trunk@1610 57040599-48ee-4647-8227-d26cbd406fcb
  • Loading branch information...
commit 0282ccdd929edc0a211f6ae1f7037fdef5328f55 1 parent 044d338
dcjm authored

Showing 2 changed files with 366 additions and 110 deletions. Show diff stats Hide diff stats

  1. +27 64 polyml/libpolyml/x86_dep.cpp
  2. +339 46 polyml/libpolyml/x86asm.asm
91 polyml/libpolyml/x86_dep.cpp
@@ -402,26 +402,6 @@ extern "C" {
402 402 byte *X86AsmCallPOLY_SYS_os_specific(void);
403 403 byte *X86AsmCallPOLY_SYS_signal_handler(void);
404 404 byte *X86AsmCallPOLY_SYS_kill_self(void);
405   - byte *X86AsmCallPOLY_SYS_eq_longword(void);
406   - byte *X86AsmCallPOLY_SYS_neq_longword(void);
407   - byte *X86AsmCallPOLY_SYS_geq_longword(void);
408   - byte *X86AsmCallPOLY_SYS_leq_longword(void);
409   - byte *X86AsmCallPOLY_SYS_gt_longword(void);
410   - byte *X86AsmCallPOLY_SYS_lt_longword(void);
411   - byte *X86AsmCallPOLY_SYS_plus_longword(void);
412   - byte *X86AsmCallPOLY_SYS_minus_longword(void);
413   - byte *X86AsmCallPOLY_SYS_mul_longword(void);
414   - byte *X86AsmCallPOLY_SYS_div_longword(void);
415   - byte *X86AsmCallPOLY_SYS_mod_longword(void);
416   - byte *X86AsmCallPOLY_SYS_andb_longword(void);
417   - byte *X86AsmCallPOLY_SYS_orb_longword(void);
418   - byte *X86AsmCallPOLY_SYS_xorb_longword(void);
419   - byte *X86AsmCallPOLY_SYS_shift_left_longword(void);
420   - byte *X86AsmCallPOLY_SYS_shift_right_longword(void);
421   - byte *X86AsmCallPOLY_SYS_shift_right_arith_longword(void);
422   - byte *X86AsmCallPOLY_SYS_longword_to_tagged(void);
423   - byte *X86AsmCallPOLY_SYS_signed_to_longword(void);
424   - byte *X86AsmCallPOLY_SYS_unsigned_to_longword(void);
425 405
426 406 byte *X86AsmCallExtraRETURN_HEAP_OVERFLOW(void);
427 407 byte *X86AsmCallExtraRETURN_STACK_OVERFLOW(void);
@@ -468,6 +448,12 @@ extern "C" {
468 448 extern int real_add(), real_sub(), real_mul(), real_div(), real_abs(), real_neg();
469 449 extern int real_geq(), real_leq(), real_gtr(), real_lss(), real_eq(), real_neq();
470 450 extern int real_from_int();
  451 + extern int eq_longword(), neq_longword(), geq_longword(), leq_longword();
  452 + extern int gt_longword(), lt_longword();
  453 + extern int longword_to_tagged(), signed_to_longword(), unsigned_to_longword();
  454 + extern int plus_longword(), minus_longword(), mul_longword(), div_longword();
  455 + extern int mod_longword(), andb_longword(), orb_longword(), xorb_longword();
  456 + extern int shift_left_longword(), shift_right_longword(), shift_right_arith_longword();
471 457 };
472 458
473 459 // Run the current ML process. X86AsmSwitchToPoly saves the C state so that
@@ -1922,50 +1908,27 @@ void X86Dependent::InitInterfaceVector(void)
1922 1908 MAKE_IO_CALL_SEQUENCE(POLY_SYS_signal_handler, codeAddr);
1923 1909 add_word_to_io_area(POLY_SYS_signal_handler, PolyWord::FromCodePtr(codeAddr));
1924 1910
1925   - MAKE_IO_CALL_SEQUENCE(POLY_SYS_eq_longword, codeAddr);
1926   - add_word_to_io_area(POLY_SYS_eq_longword, PolyWord::FromCodePtr(codeAddr));
1927   - MAKE_IO_CALL_SEQUENCE(POLY_SYS_neq_longword, codeAddr);
1928   - add_word_to_io_area(POLY_SYS_neq_longword, PolyWord::FromCodePtr(codeAddr));
1929   - MAKE_IO_CALL_SEQUENCE(POLY_SYS_geq_longword, codeAddr);
1930   - add_word_to_io_area(POLY_SYS_geq_longword, PolyWord::FromCodePtr(codeAddr));
1931   - MAKE_IO_CALL_SEQUENCE(POLY_SYS_leq_longword, codeAddr);
1932   - add_word_to_io_area(POLY_SYS_leq_longword, PolyWord::FromCodePtr(codeAddr));
1933   - MAKE_IO_CALL_SEQUENCE(POLY_SYS_gt_longword, codeAddr);
1934   - add_word_to_io_area(POLY_SYS_gt_longword, PolyWord::FromCodePtr(codeAddr));
1935   - MAKE_IO_CALL_SEQUENCE(POLY_SYS_lt_longword, codeAddr);
1936   - add_word_to_io_area(POLY_SYS_lt_longword, PolyWord::FromCodePtr(codeAddr));
1937   -
1938   - MAKE_IO_CALL_SEQUENCE(POLY_SYS_plus_longword, codeAddr);
1939   - add_word_to_io_area(POLY_SYS_plus_longword, PolyWord::FromCodePtr(codeAddr));
1940   - MAKE_IO_CALL_SEQUENCE(POLY_SYS_minus_longword, codeAddr);
1941   - add_word_to_io_area(POLY_SYS_minus_longword, PolyWord::FromCodePtr(codeAddr));
1942   - MAKE_IO_CALL_SEQUENCE(POLY_SYS_mul_longword, codeAddr);
1943   - add_word_to_io_area(POLY_SYS_mul_longword, PolyWord::FromCodePtr(codeAddr));
1944   - MAKE_IO_CALL_SEQUENCE(POLY_SYS_div_longword, codeAddr);
1945   - add_word_to_io_area(POLY_SYS_div_longword, PolyWord::FromCodePtr(codeAddr));
1946   - MAKE_IO_CALL_SEQUENCE(POLY_SYS_mod_longword, codeAddr);
1947   - add_word_to_io_area(POLY_SYS_mod_longword, PolyWord::FromCodePtr(codeAddr));
1948   - MAKE_IO_CALL_SEQUENCE(POLY_SYS_andb_longword, codeAddr);
1949   - add_word_to_io_area(POLY_SYS_andb_longword, PolyWord::FromCodePtr(codeAddr));
1950   - MAKE_IO_CALL_SEQUENCE(POLY_SYS_orb_longword, codeAddr);
1951   - add_word_to_io_area(POLY_SYS_orb_longword, PolyWord::FromCodePtr(codeAddr));
1952   - MAKE_IO_CALL_SEQUENCE(POLY_SYS_xorb_longword, codeAddr);
1953   - add_word_to_io_area(POLY_SYS_xorb_longword, PolyWord::FromCodePtr(codeAddr));
1954   -
1955   - MAKE_IO_CALL_SEQUENCE(POLY_SYS_shift_left_longword, codeAddr);
1956   - add_word_to_io_area(POLY_SYS_shift_left_longword, PolyWord::FromCodePtr(codeAddr));
1957   - MAKE_IO_CALL_SEQUENCE(POLY_SYS_shift_right_longword, codeAddr);
1958   - add_word_to_io_area(POLY_SYS_shift_right_longword, PolyWord::FromCodePtr(codeAddr));
1959   - MAKE_IO_CALL_SEQUENCE(POLY_SYS_shift_right_arith_longword, codeAddr);
1960   - add_word_to_io_area(POLY_SYS_shift_right_arith_longword, PolyWord::FromCodePtr(codeAddr));
1961   -
1962   - MAKE_IO_CALL_SEQUENCE(POLY_SYS_longword_to_tagged, codeAddr);
1963   - add_word_to_io_area(POLY_SYS_longword_to_tagged, PolyWord::FromCodePtr(codeAddr));
1964   - MAKE_IO_CALL_SEQUENCE(POLY_SYS_signed_to_longword, codeAddr);
1965   - add_word_to_io_area(POLY_SYS_signed_to_longword, PolyWord::FromCodePtr(codeAddr));
1966   - MAKE_IO_CALL_SEQUENCE(POLY_SYS_unsigned_to_longword, codeAddr);
1967   - add_word_to_io_area(POLY_SYS_unsigned_to_longword, PolyWord::FromCodePtr(codeAddr));
1968   -
  1911 + add_function_to_io_area(POLY_SYS_eq_longword, &eq_longword);
  1912 + add_function_to_io_area(POLY_SYS_neq_longword, &neq_longword);
  1913 + add_function_to_io_area(POLY_SYS_geq_longword, &geq_longword);
  1914 + add_function_to_io_area(POLY_SYS_leq_longword, &leq_longword);
  1915 + add_function_to_io_area(POLY_SYS_gt_longword, &gt_longword);
  1916 + add_function_to_io_area(POLY_SYS_lt_longword, &lt_longword);
  1917 + add_function_to_io_area(POLY_SYS_plus_longword, &plus_longword);
  1918 + add_function_to_io_area(POLY_SYS_minus_longword, &minus_longword);
  1919 + add_function_to_io_area(POLY_SYS_mul_longword, &mul_longword);
  1920 + add_function_to_io_area(POLY_SYS_div_longword, &div_longword);
  1921 + add_function_to_io_area(POLY_SYS_mod_longword, &mod_longword);
  1922 + add_function_to_io_area(POLY_SYS_andb_longword, &andb_longword);
  1923 + add_function_to_io_area(POLY_SYS_orb_longword, &orb_longword);
  1924 + add_function_to_io_area(POLY_SYS_xorb_longword, &xorb_longword);
  1925 + add_function_to_io_area(POLY_SYS_shift_left_longword, &shift_left_longword);
  1926 + add_function_to_io_area(POLY_SYS_shift_right_longword, &shift_right_longword);
  1927 + add_function_to_io_area(POLY_SYS_shift_right_arith_longword, &shift_right_arith_longword);
  1928 +
  1929 + add_function_to_io_area(POLY_SYS_longword_to_tagged, &longword_to_tagged);
  1930 + add_function_to_io_area(POLY_SYS_signed_to_longword, &signed_to_longword);
  1931 + add_function_to_io_area(POLY_SYS_unsigned_to_longword, &unsigned_to_longword);
1969 1932
1970 1933 // Entries for special cases. These are generally, but not always, called from
1971 1934 // compiled code.
385 polyml/libpolyml/x86asm.asm
@@ -251,6 +251,7 @@ IFDEF HOSTARCHITECTURE_X86_64
251 251 #define TESTL testq
252 252 #define IMULL imulq
253 253 #define MULL mulq
  254 +#define DIVL divl
254 255 #define NEGL negq
255 256 #define PUSHL pushq
256 257 #define POPL popq
@@ -277,6 +278,7 @@ ELSE
277 278 #define TESTL testl
278 279 #define IMULL imull
279 280 #define MULL mull
  281 +#define DIVL divl
280 282 #define NEGL negl
281 283 #define PUSHL pushl
282 284 #define POPL popl
@@ -2227,10 +2229,37 @@ CALLMACRO RegMask thread_self,(M_Reax)
2227 2229
2228 2230
2229 2231
  2232 +;# Memory for LargeWord.word values. This is the same as mem_for_real on
  2233 +;# 64-bits but only a single word on 32-bits.
  2234 +mem_for_largeword:
  2235 +IFNDEF HOSTARCHITECTURE_X86_64
  2236 + MOVL LocalMpointer[Rebp],Recx
  2237 + SUBL CONST 8,Recx ;# Length word (4 bytes) + 4 bytes
  2238 +IFDEF TEST_ALLOC
  2239 +;# Test case - this will always force a call into RTS.
  2240 + CMPL LocalMpointer[Rebp],Recx
  2241 +ELSE
  2242 + CMPL LocalMbottom[Rebp],Recx
  2243 +ENDIF
  2244 + jb mem_for_real1
  2245 + MOVL Recx,LocalMpointer[Rebp] ;# Updated allocation pointer
  2246 +IFDEF WINDOWS
  2247 + mov FULLWORD ptr (-4)[Recx],01000001h ;# Length word:
  2248 +ELSE
  2249 + MOVL CONST 0x01000001,(-4)[Recx] ;# Length word
  2250 +ENDIF
  2251 + ret
  2252 +ENDIF
  2253 +;# Else if it is 64-bits just drop through
  2254 +
2230 2255 ;# FLOATING POINT
2231 2256 ;# If we have insufficient space for the result we call in to
2232   -;# main RTS to do the work.
2233   -
  2257 +;# main RTS to do the work. The reason for this is that it is
  2258 +;# not safe to make a call into memory allocator and then
  2259 +;# continue with the rest of the floating point operation
  2260 +;# because that would produce a return address pointing into the
  2261 +;# assembly code itself. It's possible that this is no longer
  2262 +;# a problem.
2234 2263
2235 2264 mem_for_real:
2236 2265 ;# Allocate memory for the result.
@@ -2633,6 +2662,294 @@ ENDIF
2633 2662 SUBL CONST 2,Reax
2634 2663 ret
2635 2664
  2665 +;# LargeWord.word operations. These are 32 or 64-bit values in a single-word byte
  2666 +;# memory cell.
  2667 +CALLMACRO INLINE_ROUTINE eq_longword
  2668 + MOVL [Reax],Reax
  2669 + CMPL [Rebx],Reax
  2670 + jz RetTrue ;# True if they are equal.
  2671 + jmp RetFalse
  2672 +CALLMACRO RegMask eq_longword,(M_Reax)
  2673 +
  2674 +CALLMACRO INLINE_ROUTINE neq_longword
  2675 + MOVL [Reax],Reax
  2676 + CMPL [Rebx],Reax
  2677 + jz RetFalse
  2678 + jmp RetTrue
  2679 +CALLMACRO RegMask neq_longword,(M_Reax)
  2680 +
  2681 +CALLMACRO INLINE_ROUTINE geq_longword
  2682 + MOVL [Reax],Reax
  2683 + CMPL [Rebx],Reax
  2684 + jnb RetTrue
  2685 + jmp RetFalse
  2686 +CALLMACRO RegMask geq_longword,(M_Reax)
  2687 +
  2688 +CALLMACRO INLINE_ROUTINE leq_longword
  2689 + MOVL [Reax],Reax
  2690 + CMPL [Rebx],Reax
  2691 + jna RetTrue
  2692 + jmp RetFalse
  2693 +CALLMACRO RegMask leq_longword,(M_Reax)
  2694 +
  2695 +CALLMACRO INLINE_ROUTINE gt_longword
  2696 + MOVL [Reax],Reax
  2697 + CMPL [Rebx],Reax
  2698 + ja RetTrue
  2699 + jmp RetFalse
  2700 +CALLMACRO RegMask gt_longword,(M_Reax)
  2701 +
  2702 +CALLMACRO INLINE_ROUTINE lt_longword
  2703 + MOVL [Reax],Reax
  2704 + CMPL [Rebx],Reax
  2705 + jb RetTrue
  2706 + jmp RetFalse
  2707 +CALLMACRO RegMask lt_longword,(M_Reax)
  2708 +
  2709 +CALLMACRO INLINE_ROUTINE longword_to_tagged
  2710 +;# Load the value and tag it, discarding the top bit
  2711 + MOVL [Reax],Reax
  2712 + CALLMACRO MAKETAGGED Reax,Reax
  2713 + ret
  2714 +CALLMACRO RegMask longword_to_tagged,(M_Reax)
  2715 +
  2716 +CALLMACRO INLINE_ROUTINE signed_to_longword
  2717 +;# Shift the value to remove the tag and store it.
  2718 + call mem_for_largeword
  2719 + jb signed_to_longword1
  2720 + SARL CONST TAGSHIFT,Reax ;# Arithmetic shift, preserve sign
  2721 + MOVL Reax,[Recx]
  2722 + MOVL Recx,Reax
  2723 + ret
  2724 +signed_to_longword1:
  2725 + CALLMACRO CALL_IO POLY_SYS_signed_to_longword
  2726 +CALLMACRO RegMask signed_to_longword,(M_Reax OR M_Recx OR Mask_all)
  2727 +
  2728 +CALLMACRO INLINE_ROUTINE unsigned_to_longword
  2729 +;# Shift the value to remove the tag and store it.
  2730 + call mem_for_largeword
  2731 + jb unsigned_to_longword1
  2732 + SHRL CONST TAGSHIFT,Reax ;# Logical shift, zero top bit
  2733 + MOVL Reax,[Recx]
  2734 + MOVL Recx,Reax
  2735 + ret
  2736 +unsigned_to_longword1:
  2737 + CALLMACRO CALL_IO POLY_SYS_unsigned_to_longword
  2738 +CALLMACRO RegMask unsigned_to_longword,(M_Reax OR M_Recx OR Mask_all)
  2739 +
  2740 +CALLMACRO INLINE_ROUTINE plus_longword
  2741 + call mem_for_largeword
  2742 + jb plus_longword1
  2743 + MOVL [Reax],Reax
  2744 + ADDL [Rebx],Reax
  2745 + MOVL Reax,[Recx]
  2746 + MOVL Recx,Reax
  2747 + ret
  2748 +plus_longword1:
  2749 + CALLMACRO CALL_IO POLY_SYS_plus_longword
  2750 +CALLMACRO RegMask plus_longword,(M_Reax OR M_Recx OR Mask_all)
  2751 +
  2752 +CALLMACRO INLINE_ROUTINE minus_longword
  2753 + call mem_for_largeword
  2754 + jb minus_longword1
  2755 + MOVL [Reax],Reax
  2756 + SUBL [Rebx],Reax
  2757 + MOVL Reax,[Recx]
  2758 + MOVL Recx,Reax
  2759 + ret
  2760 +minus_longword1:
  2761 + CALLMACRO CALL_IO POLY_SYS_minus_longword
  2762 +CALLMACRO RegMask minus_longword,(M_Reax OR M_Recx OR Mask_all)
  2763 +
  2764 +CALLMACRO INLINE_ROUTINE mul_longword
  2765 + call mem_for_largeword
  2766 + jb mul_longword1
  2767 + MOVL [Reax],Reax
  2768 +IFDEF WINDOWS
  2769 + mul FULLWORD ptr [Rebx]
  2770 +ELSE
  2771 + MULL [Rebx]
  2772 +ENDIF
  2773 + MOVL Reax,[Recx]
  2774 + MOVL Recx,Reax
  2775 + MOVL Reax,Redx ;# clobber this which has the high-end result
  2776 + ret
  2777 +mul_longword1:
  2778 + CALLMACRO CALL_IO POLY_SYS_mul_longword
  2779 +CALLMACRO RegMask mul_longword,(M_Reax OR M_Recx OR M_Redx OR Mask_all)
  2780 +
  2781 +CALLMACRO INLINE_ROUTINE div_longword
  2782 +IFDEF WINDOWS
  2783 + cmp FULLWORD ptr [Rebx],0
  2784 +ELSE
  2785 + CMPL CONST 0,[Rebx]
  2786 +ENDIF
  2787 + jz raise_div_ex
  2788 + call mem_for_largeword
  2789 + jb div_longword1
  2790 + MOVL [Reax],Reax
  2791 + MOVL CONST 0,Redx
  2792 +IFDEF WINDOWS
  2793 + div FULLWORD ptr [Rebx]
  2794 +ELSE
  2795 + DIVL [Rebx]
  2796 +ENDIF
  2797 + MOVL Reax,[Recx] ;# Store the quotient
  2798 + MOVL Recx,Reax
  2799 + MOVL Reax,Redx ;# clobber this which has the remainder
  2800 + ret
  2801 +div_longword1:
  2802 + CALLMACRO CALL_IO POLY_SYS_div_longword
  2803 +CALLMACRO RegMask div_longword,(M_Reax OR M_Recx OR M_Redx OR Mask_all)
  2804 +
  2805 +CALLMACRO INLINE_ROUTINE mod_longword
  2806 +IFDEF WINDOWS
  2807 + cmp FULLWORD ptr [Rebx],0
  2808 +ELSE
  2809 + CMPL CONST 0,[Rebx]
  2810 +ENDIF
  2811 + jz raise_div_ex
  2812 + call mem_for_largeword
  2813 + jb mod_longword1
  2814 + MOVL [Reax],Reax
  2815 + MOVL CONST 0,Redx
  2816 +IFDEF WINDOWS
  2817 + div FULLWORD ptr [Rebx]
  2818 +ELSE
  2819 + DIVL [Rebx]
  2820 +ENDIF
  2821 + MOVL Redx,[Recx] ;# Store the remainder
  2822 + MOVL Recx,Reax
  2823 + MOVL Reax,Redx ;# clobber this which has the remainder
  2824 + ret
  2825 +mod_longword1:
  2826 + CALLMACRO CALL_IO POLY_SYS_mod_longword
  2827 +CALLMACRO RegMask mod_longword,(M_Reax OR M_Recx OR M_Redx OR Mask_all)
  2828 +
  2829 +CALLMACRO INLINE_ROUTINE andb_longword
  2830 + call mem_for_largeword
  2831 + jb andb_longword1
  2832 + MOVL [Reax],Reax
  2833 + ANDL [Rebx],Reax
  2834 + MOVL Reax,[Recx]
  2835 + MOVL Recx,Reax
  2836 + ret
  2837 +andb_longword1:
  2838 + CALLMACRO CALL_IO POLY_SYS_andb_longword
  2839 +CALLMACRO RegMask andb_longword,(M_Reax OR M_Recx OR Mask_all)
  2840 +
  2841 +CALLMACRO INLINE_ROUTINE orb_longword
  2842 + call mem_for_largeword
  2843 + jb orb_longword1
  2844 + MOVL [Reax],Reax
  2845 + ORL [Rebx],Reax
  2846 + MOVL Reax,[Recx]
  2847 + MOVL Recx,Reax
  2848 + ret
  2849 +orb_longword1:
  2850 + CALLMACRO CALL_IO POLY_SYS_orb_longword
  2851 +CALLMACRO RegMask orb_longword,(M_Reax OR M_Recx OR Mask_all)
  2852 +
  2853 +CALLMACRO INLINE_ROUTINE xorb_longword
  2854 + call mem_for_largeword
  2855 + jb xorb_longword1
  2856 + MOVL [Reax],Reax
  2857 + XORL [Rebx],Reax
  2858 + MOVL Reax,[Recx]
  2859 + MOVL Recx,Reax
  2860 + ret
  2861 +xorb_longword1:
  2862 + CALLMACRO CALL_IO POLY_SYS_xorb_longword
  2863 +CALLMACRO RegMask xorb_longword,(M_Reax OR M_Recx OR Mask_all)
  2864 +
  2865 +CALLMACRO INLINE_ROUTINE shift_left_longword
  2866 + call mem_for_largeword
  2867 + jb shift_left_longword1
  2868 + MOVL Recx,Redx ;# We need Recx for the shift
  2869 + ;# The shift value is always a Word.word value i.e. tagged
  2870 + ;# LargeWord.<<(a,b) is defined to return 0 if b > LargeWord.wordSize
  2871 +IFNDEF HOSTARCHITECTURE_X86_64
  2872 + CMPL CONST TAGGED(32),Rebx
  2873 +ELSE
  2874 + CMPL CONST TAGGED(64),Rebx
  2875 +ENDIF
  2876 + jb sllw1
  2877 + MOVL CONST 0,Reax
  2878 + jmp sllw2
  2879 +sllw1:
  2880 + MOVL Rebx,Recx
  2881 + SHRL CONST TAGSHIFT,Recx ;# remove tag
  2882 + MOVL [Reax],Reax
  2883 + SHLL R_cl,Reax
  2884 +sllw2:
  2885 + MOVL Reax,[Redx]
  2886 + MOVL Redx,Reax
  2887 + MOVL Reax,Recx ;# Clobber Recx
  2888 + ret
  2889 +shift_left_longword1:
  2890 + CALLMACRO CALL_IO POLY_SYS_shift_left_longword
  2891 +CALLMACRO RegMask shift_left_longword,(M_Reax OR M_Recx OR M_Redx OR Mask_all)
  2892 +
  2893 +CALLMACRO INLINE_ROUTINE shift_right_longword
  2894 + call mem_for_largeword
  2895 + jb shift_right_longword1
  2896 + MOVL Recx,Redx ;# We need Recx for the shift
  2897 + ;# The shift value is always a Word.word value i.e. tagged
  2898 + ;# LargeWord.>>(a,b) is defined to return 0 if b > LargeWord.wordSize
  2899 +IFNDEF HOSTARCHITECTURE_X86_64
  2900 + CMPL CONST TAGGED(32),Rebx
  2901 +ELSE
  2902 + CMPL CONST TAGGED(64),Rebx
  2903 +ENDIF
  2904 + jb srlw1
  2905 + MOVL CONST 0,Reax
  2906 + jmp srlw2
  2907 +srlw1:
  2908 + MOVL Rebx,Recx
  2909 + SHRL CONST TAGSHIFT,Recx ;# remove tag
  2910 + MOVL [Reax],Reax
  2911 + SHRL R_cl,Reax
  2912 +srlw2:
  2913 + MOVL Reax,[Redx]
  2914 + MOVL Redx,Reax
  2915 + MOVL Reax,Recx ;# Clobber Recx
  2916 + ret
  2917 +shift_right_longword1:
  2918 + CALLMACRO CALL_IO POLY_SYS_shift_right_longword
  2919 +CALLMACRO RegMask shift_right_longword,(M_Reax OR M_Recx OR M_Redx OR Mask_all)
  2920 +
  2921 +CALLMACRO INLINE_ROUTINE shift_right_arith_longword
  2922 + call mem_for_largeword
  2923 + jb shift_right_arith_longword1
  2924 + MOVL Recx,Redx ;# We need Recx for the shift
  2925 + ;# The shift value is always a Word.word value i.e. tagged
  2926 + ;# LargeWord.~>>(a,b) is defined to return 0 or ~1 if b > LargeWord.wordSize
  2927 +IFNDEF HOSTARCHITECTURE_X86_64
  2928 + CMPL CONST TAGGED(32),Rebx
  2929 +ELSE
  2930 + CMPL CONST TAGGED(64),Rebx
  2931 +ENDIF
  2932 + jb sralw1
  2933 + ;# Setting the shift to 31/63 propagates the sign bit
  2934 +IFNDEF HOSTARCHITECTURE_X86_64
  2935 + MOVL CONST TAGGED(31),Rebx
  2936 +ELSE
  2937 + MOVL CONST TAGGED(63),Rebx
  2938 +ENDIF
  2939 +sralw1:
  2940 + MOVL Rebx,Recx
  2941 + SHRL CONST TAGSHIFT,Recx ;# remove tag
  2942 + MOVL [Reax],Reax
  2943 + SARL R_cl,Reax
  2944 + MOVL Reax,[Redx]
  2945 + MOVL Redx,Reax
  2946 + MOVL Reax,Recx ;# Clobber Recx
  2947 + ret
  2948 +shift_right_arith_longword1:
  2949 + CALLMACRO CALL_IO POLY_SYS_shift_right_arith_longword
  2950 +CALLMACRO RegMask shift_right_arith_longword,(M_Reax OR M_Rebx OR M_Recx OR M_Redx OR Mask_all)
  2951 +
  2952 +
2636 2953 IFDEF WINDOWS
2637 2954 ;# Visual C does not support assembly code on X86-64 so we use this for X86-32 as well.
2638 2955 CREATE_IO_CALL MACRO index
@@ -2685,30 +3002,6 @@ CREATE_EXTRA_CALL MACRO index
2685 3002 CREATE_IO_CALL POLY_SYS_arctan_real
2686 3003 CREATE_IO_CALL POLY_SYS_cos_real
2687 3004
2688   -;# For the moment these all call into C++. They will be replaced by
2689   -;# assembly code in due course.
2690   - CREATE_IO_CALL POLY_SYS_eq_longword
2691   - CREATE_IO_CALL POLY_SYS_neq_longword
2692   - CREATE_IO_CALL POLY_SYS_geq_longword
2693   - CREATE_IO_CALL POLY_SYS_leq_longword
2694   - CREATE_IO_CALL POLY_SYS_gt_longword
2695   - CREATE_IO_CALL POLY_SYS_lt_longword
2696   - CREATE_IO_CALL POLY_SYS_plus_longword
2697   - CREATE_IO_CALL POLY_SYS_minus_longword
2698   - CREATE_IO_CALL POLY_SYS_mul_longword
2699   - CREATE_IO_CALL POLY_SYS_div_longword
2700   - CREATE_IO_CALL POLY_SYS_mod_longword
2701   - CREATE_IO_CALL POLY_SYS_andb_longword
2702   - CREATE_IO_CALL POLY_SYS_orb_longword
2703   - CREATE_IO_CALL POLY_SYS_xorb_longword
2704   - CREATE_IO_CALL POLY_SYS_shift_left_longword
2705   - CREATE_IO_CALL POLY_SYS_shift_right_longword
2706   - CREATE_IO_CALL POLY_SYS_shift_right_arith_longword
2707   - CREATE_IO_CALL POLY_SYS_longword_to_tagged
2708   - CREATE_IO_CALL POLY_SYS_signed_to_longword
2709   - CREATE_IO_CALL POLY_SYS_unsigned_to_longword
2710   -
2711   -
2712 3005 RETURN_HEAP_OVERFLOW EQU 1
2713 3006 RETURN_STACK_OVERFLOW EQU 2
2714 3007 RETURN_STACK_OVERFLOWEX EQU 3
@@ -2793,12 +3086,12 @@ ENDIF
2793 3086 dd Mask_all ;# 50 is no longer used
2794 3087 dd Mask_all ;# 51
2795 3088 dd Mask_all ;# 52
2796   - dd Mask_all ;# 53
2797   - dd Mask_all ;# 54
2798   - dd Mask_all ;# 55
2799   - dd Mask_all ;# 56
2800   - dd Mask_all ;# 57
2801   - dd Mask_all ;# 58
  3089 + dd Mask_eq_longword ;# 53
  3090 + dd Mask_neq_longword ;# 54
  3091 + dd Mask_geq_longword ;# 55
  3092 + dd Mask_leq_longword ;# 56
  3093 + dd Mask_gt_longword ;# 57
  3094 + dd Mask_lt_longword ;# 58
2802 3095 dd Mask_all ;# 59 is unused
2803 3096 dd Mask_all ;# 60 is unused
2804 3097 dd Mask_all ;# 61
@@ -2814,24 +3107,24 @@ ENDIF
2814 3107 dd Mask_atomic_decr ;# 71
2815 3108 dd Mask_thread_self ;# 72
2816 3109 dd Mask_all ;# 73
2817   - dd Mask_all ;# 74
2818   - dd Mask_all ;# 75
2819   - dd Mask_all ;# 76
2820   - dd Mask_all ;# 77
2821   - dd Mask_all ;# 78
2822   - dd Mask_all ;# 79
2823   - dd Mask_all ;# 80
2824   - dd Mask_all ;# 81
  3110 + dd Mask_plus_longword ;# 74
  3111 + dd Mask_minus_longword ;# 75
  3112 + dd Mask_mul_longword ;# 76
  3113 + dd Mask_div_longword ;# 77
  3114 + dd Mask_mod_longword ;# 78
  3115 + dd Mask_andb_longword ;# 79
  3116 + dd Mask_orb_longword ;# 80
  3117 + dd Mask_xorb_longword ;# 81
2825 3118 dd Mask_all ;# 82 is unused
2826 3119 dd Mask_all ;# 83 is now unused
2827 3120 dd Mask_all ;# 84
2828   - dd Mask_all ;# 85
2829   - dd Mask_all ;# 86
2830   - dd Mask_all ;# 87
  3121 + dd Mask_shift_left_longword ;# 85
  3122 + dd Mask_shift_right_longword ;# 86
  3123 + dd Mask_shift_right_arith_longword ;# 87
2831 3124 dd Mask_all ;# 88
2832   - dd Mask_all ;# 89
2833   - dd Mask_all ;# 90
2834   - dd Mask_all ;# 91
  3125 + dd Mask_longword_to_tagged ;# 89
  3126 + dd Mask_signed_to_longword ;# 90
  3127 + dd Mask_unsigned_to_longword ;# 91
2835 3128 dd Mask_all ;# 92
2836 3129 dd Mask_all ;# 93
2837 3130 dd Mask_all ;# 94

0 comments on commit 0282ccd

Please sign in to comment.
Something went wrong with that request. Please try again.