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

Side by Side Diff: src/x64/codegen-x64.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/x64/codegen-x64.h ('k') | test/cctest/test-log-stack-tracer.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 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 4056 matching lines...) Expand 10 before | Expand all | Expand 10 after
4067 // RBP value is aligned, so it should be tagged as a smi (without necesarily 4067 // RBP value is aligned, so it should be tagged as a smi (without necesarily
4068 // being padded as a smi, so it should not be treated as a smi.). 4068 // being padded as a smi, so it should not be treated as a smi.).
4069 ASSERT(kSmiTag == 0 && kSmiTagSize == 1); 4069 ASSERT(kSmiTag == 0 && kSmiTagSize == 1);
4070 Result rbp_as_smi = allocator_->Allocate(); 4070 Result rbp_as_smi = allocator_->Allocate();
4071 ASSERT(rbp_as_smi.is_valid()); 4071 ASSERT(rbp_as_smi.is_valid());
4072 __ movq(rbp_as_smi.reg(), rbp); 4072 __ movq(rbp_as_smi.reg(), rbp);
4073 frame_->Push(&rbp_as_smi); 4073 frame_->Push(&rbp_as_smi);
4074 } 4074 }
4075 4075
4076 4076
4077 void CodeGenerator::GenerateRandomPositiveSmi(ZoneList<Expression*>* args) { 4077 void CodeGenerator::GenerateRandomHeapNumber(
4078 ZoneList<Expression*>* args) {
4078 ASSERT(args->length() == 0); 4079 ASSERT(args->length() == 0);
4079 frame_->SpillAll(); 4080 frame_->SpillAll();
4081
4082 Label slow_allocate_heapnumber;
4083 Label heapnumber_allocated;
4084 __ AllocateHeapNumber(rdi, rbx, &slow_allocate_heapnumber);
4085 __ jmp(&heapnumber_allocated);
4086
4087 __ bind(&slow_allocate_heapnumber);
4088 // To allocate a heap number, and ensure that it is not a smi, we
4089 // call the runtime function FUnaryMinus on 0, returning the double
4090 // -0.0. A new, distinct heap number is returned each time.
4091 __ Push(Smi::FromInt(0));
4092 __ CallRuntime(Runtime::kNumberUnaryMinus, 1);
4093 __ movq(rdi, rax);
4094
4095 __ bind(&heapnumber_allocated);
4096
4097 // Put a random number into the heap number rdi using a C++ function.
4098 // Return the heap number in rax.
4099 #ifdef _WIN64
4100 __ movq(rcx, rdi);
4101 #else
4102 // Callee-save in Microsoft 64-bit ABI, but not in AMD64 ABI.
4080 __ push(rsi); 4103 __ push(rsi);
4081 4104 #endif
4082 static const int num_arguments = 0; 4105 __ PrepareCallCFunction(1);
4083 __ PrepareCallCFunction(num_arguments); 4106 __ CallCFunction(ExternalReference::fill_heap_number_with_random_function(),
4084 4107 1);
4085 // Call V8::RandomPositiveSmi(). 4108 #ifndef _WIN64
4086 __ CallCFunction(ExternalReference::random_positive_smi_function(), 4109 // Callee-save in Microsoft 64-bit ABI, but not in AMD64 ABI.
4087 num_arguments);
4088
4089 __ pop(rsi); 4110 __ pop(rsi);
4111 #endif
4090 Result result = allocator_->Allocate(rax); 4112 Result result = allocator_->Allocate(rax);
4091 frame_->Push(&result); 4113 frame_->Push(&result);
4092 } 4114 }
4093 4115
4094 4116
4095 void CodeGenerator::GenerateRegExpExec(ZoneList<Expression*>* args) { 4117 void CodeGenerator::GenerateRegExpExec(ZoneList<Expression*>* args) {
4096 ASSERT_EQ(args->length(), 4); 4118 ASSERT_EQ(args->length(), 4);
4097 4119
4098 // Load the arguments on the stack and call the runtime system. 4120 // Load the arguments on the stack and call the runtime system.
4099 Load(args->at(0)); 4121 Load(args->at(0));
(...skipping 5944 matching lines...) Expand 10 before | Expand all | Expand 10 after
10044 // Call the function from C++. 10066 // Call the function from C++.
10045 return FUNCTION_CAST<ModuloFunction>(buffer); 10067 return FUNCTION_CAST<ModuloFunction>(buffer);
10046 } 10068 }
10047 10069
10048 #endif 10070 #endif
10049 10071
10050 10072
10051 #undef __ 10073 #undef __
10052 10074
10053 } } // namespace v8::internal 10075 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/x64/codegen-x64.h ('k') | test/cctest/test-log-stack-tracer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698