Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Side by Side Diff: src/ia32/code-stubs-ia32.cc

Issue 8821019: Porting Math.pow changes to x64. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: . Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/ia32/lithium-codegen-ia32.cc » ('j') | src/ia32/lithium-codegen-ia32.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2922 matching lines...) Expand 10 before | Expand all | Expand 10 after
2933 2933
2934 void FloatingPointHelper::CheckFloatOperandsAreInt32(MacroAssembler* masm, 2934 void FloatingPointHelper::CheckFloatOperandsAreInt32(MacroAssembler* masm,
2935 Label* non_int32) { 2935 Label* non_int32) {
2936 return; 2936 return;
2937 } 2937 }
2938 2938
2939 2939
2940 void MathPowStub::Generate(MacroAssembler* masm) { 2940 void MathPowStub::Generate(MacroAssembler* masm) {
2941 CpuFeatures::Scope use_sse2(SSE2); 2941 CpuFeatures::Scope use_sse2(SSE2);
2942 Factory* factory = masm->isolate()->factory(); 2942 Factory* factory = masm->isolate()->factory();
2943 const Register exponent = eax;
2944 const Register base = edx;
2945 const Register scratch = ecx;
2946 const XMMRegister double_result = xmm3;
2947 const XMMRegister double_base = xmm2;
2948 const XMMRegister double_exponent = xmm1;
2949 const XMMRegister double_scratch = xmm4;
2950
2943 Label double_int_runtime, generic_runtime, done; 2951 Label double_int_runtime, generic_runtime, done;
2944 Label base_is_smi, unpack_exponent, exponent_not_smi, int_exponent; 2952 Label exponent_not_smi, int_exponent;
2945 // Save 1 in xmm3 - we need this several times later on. 2953
2946 __ mov(ecx, Immediate(1)); 2954 // Save 1 in double_result - we need this several times later on.
2947 __ cvtsi2sd(xmm3, ecx); 2955 __ mov(scratch, Immediate(1));
2956 __ cvtsi2sd(double_result, scratch);
2948 2957
2949 if (exponent_type_ == ON_STACK) { 2958 if (exponent_type_ == ON_STACK) {
2950 // The exponent (and base) are supplied as arguments on the stack. 2959 Label base_is_smi, unpack_exponent;
2960 // The exponent and base are supplied as arguments on the stack.
2951 // This can only happen if the stub is called from non-optimized code. 2961 // This can only happen if the stub is called from non-optimized code.
2952 // Load input parameters from stack 2962 // Load input parameters from stack.
2953 __ mov(edx, Operand(esp, 2 * kPointerSize)); 2963 __ mov(base, Operand(esp, 2 * kPointerSize));
2954 __ mov(eax, Operand(esp, 1 * kPointerSize)); 2964 __ mov(exponent, Operand(esp, 1 * kPointerSize));
2955 // edx: base (smi or heap number) 2965
2956 // eax: exponent (smi or heap number) 2966 __ JumpIfSmi(base, &base_is_smi, Label::kNear);
2957 __ JumpIfSmi(edx, &base_is_smi, Label::kNear); 2967 __ cmp(FieldOperand(base, HeapObject::kMapOffset),
2958 __ cmp(FieldOperand(edx, HeapObject::kMapOffset),
2959 factory->heap_number_map()); 2968 factory->heap_number_map());
2960 __ j(not_equal, &generic_runtime); 2969 __ j(not_equal, &generic_runtime);
2961 2970
2962 __ movdbl(xmm1, FieldOperand(edx, HeapNumber::kValueOffset)); 2971 __ movdbl(double_base, FieldOperand(base, HeapNumber::kValueOffset));
2963 __ jmp(&unpack_exponent, Label::kNear); 2972 __ jmp(&unpack_exponent, Label::kNear);
2964 2973
2965 __ bind(&base_is_smi); 2974 __ bind(&base_is_smi);
2966 __ SmiUntag(edx); 2975 __ SmiUntag(base);
2967 __ cvtsi2sd(xmm1, edx); 2976 __ cvtsi2sd(double_base, base);
2968 __ bind(&unpack_exponent); 2977 __ bind(&unpack_exponent);
2969 2978
2970 __ JumpIfNotSmi(eax, &exponent_not_smi, Label::kNear); 2979 __ JumpIfNotSmi(exponent, &exponent_not_smi, Label::kNear);
2971 __ SmiUntag(eax); 2980 __ SmiUntag(exponent);
2972 __ jmp(&int_exponent); 2981 __ jmp(&int_exponent);
2973 2982
2974 __ bind(&exponent_not_smi); 2983 __ bind(&exponent_not_smi);
2975 __ cmp(FieldOperand(eax, HeapObject::kMapOffset), 2984 __ cmp(FieldOperand(exponent, HeapObject::kMapOffset),
2976 factory->heap_number_map()); 2985 factory->heap_number_map());
2977 __ j(not_equal, &generic_runtime); 2986 __ j(not_equal, &generic_runtime);
2978 __ movdbl(xmm2, FieldOperand(eax, HeapNumber::kValueOffset)); 2987 __ movdbl(double_exponent,
2988 FieldOperand(exponent, HeapNumber::kValueOffset));
2979 } else if (exponent_type_ == TAGGED) { 2989 } else if (exponent_type_ == TAGGED) {
2980 // xmm1: base as double 2990 __ JumpIfNotSmi(exponent, &exponent_not_smi, Label::kNear);
2981 // eax: exponent (smi or heap number) 2991 __ SmiUntag(exponent);
2982 __ JumpIfNotSmi(eax, &exponent_not_smi, Label::kNear);
2983 __ SmiUntag(eax);
2984 __ jmp(&int_exponent); 2992 __ jmp(&int_exponent);
2985 2993
2986 __ bind(&exponent_not_smi); 2994 __ bind(&exponent_not_smi);
2987 __ movdbl(xmm2, FieldOperand(eax, HeapNumber::kValueOffset)); 2995 __ movdbl(double_exponent,
2996 FieldOperand(exponent, HeapNumber::kValueOffset));
2988 } 2997 }
2989 2998
2990 if (exponent_type_ != INTEGER) { 2999 if (exponent_type_ != INTEGER) {
2991 Label fast_power; 3000 Label fast_power;
2992 // xmm1: base as double that is not +/- Infinity or NaN
2993 // xmm2: exponent as double
2994 // Detect integer exponents stored as double. 3001 // Detect integer exponents stored as double.
2995 __ cvttsd2si(eax, Operand(xmm2)); 3002 __ cvttsd2si(exponent, Operand(double_exponent));
2996 // Skip to runtime if possibly NaN (indicated by the indefinite integer). 3003 // Skip to runtime if possibly NaN (indicated by the indefinite integer).
2997 __ cmp(eax, Immediate(0x80000000u)); 3004 __ cmp(exponent, Immediate(0x80000000u));
2998 __ j(equal, &generic_runtime); 3005 __ j(equal, &generic_runtime);
2999 __ cvtsi2sd(xmm4, eax); 3006 __ cvtsi2sd(double_scratch, exponent);
3000 __ ucomisd(xmm2, xmm4); // Already ruled out NaNs for exponent. 3007 // Already ruled out NaNs for exponent.
3008 __ ucomisd(double_exponent, double_scratch);
3001 __ j(equal, &int_exponent); 3009 __ j(equal, &int_exponent);
3002 3010
3003 if (exponent_type_ == ON_STACK) { 3011 if (exponent_type_ == ON_STACK) {
3004 // Detect square root case. Crankshaft detects constant +/-0.5 at 3012 // Detect square root case. Crankshaft detects constant +/-0.5 at
3005 // compile time and uses DoMathPowHalf instead. We then skip this check 3013 // compile time and uses DoMathPowHalf instead. We then skip this check
3006 // for non-constant cases of +/-0.5 as these hardly occur. 3014 // for non-constant cases of +/-0.5 as these hardly occur.
3007 Label continue_sqrt, continue_rsqrt, not_plus_half; 3015 Label continue_sqrt, continue_rsqrt, not_plus_half;
3008 // Test for 0.5. 3016 // Test for 0.5.
3009 // Load xmm4 with 0.5. 3017 // Load double_scratch with 0.5.
3010 __ mov(ecx, Immediate(0x3F000000u)); 3018 __ mov(scratch, Immediate(0x3F000000u));
3011 __ movd(xmm4, ecx); 3019 __ movd(double_scratch, scratch);
3012 __ cvtss2sd(xmm4, xmm4); 3020 __ cvtss2sd(double_scratch, double_scratch);
3013 // xmm4 now has 0.5. 3021 // Already ruled out NaNs for exponent.
3014 __ ucomisd(xmm4, xmm2); // Already ruled out NaNs for exponent. 3022 __ ucomisd(double_scratch, double_exponent);
3015 __ j(not_equal, &not_plus_half, Label::kNear); 3023 __ j(not_equal, &not_plus_half, Label::kNear);
3016 3024
3017 // Calculates square root of base. Check for the special case of 3025 // Calculates square root of base. Check for the special case of
3018 // Math.pow(-Infinity, 0.5) == Infinity (ECMA spec, 15.8.2.13). 3026 // Math.pow(-Infinity, 0.5) == Infinity (ECMA spec, 15.8.2.13).
3019 // According to IEEE-754, single-precision -Infinity has the highest 3027 // According to IEEE-754, single-precision -Infinity has the highest
3020 // 9 bits set and the lowest 23 bits cleared. 3028 // 9 bits set and the lowest 23 bits cleared.
3021 __ mov(ecx, 0xFF800000u); 3029 __ mov(scratch, 0xFF800000u);
3022 __ movd(xmm4, ecx); 3030 __ movd(double_scratch, scratch);
3023 __ cvtss2sd(xmm4, xmm4); 3031 __ cvtss2sd(double_scratch, double_scratch);
3024 __ ucomisd(xmm1, xmm4); 3032 __ ucomisd(double_base, double_scratch);
3025 // Comparing -Infinity with NaN results in "unordered", which sets the 3033 // Comparing -Infinity with NaN results in "unordered", which sets the
3026 // zero flag as if both were equal. However, it also sets the carry flag. 3034 // zero flag as if both were equal. However, it also sets the carry flag.
3027 __ j(not_equal, &continue_sqrt, Label::kNear); 3035 __ j(not_equal, &continue_sqrt, Label::kNear);
3028 __ j(carry, &continue_sqrt, Label::kNear); 3036 __ j(carry, &continue_sqrt, Label::kNear);
3029 3037
3030 // Set result to Infinity in the special case. 3038 // Set result to Infinity in the special case.
3031 __ xorps(xmm3, xmm3); 3039 __ xorps(double_result, double_result);
3032 __ subsd(xmm3, xmm4); 3040 __ subsd(double_result, double_scratch);
3033 __ jmp(&done); 3041 __ jmp(&done);
3034 3042
3035 __ bind(&continue_sqrt); 3043 __ bind(&continue_sqrt);
3036 // sqrtsd returns -0 when input is -0. ECMA spec requires +0. 3044 // sqrtsd returns -0 when input is -0. ECMA spec requires +0.
3037 __ xorps(xmm4, xmm4); 3045 __ xorps(double_scratch, double_scratch);
3038 __ addsd(xmm4, xmm1); // Convert -0 to +0. 3046 __ addsd(double_scratch, double_base); // Convert -0 to +0.
3039 __ sqrtsd(xmm3, xmm4); 3047 __ sqrtsd(double_result, double_scratch);
3040 __ jmp(&done); 3048 __ jmp(&done);
3041 3049
3042 // Test for -0.5. 3050 // Test for -0.5.
3043 __ bind(&not_plus_half); 3051 __ bind(&not_plus_half);
3044 // Load xmm2 with -0.5. 3052 // Load double_exponent with -0.5 by substracting 1.
3045 // Since xmm3 is 1 and xmm4 is 0.5 this is simply xmm4 - xmm3. 3053 __ subsd(double_scratch, double_result);
3046 __ subsd(xmm4, xmm3); 3054 // Already ruled out NaNs for exponent.
3047 // xmm4 now has -0.5. 3055 __ ucomisd(double_scratch, double_exponent);
3048 __ ucomisd(xmm4, xmm2); // Already ruled out NaNs for exponent.
3049 __ j(not_equal, &fast_power, Label::kNear); 3056 __ j(not_equal, &fast_power, Label::kNear);
3050 3057
3051 // Calculates reciprocal of square root of base. Check for the special 3058 // Calculates reciprocal of square root of base. Check for the special
3052 // case of Math.pow(-Infinity, -0.5) == 0 (ECMA spec, 15.8.2.13). 3059 // case of Math.pow(-Infinity, -0.5) == 0 (ECMA spec, 15.8.2.13).
3053 // According to IEEE-754, single-precision -Infinity has the highest 3060 // According to IEEE-754, single-precision -Infinity has the highest
3054 // 9 bits set and the lowest 23 bits cleared. 3061 // 9 bits set and the lowest 23 bits cleared.
3055 __ mov(ecx, 0xFF800000u); 3062 __ mov(scratch, 0xFF800000u);
3056 __ movd(xmm4, ecx); 3063 __ movd(double_scratch, scratch);
3057 __ cvtss2sd(xmm4, xmm4); 3064 __ cvtss2sd(double_scratch, double_scratch);
3058 __ ucomisd(xmm1, xmm4); 3065 __ ucomisd(double_base, double_scratch);
3059 // Comparing -Infinity with NaN results in "unordered", which sets the 3066 // Comparing -Infinity with NaN results in "unordered", which sets the
3060 // zero flag as if both were equal. However, it also sets the carry flag. 3067 // zero flag as if both were equal. However, it also sets the carry flag.
3061 __ j(not_equal, &continue_rsqrt, Label::kNear); 3068 __ j(not_equal, &continue_rsqrt, Label::kNear);
3062 __ j(carry, &continue_rsqrt, Label::kNear); 3069 __ j(carry, &continue_rsqrt, Label::kNear);
3063 3070
3064 // Set result to 0 in the special case. 3071 // Set result to 0 in the special case.
3065 __ xorps(xmm3, xmm3); 3072 __ xorps(double_result, double_result);
3066 __ jmp(&done); 3073 __ jmp(&done);
3067 3074
3068 __ bind(&continue_rsqrt); 3075 __ bind(&continue_rsqrt);
3069 // sqrtsd returns -0 when input is -0. ECMA spec requires +0. 3076 // sqrtsd returns -0 when input is -0. ECMA spec requires +0.
3070 __ xorps(xmm2, xmm2); 3077 __ xorps(double_exponent, double_exponent);
3071 __ addsd(xmm2, xmm1); // Convert -0 to +0. 3078 __ addsd(double_exponent, double_base); // Convert -0 to +0.
3072 __ sqrtsd(xmm2, xmm2); 3079 __ sqrtsd(double_exponent, double_exponent);
3073 __ divsd(xmm3, xmm2); 3080 __ divsd(double_result, double_exponent);
3074 __ jmp(&done); 3081 __ jmp(&done);
3075 } 3082 }
3076 3083
3077 // Using FPU instructions to calculate power. 3084 // Using FPU instructions to calculate power.
3078 Label fast_power_failed; 3085 Label fast_power_failed;
3079 __ bind(&fast_power); 3086 __ bind(&fast_power);
3080 __ fnclex(); // Clear flags to catch exceptions later. 3087 __ fnclex(); // Clear flags to catch exceptions later.
3081 // Transfer (B)ase and (E)xponent onto the FPU register stack. 3088 // Transfer (B)ase and (E)xponent onto the FPU register stack.
3082 __ sub(esp, Immediate(kDoubleSize)); 3089 __ sub(esp, Immediate(kDoubleSize));
3083 __ movdbl(Operand(esp, 0), xmm2); 3090 __ movdbl(Operand(esp, 0), double_exponent);
3084 __ fld_d(Operand(esp, 0)); // E 3091 __ fld_d(Operand(esp, 0)); // E
3085 __ movdbl(Operand(esp, 0), xmm1); 3092 __ movdbl(Operand(esp, 0), double_base);
3086 __ fld_d(Operand(esp, 0)); // B, E 3093 __ fld_d(Operand(esp, 0)); // B, E
3087 3094
3088 // Exponent is in st(1) and base is in st(0) 3095 // Exponent is in st(1) and base is in st(0)
3089 // B ^ E = (2^(E * log2(B)) - 1) + 1 = (2^X - 1) + 1 for X = E * log2(B) 3096 // B ^ E = (2^(E * log2(B)) - 1) + 1 = (2^X - 1) + 1 for X = E * log2(B)
3090 // FYL2X calculates st(1) * log2(st(0)) 3097 // FYL2X calculates st(1) * log2(st(0))
3091 __ fyl2x(); // X 3098 __ fyl2x(); // X
3092 __ fld(0); // X, X 3099 __ fld(0); // X, X
3093 __ frndint(); // rnd(X), X 3100 __ frndint(); // rnd(X), X
3094 __ fsub(1); // rnd(X), X-rnd(X) 3101 __ fsub(1); // rnd(X), X-rnd(X)
3095 __ fxch(1); // X - rnd(X), rnd(X) 3102 __ fxch(1); // X - rnd(X), rnd(X)
3096 // F2XM1 calculates 2^st(0) - 1 for -1 < st(0) < 1 3103 // F2XM1 calculates 2^st(0) - 1 for -1 < st(0) < 1
3097 __ f2xm1(); // 2^(X-rnd(X)) - 1, rnd(X) 3104 __ f2xm1(); // 2^(X-rnd(X)) - 1, rnd(X)
3098 __ fld1(); // 1, 2^(X-rnd(X)) - 1, rnd(X) 3105 __ fld1(); // 1, 2^(X-rnd(X)) - 1, rnd(X)
3099 __ faddp(1); // 1, 2^(X-rnd(X)), rnd(X) 3106 __ faddp(1); // 1, 2^(X-rnd(X)), rnd(X)
3100 // FSCALE calculates st(0) * 2^st(1) 3107 // FSCALE calculates st(0) * 2^st(1)
3101 __ fscale(); // 2^X, rnd(X) 3108 __ fscale(); // 2^X, rnd(X)
3102 __ fstp(1); 3109 __ fstp(1);
3103 // Bail out to runtime in case of exceptions in the status word. 3110 // Bail out to runtime in case of exceptions in the status word.
3104 __ fnstsw_ax(); 3111 __ fnstsw_ax();
3105 __ test_b(eax, 0x5F); // We check for all but precision exception. 3112 __ test_b(exponent, 0x5F); // We check for all but precision exception.
3106 __ j(not_zero, &fast_power_failed, Label::kNear); 3113 __ j(not_zero, &fast_power_failed, Label::kNear);
3107 __ fstp_d(Operand(esp, 0)); 3114 __ fstp_d(Operand(esp, 0));
3108 __ movdbl(xmm3, Operand(esp, 0)); 3115 __ movdbl(double_result, Operand(esp, 0));
3109 __ add(esp, Immediate(kDoubleSize)); 3116 __ add(esp, Immediate(kDoubleSize));
3110 __ jmp(&done); 3117 __ jmp(&done);
3111 3118
3112 __ bind(&fast_power_failed); 3119 __ bind(&fast_power_failed);
3113 __ fninit(); 3120 __ fninit();
3114 __ add(esp, Immediate(kDoubleSize)); 3121 __ add(esp, Immediate(kDoubleSize));
3115 __ jmp(&generic_runtime); 3122 __ jmp(&generic_runtime);
3116 } 3123 }
3117 3124
3118 // Calculate power with integer exponent. 3125 // Calculate power with integer exponent.
3119 __ bind(&int_exponent); 3126 __ bind(&int_exponent);
3120 // xmm1: base as double that is not +/- Infinity or NaN 3127 const XMMRegister double_scratch2 = double_exponent;
3121 // eax: exponent as untagged integer 3128 __ mov(scratch, exponent); // Back up exponent.
3122 __ mov(ecx, eax); // Back up exponent. 3129 __ movsd(double_scratch, double_base); // Back up base.
3123 __ movsd(xmm4, xmm1); // Back up base. 3130 __ movsd(double_scratch2, double_result); // Load double_exponent with 1.
3124 __ movsd(xmm2, xmm3); // Load xmm2 with 1.
3125
3126 3131
3127 // Get absolute value of exponent. 3132 // Get absolute value of exponent.
3128 Label no_neg, while_true, no_multiply; 3133 Label no_neg, while_true, no_multiply;
3129 __ cmp(eax, 0); 3134 __ cmp(exponent, 0);
3130 __ j(greater_equal, &no_neg, Label::kNear); 3135 __ j(greater_equal, &no_neg, Label::kNear);
3131 __ neg(eax); 3136 __ neg(exponent);
3132 __ bind(&no_neg); 3137 __ bind(&no_neg);
3133 3138
3134 __ bind(&while_true); 3139 __ bind(&while_true);
3135 __ shr(eax, 1); 3140 __ shr(exponent, 1);
3136 __ j(not_carry, &no_multiply, Label::kNear); 3141 __ j(not_carry, &no_multiply, Label::kNear);
3137 __ mulsd(xmm3, xmm1); 3142 __ mulsd(double_result, double_base);
3138 __ bind(&no_multiply); 3143 __ bind(&no_multiply);
3139 3144
3140 __ mulsd(xmm1, xmm1); 3145 __ mulsd(double_base, double_base);
3141 __ j(not_zero, &while_true); 3146 __ j(not_zero, &while_true);
3142 3147
3143 // base has the original value of the exponent - if the exponent is 3148 // scratch has the original value of the exponent - if the exponent is
3144 // negative return 1/result. 3149 // negative, return 1/result.
3145 __ test(ecx, ecx); 3150 __ test(scratch, scratch);
3146 __ j(positive, &done); 3151 __ j(positive, &done);
3147 __ divsd(xmm2, xmm3); 3152 __ divsd(double_scratch2, double_result);
3148 __ movsd(xmm3, xmm2); 3153 __ movsd(double_result, double_scratch2);
3149 // Test whether result is zero. Bail out to check for subnormal result. 3154 // Test whether result is zero. Bail out to check for subnormal result.
3150 // Due to subnormals, x^-y == (1/x)^y does not hold in all cases. 3155 // Due to subnormals, x^-y == (1/x)^y does not hold in all cases.
3151 __ xorps(xmm2, xmm2); 3156 __ xorps(double_scratch2, double_scratch2);
3152 __ ucomisd(xmm2, xmm3); // Result cannot be NaN. 3157 __ ucomisd(double_scratch2, double_result); // Result cannot be NaN.
3153 __ j(equal, &double_int_runtime); 3158 __ j(equal, &double_int_runtime);
3154 3159
3155 // Returning or bailing out. 3160 // Returning or bailing out.
3156 if (exponent_type_ == ON_STACK) { 3161 if (exponent_type_ == ON_STACK) {
3157 // The stub is called from non-optimized code, which expects the result 3162 // The stub is called from non-optimized code, which expects the result
3158 // as heap number in eax. 3163 // as heap number in exponent.
3159 __ bind(&done); 3164 __ bind(&done);
3160 // xmm3: result 3165 __ AllocateHeapNumber(exponent, scratch, base, &generic_runtime);
3161 __ AllocateHeapNumber(eax, ecx, edx, &generic_runtime); 3166 __ movdbl(FieldOperand(exponent, HeapNumber::kValueOffset), double_result);
3162 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm3);
3163 __ ret(2 * kPointerSize); 3167 __ ret(2 * kPointerSize);
3164 3168
3165 // The arguments are still on the stack. 3169 // The arguments are still on the stack.
3166 __ bind(&generic_runtime); 3170 __ bind(&generic_runtime);
3167 __ bind(&double_int_runtime); 3171 __ bind(&double_int_runtime);
3168 __ TailCallRuntime(Runtime::kMath_pow_cfunction, 2, 1); 3172 __ TailCallRuntime(Runtime::kMath_pow_cfunction, 2, 1);
3169 } else { 3173 } else {
3170 __ jmp(&done); 3174 __ jmp(&done);
3171 3175
3172 Label return_from_runtime; 3176 Label return_from_runtime;
3173 StubRuntimeCallHelper callhelper;
3174 __ bind(&generic_runtime); 3177 __ bind(&generic_runtime);
3175 // xmm1: base
3176 // xmm2: exponent
3177 { 3178 {
3178 AllowExternalCallThatCantCauseGC scope(masm); 3179 AllowExternalCallThatCantCauseGC scope(masm);
3179 __ PrepareCallCFunction(4, eax); 3180 __ PrepareCallCFunction(4, exponent);
3180 __ movdbl(Operand(esp, 0 * kDoubleSize), xmm1); 3181 __ movdbl(Operand(esp, 0 * kDoubleSize), double_base);
3181 __ movdbl(Operand(esp, 1 * kDoubleSize), xmm2); 3182 __ movdbl(Operand(esp, 1 * kDoubleSize), double_exponent);
3182 __ CallCFunction( 3183 __ CallCFunction(
3183 ExternalReference::power_double_double_function(masm->isolate()), 4); 3184 ExternalReference::power_double_double_function(masm->isolate()), 4);
3184 } 3185 }
3185 __ jmp(&return_from_runtime, Label::kNear); 3186 __ jmp(&return_from_runtime, Label::kNear);
3186 3187
3187 __ bind(&double_int_runtime); 3188 __ bind(&double_int_runtime);
3188 // xmm4: base
3189 // ecx: exponent
3190 { 3189 {
3191 AllowExternalCallThatCantCauseGC scope(masm); 3190 AllowExternalCallThatCantCauseGC scope(masm);
3192 __ PrepareCallCFunction(4, eax); 3191 __ PrepareCallCFunction(4, exponent);
3193 __ movdbl(Operand(esp, 0 * kDoubleSize), xmm4); 3192 __ movdbl(Operand(esp, 0 * kDoubleSize), double_scratch);
3194 __ mov(Operand(esp, 1 * kDoubleSize), ecx); 3193 __ mov(Operand(esp, 1 * kDoubleSize), scratch);
3195 __ CallCFunction( 3194 __ CallCFunction(
3196 ExternalReference::power_double_int_function(masm->isolate()), 4); 3195 ExternalReference::power_double_int_function(masm->isolate()), 4);
3197 } 3196 }
3198 3197
3199 __ bind(&return_from_runtime); 3198 __ bind(&return_from_runtime);
3200 // Return value is in st(0) on ia32. 3199 // Return value is in st(0) on ia32.
3201 // Store it into the (fixed) result register. 3200 // Store it into the (fixed) result register.
3202 __ sub(esp, Immediate(kDoubleSize)); 3201 __ sub(esp, Immediate(kDoubleSize));
3203 __ fstp_d(Operand(esp, 0)); 3202 __ fstp_d(Operand(esp, 0));
3204 __ movdbl(xmm3, Operand(esp, 0)); 3203 __ movdbl(double_result, Operand(esp, 0));
3205 __ add(esp, Immediate(kDoubleSize)); 3204 __ add(esp, Immediate(kDoubleSize));
3206 3205
3207 // xmm3: result
3208 __ bind(&done); 3206 __ bind(&done);
3209 __ ret(0); 3207 __ ret(0);
3210 } 3208 }
3211 } 3209 }
3212 3210
3213 3211
3214 void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { 3212 void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) {
3215 // The key is in edx and the parameter count is in eax. 3213 // The key is in edx and the parameter count is in eax.
3216 3214
3217 // The displacement is used for skipping the frame pointer on the 3215 // The displacement is used for skipping the frame pointer on the
(...skipping 4072 matching lines...) Expand 10 before | Expand all | Expand 10 after
7290 false); 7288 false);
7291 __ pop(edx); 7289 __ pop(edx);
7292 __ ret(0); 7290 __ ret(0);
7293 } 7291 }
7294 7292
7295 #undef __ 7293 #undef __
7296 7294
7297 } } // namespace v8::internal 7295 } } // namespace v8::internal
7298 7296
7299 #endif // V8_TARGET_ARCH_IA32 7297 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « no previous file | src/ia32/lithium-codegen-ia32.cc » ('j') | src/ia32/lithium-codegen-ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698