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

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

Issue 9167011: Support inlining and crankshaft optimization of Math.random. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 11 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
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 2998 matching lines...) Expand 10 before | Expand all | Expand 10 after
3009 MathPowStub stub(MathPowStub::INTEGER); 3009 MathPowStub stub(MathPowStub::INTEGER);
3010 __ CallStub(&stub); 3010 __ CallStub(&stub);
3011 } else { 3011 } else {
3012 ASSERT(exponent_type.IsDouble()); 3012 ASSERT(exponent_type.IsDouble());
3013 MathPowStub stub(MathPowStub::DOUBLE); 3013 MathPowStub stub(MathPowStub::DOUBLE);
3014 __ CallStub(&stub); 3014 __ CallStub(&stub);
3015 } 3015 }
3016 } 3016 }
3017 3017
3018 3018
3019 void LCodeGen::DoRandom(LRandom* instr) {
3020 // Having marked this instruction as a call we can use any
3021 // registers.
3022 ASSERT(ToDoubleRegister(instr->result()).is(xmm1));
3023 ASSERT(ToRegister(instr->InputAt(0)).is(eax));
3024
3025 __ PrepareCallCFunction(1, ebx);
3026 __ mov(eax, FieldOperand(eax, GlobalObject::kGlobalContextOffset));
3027 __ mov(Operand(esp, 0), eax);
3028 __ CallCFunction(ExternalReference::random_uint32_function(isolate()), 1);
3029
3030 // Convert 32 random bits in eax to 0.(32 random bits) in a double
3031 // by computing:
3032 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)).
3033 __ mov(ebx, Immediate(0x49800000)); // 1.0 x 2^20 as single.
3034 __ movd(xmm2, ebx);
3035 __ movd(xmm1, eax);
3036 __ cvtss2sd(xmm2, xmm2);
3037 __ xorps(xmm1, xmm2);
3038 __ subsd(xmm1, xmm2);
3039 }
3040
3041
3019 void LCodeGen::DoMathLog(LUnaryMathOperation* instr) { 3042 void LCodeGen::DoMathLog(LUnaryMathOperation* instr) {
3020 ASSERT(instr->value()->Equals(instr->result())); 3043 ASSERT(instr->value()->Equals(instr->result()));
3021 XMMRegister input_reg = ToDoubleRegister(instr->value()); 3044 XMMRegister input_reg = ToDoubleRegister(instr->value());
3022 Label positive, done, zero; 3045 Label positive, done, zero;
3023 __ xorps(xmm0, xmm0); 3046 __ xorps(xmm0, xmm0);
3024 __ ucomisd(input_reg, xmm0); 3047 __ ucomisd(input_reg, xmm0);
3025 __ j(above, &positive, Label::kNear); 3048 __ j(above, &positive, Label::kNear);
3026 __ j(equal, &zero, Label::kNear); 3049 __ j(equal, &zero, Label::kNear);
3027 ExternalReference nan = 3050 ExternalReference nan =
3028 ExternalReference::address_of_canonical_non_hole_nan(); 3051 ExternalReference::address_of_canonical_non_hole_nan();
(...skipping 1592 matching lines...) Expand 10 before | Expand all | Expand 10 after
4621 this, pointers, Safepoint::kLazyDeopt); 4644 this, pointers, Safepoint::kLazyDeopt);
4622 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); 4645 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator);
4623 } 4646 }
4624 4647
4625 4648
4626 #undef __ 4649 #undef __
4627 4650
4628 } } // namespace v8::internal 4651 } } // namespace v8::internal
4629 4652
4630 #endif // V8_TARGET_ARCH_IA32 4653 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698