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

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

Issue 1774010: Port inline version of Math.sqrt and Math.pow from ia32 to x64. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 7 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 | « no previous file | src/x64/assembler-x64.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 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 6599 matching lines...) Expand 10 before | Expand all | Expand 10 after
6610 Load(args->at(0)); // receiver 6610 Load(args->at(0)); // receiver
6611 for (int i = 0; i < n_args; i++) { 6611 for (int i = 0; i < n_args; i++) {
6612 Load(args->at(i + 1)); 6612 Load(args->at(i + 1));
6613 } 6613 }
6614 Load(args->at(n_args + 1)); // function 6614 Load(args->at(n_args + 1)); // function
6615 Result result = frame_->CallJSFunction(n_args); 6615 Result result = frame_->CallJSFunction(n_args);
6616 frame_->Push(&result); 6616 frame_->Push(&result);
6617 } 6617 }
6618 6618
6619 6619
6620 // Generates the Math.pow method - only handles special cases and branches to 6620 // Generates the Math.pow method. Only handles special cases and
6621 // the runtime system if not.Please note - this function assumes that 6621 // branches to the runtime system for everything else. Please note
6622 // the callsite has executed ToNumber on both arguments and that the 6622 // that this function assumes that the callsite has executed ToNumber
6623 // arguments are not the same identifier. 6623 // on both arguments.
6624 void CodeGenerator::GenerateMathPow(ZoneList<Expression*>* args) { 6624 void CodeGenerator::GenerateMathPow(ZoneList<Expression*>* args) {
6625 ASSERT(args->length() == 2); 6625 ASSERT(args->length() == 2);
6626 Load(args->at(0)); 6626 Load(args->at(0));
6627 Load(args->at(1)); 6627 Load(args->at(1));
6628 if (!CpuFeatures::IsSupported(SSE2)) { 6628 if (!CpuFeatures::IsSupported(SSE2)) {
6629 Result res = frame_->CallRuntime(Runtime::kMath_pow, 2); 6629 Result res = frame_->CallRuntime(Runtime::kMath_pow, 2);
6630 frame_->Push(&res); 6630 frame_->Push(&res);
6631 } else { 6631 } else {
6632 CpuFeatures::Scope use_sse2(SSE2); 6632 CpuFeatures::Scope use_sse2(SSE2);
6633 Label allocate_return; 6633 Label allocate_return;
6634 // Load the two operands while leaving the values on the frame. 6634 // Load the two operands while leaving the values on the frame.
6635 frame()->Dup(); 6635 frame()->Dup();
6636 Result exponent = frame()->Pop(); 6636 Result exponent = frame()->Pop();
6637 exponent.ToRegister(); 6637 exponent.ToRegister();
6638 frame()->Spill(exponent.reg()); 6638 frame()->Spill(exponent.reg());
6639 frame()->PushElementAt(1); 6639 frame()->PushElementAt(1);
6640 Result base = frame()->Pop(); 6640 Result base = frame()->Pop();
6641 base.ToRegister(); 6641 base.ToRegister();
6642 frame()->Spill(base.reg()); 6642 frame()->Spill(base.reg());
6643 6643
6644 Result answer = allocator()->Allocate(); 6644 Result answer = allocator()->Allocate();
6645 ASSERT(answer.is_valid()); 6645 ASSERT(answer.is_valid());
6646 // We can safely assume that the base and exponent is not in the same
6647 // register since we only call this from one callsite (math.js).
6648 ASSERT(!exponent.reg().is(base.reg())); 6646 ASSERT(!exponent.reg().is(base.reg()));
6649 JumpTarget call_runtime; 6647 JumpTarget call_runtime;
6650 6648
6651 // Save 1 in xmm3 - we need this several times later on. 6649 // Save 1 in xmm3 - we need this several times later on.
6652 __ mov(answer.reg(), Immediate(1)); 6650 __ mov(answer.reg(), Immediate(1));
6653 __ cvtsi2sd(xmm3, Operand(answer.reg())); 6651 __ cvtsi2sd(xmm3, Operand(answer.reg()));
6654 6652
6655 Label exponent_nonsmi; 6653 Label exponent_nonsmi;
6656 Label base_nonsmi; 6654 Label base_nonsmi;
6657 // If the exponent is a heap number go to that specific case. 6655 // If the exponent is a heap number go to that specific case.
(...skipping 28 matching lines...) Expand all
6686 __ cmp(exponent.reg(), 0); 6684 __ cmp(exponent.reg(), 0);
6687 __ j(greater_equal, &no_neg); 6685 __ j(greater_equal, &no_neg);
6688 __ neg(exponent.reg()); 6686 __ neg(exponent.reg());
6689 __ bind(&no_neg); 6687 __ bind(&no_neg);
6690 6688
6691 // Load xmm1 with 1. 6689 // Load xmm1 with 1.
6692 __ movsd(xmm1, xmm3); 6690 __ movsd(xmm1, xmm3);
6693 Label while_true; 6691 Label while_true;
6694 Label no_multiply; 6692 Label no_multiply;
6695 6693
6696 // Label allocate_and_return;
6697 __ bind(&while_true); 6694 __ bind(&while_true);
6698 __ shr(exponent.reg(), 1); 6695 __ shr(exponent.reg(), 1);
6699 __ j(not_carry, &no_multiply); 6696 __ j(not_carry, &no_multiply);
6700 __ mulsd(xmm1, xmm0); 6697 __ mulsd(xmm1, xmm0);
6701 __ bind(&no_multiply); 6698 __ bind(&no_multiply);
6702 __ test(exponent.reg(), Operand(exponent.reg())); 6699 __ test(exponent.reg(), Operand(exponent.reg()));
6703 __ mulsd(xmm0, xmm0); 6700 __ mulsd(xmm0, xmm0);
6704 __ j(not_zero, &while_true); 6701 __ j(not_zero, &while_true);
6705 6702
6706 // x has the original value of y - if y is negative return 1/result. 6703 // x has the original value of y - if y is negative return 1/result.
(...skipping 6214 matching lines...) Expand 10 before | Expand all | Expand 10 after
12921 12918
12922 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) 12919 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
12923 // tagged as a small integer. 12920 // tagged as a small integer.
12924 __ bind(&runtime); 12921 __ bind(&runtime);
12925 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); 12922 __ TailCallRuntime(Runtime::kStringCompare, 2, 1);
12926 } 12923 }
12927 12924
12928 #undef __ 12925 #undef __
12929 12926
12930 } } // namespace v8::internal 12927 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/x64/assembler-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698