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

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

Issue 80513004: Revert 17963, 17962 and 17955: Random number generator in JS changes (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove Yang's changes, too Created 7 years, 1 month 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/v8.cc ('k') | src/x64/lithium-codegen-x64.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 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 3253 matching lines...) Expand 10 before | Expand all | Expand 10 after
3264 VisitForStackValue(args->at(1)); 3264 VisitForStackValue(args->at(1));
3265 VisitForStackValue(args->at(2)); 3265 VisitForStackValue(args->at(2));
3266 __ CallRuntime(Runtime::kLog, 2); 3266 __ CallRuntime(Runtime::kLog, 2);
3267 } 3267 }
3268 // Finally, we're expected to leave a value on the top of the stack. 3268 // Finally, we're expected to leave a value on the top of the stack.
3269 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); 3269 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
3270 context()->Plug(rax); 3270 context()->Plug(rax);
3271 } 3271 }
3272 3272
3273 3273
3274 void FullCodeGenerator::EmitRandomHeapNumber(CallRuntime* expr) {
3275 ASSERT(expr->arguments()->length() == 0);
3276
3277 Label slow_allocate_heapnumber;
3278 Label heapnumber_allocated;
3279
3280 __ AllocateHeapNumber(rbx, rcx, &slow_allocate_heapnumber);
3281 __ jmp(&heapnumber_allocated);
3282
3283 __ bind(&slow_allocate_heapnumber);
3284 // Allocate a heap number.
3285 __ CallRuntime(Runtime::kNumberAlloc, 0);
3286 __ movq(rbx, rax);
3287
3288 __ bind(&heapnumber_allocated);
3289
3290 // Return a random uint32 number in rax.
3291 // The fresh HeapNumber is in rbx, which is callee-save on both x64 ABIs.
3292 __ PrepareCallCFunction(1);
3293 __ movq(arg_reg_1,
3294 ContextOperand(context_register(), Context::GLOBAL_OBJECT_INDEX));
3295 __ movq(arg_reg_1,
3296 FieldOperand(arg_reg_1, GlobalObject::kNativeContextOffset));
3297 __ CallCFunction(ExternalReference::random_uint32_function(isolate()), 1);
3298
3299 // Convert 32 random bits in rax to 0.(32 random bits) in a double
3300 // by computing:
3301 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)).
3302 __ movl(rcx, Immediate(0x49800000)); // 1.0 x 2^20 as single.
3303 __ movd(xmm1, rcx);
3304 __ movd(xmm0, rax);
3305 __ cvtss2sd(xmm1, xmm1);
3306 __ xorps(xmm0, xmm1);
3307 __ subsd(xmm0, xmm1);
3308 __ movsd(FieldOperand(rbx, HeapNumber::kValueOffset), xmm0);
3309
3310 __ movq(rax, rbx);
3311 context()->Plug(rax);
3312 }
3313
3314
3274 void FullCodeGenerator::EmitSubString(CallRuntime* expr) { 3315 void FullCodeGenerator::EmitSubString(CallRuntime* expr) {
3275 // Load the arguments on the stack and call the stub. 3316 // Load the arguments on the stack and call the stub.
3276 SubStringStub stub; 3317 SubStringStub stub;
3277 ZoneList<Expression*>* args = expr->arguments(); 3318 ZoneList<Expression*>* args = expr->arguments();
3278 ASSERT(args->length() == 3); 3319 ASSERT(args->length() == 3);
3279 VisitForStackValue(args->at(0)); 3320 VisitForStackValue(args->at(0));
3280 VisitForStackValue(args->at(1)); 3321 VisitForStackValue(args->at(1));
3281 VisitForStackValue(args->at(2)); 3322 VisitForStackValue(args->at(2));
3282 __ CallStub(&stub); 3323 __ CallStub(&stub);
3283 context()->Plug(rax); 3324 context()->Plug(rax);
(...skipping 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after
4896 4937
4897 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 4938 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
4898 Assembler::target_address_at(call_target_address)); 4939 Assembler::target_address_at(call_target_address));
4899 return OSR_AFTER_STACK_CHECK; 4940 return OSR_AFTER_STACK_CHECK;
4900 } 4941 }
4901 4942
4902 4943
4903 } } // namespace v8::internal 4944 } } // namespace v8::internal
4904 4945
4905 #endif // V8_TARGET_ARCH_X64 4946 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/v8.cc ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698