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

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

Issue 82763005: Reland "Implement Math.random() purely in JavaScript" plus fixes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added assertion Created 7 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/arm/lithium-arm.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 3329 matching lines...) Expand 10 before | Expand all | Expand 10 after
3340 VisitForStackValue(args->at(2)); 3340 VisitForStackValue(args->at(2));
3341 __ CallRuntime(Runtime::kLog, 2); 3341 __ CallRuntime(Runtime::kLog, 2);
3342 } 3342 }
3343 3343
3344 // Finally, we're expected to leave a value on the top of the stack. 3344 // Finally, we're expected to leave a value on the top of the stack.
3345 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); 3345 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex);
3346 context()->Plug(r0); 3346 context()->Plug(r0);
3347 } 3347 }
3348 3348
3349 3349
3350 void FullCodeGenerator::EmitRandomHeapNumber(CallRuntime* expr) {
3351 ASSERT(expr->arguments()->length() == 0);
3352 Label slow_allocate_heapnumber;
3353 Label heapnumber_allocated;
3354
3355 __ LoadRoot(r6, Heap::kHeapNumberMapRootIndex);
3356 __ AllocateHeapNumber(r4, r1, r2, r6, &slow_allocate_heapnumber);
3357 __ jmp(&heapnumber_allocated);
3358
3359 __ bind(&slow_allocate_heapnumber);
3360 // Allocate a heap number.
3361 __ CallRuntime(Runtime::kNumberAlloc, 0);
3362 __ mov(r4, Operand(r0));
3363
3364 __ bind(&heapnumber_allocated);
3365
3366 // Convert 32 random bits in r0 to 0.(32 random bits) in a double
3367 // by computing:
3368 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)).
3369 __ PrepareCallCFunction(1, r0);
3370 __ ldr(r0,
3371 ContextOperand(context_register(), Context::GLOBAL_OBJECT_INDEX));
3372 __ ldr(r0, FieldMemOperand(r0, GlobalObject::kNativeContextOffset));
3373 __ CallCFunction(ExternalReference::random_uint32_function(isolate()), 1);
3374
3375 // 0x41300000 is the top half of 1.0 x 2^20 as a double.
3376 // Create this constant using mov/orr to avoid PC relative load.
3377 __ mov(r1, Operand(0x41000000));
3378 __ orr(r1, r1, Operand(0x300000));
3379 // Move 0x41300000xxxxxxxx (x = random bits) to VFP.
3380 __ vmov(d7, r0, r1);
3381 // Move 0x4130000000000000 to VFP.
3382 __ mov(r0, Operand::Zero());
3383 __ vmov(d8, r0, r1);
3384 // Subtract and store the result in the heap number.
3385 __ vsub(d7, d7, d8);
3386 __ sub(r0, r4, Operand(kHeapObjectTag));
3387 __ vstr(d7, r0, HeapNumber::kValueOffset);
3388 __ mov(r0, r4);
3389
3390 context()->Plug(r0);
3391 }
3392
3393
3394 void FullCodeGenerator::EmitSubString(CallRuntime* expr) { 3350 void FullCodeGenerator::EmitSubString(CallRuntime* expr) {
3395 // Load the arguments on the stack and call the stub. 3351 // Load the arguments on the stack and call the stub.
3396 SubStringStub stub; 3352 SubStringStub stub;
3397 ZoneList<Expression*>* args = expr->arguments(); 3353 ZoneList<Expression*>* args = expr->arguments();
3398 ASSERT(args->length() == 3); 3354 ASSERT(args->length() == 3);
3399 VisitForStackValue(args->at(0)); 3355 VisitForStackValue(args->at(0));
3400 VisitForStackValue(args->at(1)); 3356 VisitForStackValue(args->at(1));
3401 VisitForStackValue(args->at(2)); 3357 VisitForStackValue(args->at(2));
3402 __ CallStub(&stub); 3358 __ CallStub(&stub);
3403 context()->Plug(r0); 3359 context()->Plug(r0);
(...skipping 1559 matching lines...) Expand 10 before | Expand all | Expand 10 after
4963 ASSERT(Memory::uint32_at(interrupt_address_pointer) == 4919 ASSERT(Memory::uint32_at(interrupt_address_pointer) ==
4964 reinterpret_cast<uint32_t>( 4920 reinterpret_cast<uint32_t>(
4965 isolate->builtins()->OsrAfterStackCheck()->entry())); 4921 isolate->builtins()->OsrAfterStackCheck()->entry()));
4966 return OSR_AFTER_STACK_CHECK; 4922 return OSR_AFTER_STACK_CHECK;
4967 } 4923 }
4968 4924
4969 4925
4970 } } // namespace v8::internal 4926 } } // namespace v8::internal
4971 4927
4972 #endif // V8_TARGET_ARCH_ARM 4928 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm/lithium-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698