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

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

Issue 1599019: Change Math.random() to return 32 bits of random goodness, instead of 30 rand... (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 | « src/ia32/codegen-ia32.h ('k') | src/math.js » ('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 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 6412 matching lines...) Expand 10 before | Expand all | Expand 10 after
6423 void CodeGenerator::GenerateGetFramePointer(ZoneList<Expression*>* args) { 6423 void CodeGenerator::GenerateGetFramePointer(ZoneList<Expression*>* args) {
6424 ASSERT(args->length() == 0); 6424 ASSERT(args->length() == 0);
6425 ASSERT(kSmiTag == 0); // EBP value is aligned, so it should look like Smi. 6425 ASSERT(kSmiTag == 0); // EBP value is aligned, so it should look like Smi.
6426 Result ebp_as_smi = allocator_->Allocate(); 6426 Result ebp_as_smi = allocator_->Allocate();
6427 ASSERT(ebp_as_smi.is_valid()); 6427 ASSERT(ebp_as_smi.is_valid());
6428 __ mov(ebp_as_smi.reg(), Operand(ebp)); 6428 __ mov(ebp_as_smi.reg(), Operand(ebp));
6429 frame_->Push(&ebp_as_smi); 6429 frame_->Push(&ebp_as_smi);
6430 } 6430 }
6431 6431
6432 6432
6433 void CodeGenerator::GenerateRandomPositiveSmi(ZoneList<Expression*>* args) { 6433 void CodeGenerator::GenerateRandomHeapNumber(
6434 ZoneList<Expression*>* args) {
6434 ASSERT(args->length() == 0); 6435 ASSERT(args->length() == 0);
6435 frame_->SpillAll(); 6436 frame_->SpillAll();
6436 6437
6437 static const int num_arguments = 0; 6438 Label slow_allocate_heapnumber;
6438 __ PrepareCallCFunction(num_arguments, eax); 6439 Label heapnumber_allocated;
6439 6440
6440 // Call V8::RandomPositiveSmi(). 6441 __ AllocateHeapNumber(eax, ebx, ecx, &slow_allocate_heapnumber);
6441 __ CallCFunction(ExternalReference::random_positive_smi_function(), 6442 __ jmp(&heapnumber_allocated);
6442 num_arguments); 6443
6444 __ bind(&slow_allocate_heapnumber);
6445 // To allocate a heap number, and ensure that it is not a smi, we
6446 // call the runtime function FUnaryMinus on 0, returning the double
6447 // -0.0. A new, distinct heap number is returned each time.
6448 __ push(Immediate(Smi::FromInt(0)));
6449 __ CallRuntime(Runtime::kNumberUnaryMinus, 1);
6450
6451 __ bind(&heapnumber_allocated);
6452
6453 __ PrepareCallCFunction(1, ebx);
6454 __ mov(Operand(esp, 0), eax);
6455 __ CallCFunction(ExternalReference::fill_heap_number_with_random_function(),
6456 1);
6443 6457
6444 Result result = allocator_->Allocate(eax); 6458 Result result = allocator_->Allocate(eax);
6445 frame_->Push(&result); 6459 frame_->Push(&result);
6446 } 6460 }
6447 6461
6448 6462
6449 void CodeGenerator::GenerateStringAdd(ZoneList<Expression*>* args) { 6463 void CodeGenerator::GenerateStringAdd(ZoneList<Expression*>* args) {
6450 ASSERT_EQ(2, args->length()); 6464 ASSERT_EQ(2, args->length());
6451 6465
6452 Load(args->at(0)); 6466 Load(args->at(0));
(...skipping 6142 matching lines...) Expand 10 before | Expand all | Expand 10 after
12595 12609
12596 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) 12610 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
12597 // tagged as a small integer. 12611 // tagged as a small integer.
12598 __ bind(&runtime); 12612 __ bind(&runtime);
12599 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); 12613 __ TailCallRuntime(Runtime::kStringCompare, 2, 1);
12600 } 12614 }
12601 12615
12602 #undef __ 12616 #undef __
12603 12617
12604 } } // namespace v8::internal 12618 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/codegen-ia32.h ('k') | src/math.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698