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

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

Issue 6613015: ARM: Implement MathPowStub and DoMathPowHalf. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Minor edits. Created 9 years, 9 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/full-codegen-arm.cc » ('j') | src/arm/lithium-codegen-arm.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 4038 matching lines...) Expand 10 before | Expand all | Expand 10 after
4049 break; 4049 break;
4050 case Token::BIT_NOT: 4050 case Token::BIT_NOT:
4051 __ InvokeBuiltin(Builtins::BIT_NOT, JUMP_JS); 4051 __ InvokeBuiltin(Builtins::BIT_NOT, JUMP_JS);
4052 break; 4052 break;
4053 default: 4053 default:
4054 UNREACHABLE(); 4054 UNREACHABLE();
4055 } 4055 }
4056 } 4056 }
4057 4057
4058 4058
4059 void MathPowStub::Generate(MacroAssembler* masm) {
4060 Label call_runtime;
4061
4062 if (CpuFeatures::IsSupported(VFP3)) {
4063 CpuFeatures::Scope scope(VFP3);
4064
4065 Label base_not_smi;
4066 Label exponent_not_smi;
4067 Label convert_exponent;
4068
4069 const Register base = r0;
4070 const Register exponent = r1;
4071 const Register result = r0;
4072 const Register heapnumbermap = r5;
4073 const Register heapnumber = r6;
4074 const DoubleRegister double_base = d0;
4075 const DoubleRegister double_exponent = d1;
4076 const DoubleRegister double_result = d2;
4077 const SwVfpRegister single_scratch = s0;
4078 const Register scratch = r9;
4079 const Register scratch2 = r7;
4080
4081 ASSERT(result.is(r0));
4082
4083 __ LoadRoot(heapnumbermap, Heap::kHeapNumberMapRootIndex);
4084 __ ldr(base, MemOperand(sp, 1 * kPointerSize));
4085 __ ldr(exponent, MemOperand(sp, 0 * kPointerSize));
4086
4087 // Convert base to double value and store it in d0.
4088 __ JumpIfNotSmi(base, &base_not_smi);
4089 // Base is a Smi. Untag and convert it.
4090 __ SmiUntag(base);
4091 __ vmov(single_scratch, base);
4092 __ vcvt_f64_s32(double_base, single_scratch);
4093 __ b(&convert_exponent);
4094
4095 __ bind(&base_not_smi);
4096 __ ldr(scratch, FieldMemOperand(base, JSObject::kMapOffset));
4097 __ cmp(scratch, heapnumbermap);
4098 __ b(ne, &call_runtime);
4099 // Base is a heapnumber. Load it into double register.
4100 __ vldr(double_base, FieldMemOperand(base, HeapNumber::kValueOffset));
4101
4102 __ bind(&convert_exponent);
4103 __ JumpIfNotSmi(exponent, &exponent_not_smi);
4104 __ SmiUntag(exponent);
4105
4106 // The base is in a double register and the exponent is
4107 // an untagged smi. Allocate a heap number and call a
4108 // C function for integer exponents.
Søren Thygesen Gjesse 2011/03/08 10:05:12 Maybe add a comment that heapnumber is callee save
Karl Klose 2011/03/08 10:29:00 Done.
4109 __ AllocateHeapNumber(heapnumber,
4110 scratch,
4111 scratch2,
4112 heapnumbermap,
4113 &call_runtime);
4114 __ push(lr);
4115 __ PrepareCallCFunction(3, scratch);
4116 __ mov(r2, exponent);
4117 __ vmov(r0, r1, double_base);
4118 __ CallCFunction(ExternalReference::power_double_int_function(), 3);
4119 __ pop(lr);
4120 __ GetCFunctionDoubleResult(double_result);
4121 __ vstr(double_result,
4122 FieldMemOperand(heapnumber, HeapNumber::kValueOffset));
4123 __ mov(result, heapnumber);
Søren Thygesen Gjesse 2011/03/08 10:05:12 I think it would be fine to just use r0 here and d
Karl Klose 2011/03/08 10:29:00 Done.
4124 __ Ret(2 * kPointerSize);
4125
4126 __ bind(&exponent_not_smi);
4127 __ ldr(scratch, FieldMemOperand(exponent, JSObject::kMapOffset));
4128 __ cmp(scratch, heapnumbermap);
4129 __ b(ne, &call_runtime);
4130 // Exponent is a heapnumber. Load it into double register.
4131 __ vldr(double_exponent,
4132 FieldMemOperand(exponent, HeapNumber::kValueOffset));
4133
4134 // The base and the exponent are in double registers.
4135 // Allocate a heap number and call a C function for
4136 // double exponents.
Søren Thygesen Gjesse 2011/03/08 10:05:12 Ditto.
Karl Klose 2011/03/08 10:29:00 Done.
4137 __ AllocateHeapNumber(heapnumber,
4138 scratch,
4139 scratch2,
4140 heapnumbermap,
4141 &call_runtime);
4142 __ push(lr);
4143 __ PrepareCallCFunction(4, scratch);
4144 __ vmov(r0, r1, double_base);
4145 __ vmov(r2, r3, double_exponent);
4146 __ CallCFunction(ExternalReference::power_double_double_function(), 4);
4147 __ pop(lr);
4148 __ GetCFunctionDoubleResult(double_result);
4149 __ vstr(double_result,
4150 FieldMemOperand(heapnumber, HeapNumber::kValueOffset));
4151 __ mov(result, heapnumber);
Søren Thygesen Gjesse 2011/03/08 10:05:12 Ditto.
Karl Klose 2011/03/08 10:29:00 Done.
4152 __ Ret(2 * kPointerSize);
4153 }
4154
4155 __ bind(&call_runtime);
4156 __ TailCallRuntime(Runtime::kMath_pow_cfunction, 2, 1);
4157 }
4158
4159
4059 void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) { 4160 void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) {
4060 __ Throw(r0); 4161 __ Throw(r0);
4061 } 4162 }
4062 4163
4063 4164
4064 void CEntryStub::GenerateThrowUncatchable(MacroAssembler* masm, 4165 void CEntryStub::GenerateThrowUncatchable(MacroAssembler* masm,
4065 UncatchableExceptionType type) { 4166 UncatchableExceptionType type) {
4066 __ ThrowUncatchable(type, r0); 4167 __ ThrowUncatchable(type, r0);
4067 } 4168 }
4068 4169
(...skipping 2808 matching lines...) Expand 10 before | Expand all | Expand 10 after
6877 __ strb(untagged_value, MemOperand(external_pointer, untagged_key)); 6978 __ strb(untagged_value, MemOperand(external_pointer, untagged_key));
6878 __ Ret(); 6979 __ Ret();
6879 } 6980 }
6880 6981
6881 6982
6882 #undef __ 6983 #undef __
6883 6984
6884 } } // namespace v8::internal 6985 } } // namespace v8::internal
6885 6986
6886 #endif // V8_TARGET_ARCH_ARM 6987 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm/full-codegen-arm.cc » ('j') | src/arm/lithium-codegen-arm.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698