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

Side by Side Diff: src/arm/codegen-arm.cc

Issue 1689007: Port improvement to Math.random to ARM. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 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 | « AUTHORS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 4214 matching lines...) Expand 10 before | Expand all | Expand 10 after
4225 4225
4226 4226
4227 void CodeGenerator::GenerateRandomHeapNumber( 4227 void CodeGenerator::GenerateRandomHeapNumber(
4228 ZoneList<Expression*>* args) { 4228 ZoneList<Expression*>* args) {
4229 VirtualFrame::SpilledScope spilled_scope(frame_); 4229 VirtualFrame::SpilledScope spilled_scope(frame_);
4230 ASSERT(args->length() == 0); 4230 ASSERT(args->length() == 0);
4231 4231
4232 Label slow_allocate_heapnumber; 4232 Label slow_allocate_heapnumber;
4233 Label heapnumber_allocated; 4233 Label heapnumber_allocated;
4234 4234
4235 __ AllocateHeapNumber(r0, r1, r2, &slow_allocate_heapnumber); 4235 __ AllocateHeapNumber(r4, r1, r2, &slow_allocate_heapnumber);
4236 __ jmp(&heapnumber_allocated); 4236 __ jmp(&heapnumber_allocated);
4237 4237
4238 __ bind(&slow_allocate_heapnumber); 4238 __ bind(&slow_allocate_heapnumber);
4239 // To allocate a heap number, and ensure that it is not a smi, we
4240 // call the runtime function FUnaryMinus on 0, returning the double
4241 // -0.0. A new, distinct heap number is returned each time.
4239 __ mov(r0, Operand(Smi::FromInt(0))); 4242 __ mov(r0, Operand(Smi::FromInt(0)));
4240 __ push(r0); 4243 __ push(r0);
4241 __ CallRuntime(Runtime::kNumberUnaryMinus, 1); 4244 __ CallRuntime(Runtime::kNumberUnaryMinus, 1);
Lasse Reichstein 2010/04/23 12:12:50 It seems fragile to use a function meant for somet
4245 __ mov(r4, Operand(r0));
4242 4246
4243 __ bind(&heapnumber_allocated); 4247 __ bind(&heapnumber_allocated);
4244 __ PrepareCallCFunction(1, r1); 4248
4245 __ CallCFunction( 4249 // Convert 32 random bits in r0 to 0.(32 random bits) in a double
4246 ExternalReference::fill_heap_number_with_random_function(), 1); 4250 // by computing:
4247 frame_->EmitPush(r0); 4251 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)).
4252 if (CpuFeatures::IsSupported(VFP3)) {
4253 __ PrepareCallCFunction(0, r1);
4254 __ CallCFunction(ExternalReference::random_uint32_function(), 0);
4255
4256 CpuFeatures::Scope scope(VFP3);
4257 // 0x41300000 is the top half of 1.0 x 2^20 as a double.
4258 // Create this constant using mov/orr to avoid PC relative load.
4259 __ mov(r1, Operand(0x41000000));
4260 __ orr(r1, r1, Operand(0x300000));
4261 // Move 0x41300000xxxxxxxx (x = random bits) to VFP.
4262 __ vmov(d7, r0, r1);
4263 // Move 0x4130000000000000 to VFP.
4264 __ mov(r0, Operand(0));
4265 __ vmov(d8, r0, r1);
4266 // Subtract and store the result in the heap number.
4267 __ vsub(d7, d7, d8);
4268 __ sub(r0, r4, Operand(kHeapObjectTag));
4269 __ vstr(d7, r0, HeapNumber::kValueOffset);
4270 frame_->EmitPush(r4);
4271 } else {
4272 __ mov(r0, Operand(r4));
4273 __ PrepareCallCFunction(1, r1);
4274 __ CallCFunction(
4275 ExternalReference::fill_heap_number_with_random_function(), 1);
4276 frame_->EmitPush(r0);
4277 }
4248 } 4278 }
4249 4279
4250 4280
4251 void CodeGenerator::GenerateStringAdd(ZoneList<Expression*>* args) { 4281 void CodeGenerator::GenerateStringAdd(ZoneList<Expression*>* args) {
4252 ASSERT_EQ(2, args->length()); 4282 ASSERT_EQ(2, args->length());
4253 4283
4254 Load(args->at(0)); 4284 Load(args->at(0));
4255 Load(args->at(1)); 4285 Load(args->at(1));
4256 4286
4257 StringAddStub stub(NO_STRING_ADD_FLAGS); 4287 StringAddStub stub(NO_STRING_ADD_FLAGS);
(...skipping 5026 matching lines...) Expand 10 before | Expand all | Expand 10 after
9284 9314
9285 // Just jump to runtime to add the two strings. 9315 // Just jump to runtime to add the two strings.
9286 __ bind(&string_add_runtime); 9316 __ bind(&string_add_runtime);
9287 __ TailCallRuntime(Runtime::kStringAdd, 2, 1); 9317 __ TailCallRuntime(Runtime::kStringAdd, 2, 1);
9288 } 9318 }
9289 9319
9290 9320
9291 #undef __ 9321 #undef __
9292 9322
9293 } } // namespace v8::internal 9323 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698