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

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

Issue 6874007: Implement hardfloat calling convention in macro assembler and simulator. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add num_double_arguments to CallCFunction Created 9 years, 8 months 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/arm/lithium-codegen-arm.cc » ('j') | no next file with comments »
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 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 // r2: Right value (least significant part of mantissa). 823 // r2: Right value (least significant part of mantissa).
824 // r3: Right value (sign, exponent, top of mantissa). 824 // r3: Right value (sign, exponent, top of mantissa).
825 825
826 // Assert that heap_number_result is callee-saved. 826 // Assert that heap_number_result is callee-saved.
827 // We currently always use r5 to pass it. 827 // We currently always use r5 to pass it.
828 ASSERT(heap_number_result.is(r5)); 828 ASSERT(heap_number_result.is(r5));
829 829
830 // Push the current return address before the C call. Return will be 830 // Push the current return address before the C call. Return will be
831 // through pop(pc) below. 831 // through pop(pc) below.
832 __ push(lr); 832 __ push(lr);
833 __ PrepareCallCFunction(4, scratch); // Two doubles are 4 arguments. 833 __ PrepareCallCFunction(0, 2, scratch);
834 if (FLAG_hardfloat) {
835 ASSERT(CpuFeatures::IsSupported(VFP3));
836 CpuFeatures::Scope scope(VFP3);
837 __ vmov(d0, r0, r1);
838 __ vmov(d1, r2, r3);
839 }
834 // Call C routine that may not cause GC or other trouble. 840 // Call C routine that may not cause GC or other trouble.
835 __ CallCFunction(ExternalReference::double_fp_operation(op, masm->isolate()), 841 __ CallCFunction(ExternalReference::double_fp_operation(op, masm->isolate()),
836 4); 842 0, 2);
837 // Store answer in the overwritable heap number. Double returned in 843 // Store answer in the overwritable heap number. Double returned in
838 // registers r0 and r1. 844 // registers r0 and r1 or in d0.
839 __ Strd(r0, r1, FieldMemOperand(heap_number_result, 845 if (FLAG_hardfloat) {
840 HeapNumber::kValueOffset)); 846 CpuFeatures::Scope scope(VFP3);
847 __ vstr(d0,
848 FieldMemOperand(heap_number_result, HeapNumber::kValueOffset));
849 } else {
850 __ Strd(r0, r1, FieldMemOperand(heap_number_result,
851 HeapNumber::kValueOffset));
852 }
841 // Place heap_number_result in r0 and return to the pushed return address. 853 // Place heap_number_result in r0 and return to the pushed return address.
842 __ mov(r0, Operand(heap_number_result)); 854 __ mov(r0, Operand(heap_number_result));
843 __ pop(pc); 855 __ pop(pc);
844 } 856 }
845 857
846 858
847 // See comment for class. 859 // See comment for class.
848 void WriteInt32ToHeapNumberStub::Generate(MacroAssembler* masm) { 860 void WriteInt32ToHeapNumberStub::Generate(MacroAssembler* masm) {
849 Label max_negative_int; 861 Label max_negative_int;
850 // the_int_ has the answer which is a signed int32 but not a Smi. 862 // the_int_ has the answer which is a signed int32 but not a Smi.
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 __ mov(r0, Operand(r4), LeaveCC, ne); 1184 __ mov(r0, Operand(r4), LeaveCC, ne);
1173 __ Ret(ne); 1185 __ Ret(ne);
1174 // Now they are equal if and only if the lhs exponent is zero in its 1186 // Now they are equal if and only if the lhs exponent is zero in its
1175 // low 31 bits. 1187 // low 31 bits.
1176 __ mov(r0, Operand(rhs_exponent, LSL, kSmiTagSize)); 1188 __ mov(r0, Operand(rhs_exponent, LSL, kSmiTagSize));
1177 __ Ret(); 1189 __ Ret();
1178 } else { 1190 } else {
1179 // Call a native function to do a comparison between two non-NaNs. 1191 // Call a native function to do a comparison between two non-NaNs.
1180 // Call C routine that may not cause GC or other trouble. 1192 // Call C routine that may not cause GC or other trouble.
1181 __ push(lr); 1193 __ push(lr);
1182 __ PrepareCallCFunction(4, r5); // Two doubles count as 4 arguments. 1194 __ PrepareCallCFunction(0, 2, r5);
1183 __ CallCFunction(ExternalReference::compare_doubles(masm->isolate()), 4); 1195 if (FLAG_hardfloat) {
1196 ASSERT(CpuFeatures::IsSupported(VFP3));
1197 CpuFeatures::Scope scope(VFP3);
1198 __ vmov(d0, r0, r1);
1199 __ vmov(d1, r2, r3);
1200 }
1201 __ CallCFunction(ExternalReference::compare_doubles(masm->isolate()),
1202 0, 2);
1184 __ pop(pc); // Return. 1203 __ pop(pc); // Return.
1185 } 1204 }
1186 } 1205 }
1187 1206
1188 1207
1189 // See comment at call site. 1208 // See comment at call site.
1190 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, 1209 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm,
1191 Register lhs, 1210 Register lhs,
1192 Register rhs) { 1211 Register rhs) {
1193 ASSERT((lhs.is(r0) && rhs.is(r1)) || 1212 ASSERT((lhs.is(r0) && rhs.is(r1)) ||
(...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after
2827 __ Ret(); 2846 __ Ret();
2828 } 2847 }
2829 } 2848 }
2830 2849
2831 2850
2832 void TranscendentalCacheStub::GenerateCallCFunction(MacroAssembler* masm, 2851 void TranscendentalCacheStub::GenerateCallCFunction(MacroAssembler* masm,
2833 Register scratch) { 2852 Register scratch) {
2834 Isolate* isolate = masm->isolate(); 2853 Isolate* isolate = masm->isolate();
2835 2854
2836 __ push(lr); 2855 __ push(lr);
2837 __ PrepareCallCFunction(2, scratch); 2856 __ PrepareCallCFunction(0, 1, scratch);
2838 __ vmov(r0, r1, d2); 2857 if (FLAG_hardfloat) {
2858 __ vmov(d0, d2);
2859 } else {
2860 __ vmov(r0, r1, d2);
2861 }
2839 switch (type_) { 2862 switch (type_) {
2840 case TranscendentalCache::SIN: 2863 case TranscendentalCache::SIN:
2841 __ CallCFunction(ExternalReference::math_sin_double_function(isolate), 2); 2864 __ CallCFunction(ExternalReference::math_sin_double_function(isolate),
2865 0, 1);
2842 break; 2866 break;
2843 case TranscendentalCache::COS: 2867 case TranscendentalCache::COS:
2844 __ CallCFunction(ExternalReference::math_cos_double_function(isolate), 2); 2868 __ CallCFunction(ExternalReference::math_cos_double_function(isolate),
2869 0, 1);
2845 break; 2870 break;
2846 case TranscendentalCache::LOG: 2871 case TranscendentalCache::LOG:
2847 __ CallCFunction(ExternalReference::math_log_double_function(isolate), 2); 2872 __ CallCFunction(ExternalReference::math_log_double_function(isolate),
2873 0, 1);
2848 break; 2874 break;
2849 default: 2875 default:
2850 UNIMPLEMENTED(); 2876 UNIMPLEMENTED();
2851 break; 2877 break;
2852 } 2878 }
2853 __ pop(lr); 2879 __ pop(lr);
2854 } 2880 }
2855 2881
2856 2882
2857 Runtime::FunctionId TranscendentalCacheStub::RuntimeFunction() { 2883 Runtime::FunctionId TranscendentalCacheStub::RuntimeFunction() {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
3054 // The base is in a double register and the exponent is 3080 // The base is in a double register and the exponent is
3055 // an untagged smi. Allocate a heap number and call a 3081 // an untagged smi. Allocate a heap number and call a
3056 // C function for integer exponents. The register containing 3082 // C function for integer exponents. The register containing
3057 // the heap number is callee-saved. 3083 // the heap number is callee-saved.
3058 __ AllocateHeapNumber(heapnumber, 3084 __ AllocateHeapNumber(heapnumber,
3059 scratch, 3085 scratch,
3060 scratch2, 3086 scratch2,
3061 heapnumbermap, 3087 heapnumbermap,
3062 &call_runtime); 3088 &call_runtime);
3063 __ push(lr); 3089 __ push(lr);
3064 __ PrepareCallCFunction(3, scratch); 3090 __ PrepareCallCFunction(1, 1, scratch);
3065 __ mov(r2, exponent); 3091 __ SetCallCDoubleArguments(double_base, exponent);
3066 __ vmov(r0, r1, double_base);
3067 __ CallCFunction( 3092 __ CallCFunction(
3068 ExternalReference::power_double_int_function(masm->isolate()), 3); 3093 ExternalReference::power_double_int_function(masm->isolate()),
3094 1, 1);
3069 __ pop(lr); 3095 __ pop(lr);
3070 __ GetCFunctionDoubleResult(double_result); 3096 __ GetCFunctionDoubleResult(double_result);
3071 __ vstr(double_result, 3097 __ vstr(double_result,
3072 FieldMemOperand(heapnumber, HeapNumber::kValueOffset)); 3098 FieldMemOperand(heapnumber, HeapNumber::kValueOffset));
3073 __ mov(r0, heapnumber); 3099 __ mov(r0, heapnumber);
3074 __ Ret(2 * kPointerSize); 3100 __ Ret(2 * kPointerSize);
3075 3101
3076 __ bind(&exponent_not_smi); 3102 __ bind(&exponent_not_smi);
3077 __ ldr(scratch, FieldMemOperand(exponent, JSObject::kMapOffset)); 3103 __ ldr(scratch, FieldMemOperand(exponent, JSObject::kMapOffset));
3078 __ cmp(scratch, heapnumbermap); 3104 __ cmp(scratch, heapnumbermap);
3079 __ b(ne, &call_runtime); 3105 __ b(ne, &call_runtime);
3080 // Exponent is a heapnumber. Load it into double register. 3106 // Exponent is a heapnumber. Load it into double register.
3081 __ vldr(double_exponent, 3107 __ vldr(double_exponent,
3082 FieldMemOperand(exponent, HeapNumber::kValueOffset)); 3108 FieldMemOperand(exponent, HeapNumber::kValueOffset));
3083 3109
3084 // The base and the exponent are in double registers. 3110 // The base and the exponent are in double registers.
3085 // Allocate a heap number and call a C function for 3111 // Allocate a heap number and call a C function for
3086 // double exponents. The register containing 3112 // double exponents. The register containing
3087 // the heap number is callee-saved. 3113 // the heap number is callee-saved.
3088 __ AllocateHeapNumber(heapnumber, 3114 __ AllocateHeapNumber(heapnumber,
3089 scratch, 3115 scratch,
3090 scratch2, 3116 scratch2,
3091 heapnumbermap, 3117 heapnumbermap,
3092 &call_runtime); 3118 &call_runtime);
3093 __ push(lr); 3119 __ push(lr);
3094 __ PrepareCallCFunction(4, scratch); 3120 __ PrepareCallCFunction(0, 2, scratch);
3095 __ vmov(r0, r1, double_base); 3121 __ SetCallCDoubleArguments(double_base, double_exponent);
3096 __ vmov(r2, r3, double_exponent);
3097 __ CallCFunction( 3122 __ CallCFunction(
3098 ExternalReference::power_double_double_function(masm->isolate()), 4); 3123 ExternalReference::power_double_double_function(masm->isolate()),
3124 0, 2);
3099 __ pop(lr); 3125 __ pop(lr);
3100 __ GetCFunctionDoubleResult(double_result); 3126 __ GetCFunctionDoubleResult(double_result);
3101 __ vstr(double_result, 3127 __ vstr(double_result,
3102 FieldMemOperand(heapnumber, HeapNumber::kValueOffset)); 3128 FieldMemOperand(heapnumber, HeapNumber::kValueOffset));
3103 __ mov(r0, heapnumber); 3129 __ mov(r0, heapnumber);
3104 __ Ret(2 * kPointerSize); 3130 __ Ret(2 * kPointerSize);
3105 } 3131 }
3106 3132
3107 __ bind(&call_runtime); 3133 __ bind(&call_runtime);
3108 __ TailCallRuntime(Runtime::kMath_pow_cfunction, 2, 1); 3134 __ TailCallRuntime(Runtime::kMath_pow_cfunction, 2, 1);
(...skipping 23 matching lines...) Expand all
3132 bool do_gc, 3158 bool do_gc,
3133 bool always_allocate) { 3159 bool always_allocate) {
3134 // r0: result parameter for PerformGC, if any 3160 // r0: result parameter for PerformGC, if any
3135 // r4: number of arguments including receiver (C callee-saved) 3161 // r4: number of arguments including receiver (C callee-saved)
3136 // r5: pointer to builtin function (C callee-saved) 3162 // r5: pointer to builtin function (C callee-saved)
3137 // r6: pointer to the first argument (C callee-saved) 3163 // r6: pointer to the first argument (C callee-saved)
3138 Isolate* isolate = masm->isolate(); 3164 Isolate* isolate = masm->isolate();
3139 3165
3140 if (do_gc) { 3166 if (do_gc) {
3141 // Passing r0. 3167 // Passing r0.
3142 __ PrepareCallCFunction(1, r1); 3168 __ PrepareCallCFunction(1, 0, r1);
3143 __ CallCFunction(ExternalReference::perform_gc_function(isolate), 1); 3169 __ CallCFunction(ExternalReference::perform_gc_function(isolate),
3170 1, 0);
3144 } 3171 }
3145 3172
3146 ExternalReference scope_depth = 3173 ExternalReference scope_depth =
3147 ExternalReference::heap_always_allocate_scope_depth(isolate); 3174 ExternalReference::heap_always_allocate_scope_depth(isolate);
3148 if (always_allocate) { 3175 if (always_allocate) {
3149 __ mov(r0, Operand(scope_depth)); 3176 __ mov(r0, Operand(scope_depth));
3150 __ ldr(r1, MemOperand(r0)); 3177 __ ldr(r1, MemOperand(r0));
3151 __ add(r1, r1, Operand(1)); 3178 __ add(r1, r1, Operand(1));
3152 __ str(r1, MemOperand(r0)); 3179 __ str(r1, MemOperand(r0));
3153 } 3180 }
(...skipping 2623 matching lines...) Expand 10 before | Expand all | Expand 10 after
5777 __ str(pc, MemOperand(sp, 0)); 5804 __ str(pc, MemOperand(sp, 0));
5778 __ Jump(target); // Call the C++ function. 5805 __ Jump(target); // Call the C++ function.
5779 } 5806 }
5780 5807
5781 5808
5782 #undef __ 5809 #undef __
5783 5810
5784 } } // namespace v8::internal 5811 } } // namespace v8::internal
5785 5812
5786 #endif // V8_TARGET_ARCH_ARM 5813 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm/lithium-codegen-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698