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

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

Issue 509006: Remove complicated Math.sin and Math.cos optimizations that do not buy... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 12 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') | src/x64/codegen-x64-inl.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 3961 matching lines...) Expand 10 before | Expand all | Expand 10 after
3972 if (kFrameAlignment > 0) { 3972 if (kFrameAlignment > 0) {
3973 __ movq(rsp, rbx); 3973 __ movq(rsp, rbx);
3974 } 3974 }
3975 3975
3976 __ pop(rsi); 3976 __ pop(rsi);
3977 Result result = allocator_->Allocate(rax); 3977 Result result = allocator_->Allocate(rax);
3978 frame_->Push(&result); 3978 frame_->Push(&result);
3979 } 3979 }
3980 3980
3981 3981
3982 void CodeGenerator::GenerateFastMathOp(MathOp op, ZoneList<Expression*>* args) {
3983 JumpTarget done;
3984 JumpTarget call_runtime;
3985 ASSERT(args->length() == 1);
3986
3987 // Load number and duplicate it.
3988 Load(args->at(0));
3989 frame_->Dup();
3990
3991 // Get the number into an unaliased register and load it onto the
3992 // floating point stack still leaving one copy on the frame.
3993 Result number = frame_->Pop();
3994 number.ToRegister();
3995 frame_->Spill(number.reg());
3996 FloatingPointHelper::LoadFloatOperand(masm_, number.reg());
3997 number.Unuse();
3998
3999 // Perform the operation on the number.
4000 switch (op) {
4001 case SIN:
4002 __ fsin();
4003 break;
4004 case COS:
4005 __ fcos();
4006 break;
4007 }
4008
4009 // Go slow case if argument to operation is out of range.
4010 Result eax_reg = allocator()->Allocate(rax);
4011 ASSERT(eax_reg.is_valid());
4012 __ fnstsw_ax();
4013 __ testl(rax, Immediate(0x0400)); // Bit 10 is condition flag C2.
4014 eax_reg.Unuse();
4015 call_runtime.Branch(not_zero);
4016
4017 // Allocate heap number for result if possible.
4018 Result scratch = allocator()->Allocate();
4019 Result heap_number = allocator()->Allocate();
4020 __ AllocateHeapNumber(heap_number.reg(),
4021 scratch.reg(),
4022 call_runtime.entry_label());
4023 scratch.Unuse();
4024
4025 // Store the result in the allocated heap number.
4026 __ fstp_d(FieldOperand(heap_number.reg(), HeapNumber::kValueOffset));
4027 // Replace the extra copy of the argument with the result.
4028 frame_->SetElementAt(0, &heap_number);
4029 done.Jump();
4030
4031 call_runtime.Bind();
4032 // Free ST(0) which was not popped before calling into the runtime.
4033 __ ffree(0);
4034 Result answer;
4035 switch (op) {
4036 case SIN:
4037 answer = frame_->CallRuntime(Runtime::kMath_sin, 1);
4038 break;
4039 case COS:
4040 answer = frame_->CallRuntime(Runtime::kMath_cos, 1);
4041 break;
4042 }
4043 frame_->Push(&answer);
4044 done.Bind();
4045 }
4046
4047
4048 void CodeGenerator::GenerateStringAdd(ZoneList<Expression*>* args) { 3982 void CodeGenerator::GenerateStringAdd(ZoneList<Expression*>* args) {
4049 ASSERT_EQ(2, args->length()); 3983 ASSERT_EQ(2, args->length());
4050 3984
4051 Load(args->at(0)); 3985 Load(args->at(0));
4052 Load(args->at(1)); 3986 Load(args->at(1));
4053 3987
4054 StringAddStub stub(NO_STRING_ADD_FLAGS); 3988 StringAddStub stub(NO_STRING_ADD_FLAGS);
4055 Result answer = frame_->CallStub(&stub, 2); 3989 Result answer = frame_->CallStub(&stub, 2);
4056 frame_->Push(&answer); 3990 frame_->Push(&answer);
4057 } 3991 }
(...skipping 4149 matching lines...) Expand 10 before | Expand all | Expand 10 after
8207 masm.GetCode(&desc); 8141 masm.GetCode(&desc);
8208 // Call the function from C++. 8142 // Call the function from C++.
8209 return FUNCTION_CAST<ModuloFunction>(buffer); 8143 return FUNCTION_CAST<ModuloFunction>(buffer);
8210 } 8144 }
8211 8145
8212 #endif 8146 #endif
8213 8147
8214 #undef __ 8148 #undef __
8215 8149
8216 } } // namespace v8::internal 8150 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/x64/codegen-x64.h ('k') | src/x64/codegen-x64-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698