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

Side by Side Diff: runtime/vm/flow_graph_compiler_x64.cc

Issue 10542167: Inline Math.sqrt in new compilers. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/flow_graph_compiler.h" 8 #include "vm/flow_graph_compiler.h"
9 9
10 #include "lib/error.h" 10 #include "lib/error.h"
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 __ movq(RAX, Address(RSP, 2 * kWordSize)); // Receiver. 858 __ movq(RAX, Address(RSP, 2 * kWordSize)); // Receiver.
859 __ movq(RBX, Address(RSP, 1 * kWordSize)); // Value. 859 __ movq(RBX, Address(RSP, 1 * kWordSize)); // Value.
860 __ StoreIntoObject(RAX, FieldAddress(RAX, offset), RBX); 860 __ StoreIntoObject(RAX, FieldAddress(RAX, offset), RBX);
861 const Immediate raw_null = 861 const Immediate raw_null =
862 Immediate(reinterpret_cast<intptr_t>(Object::null())); 862 Immediate(reinterpret_cast<intptr_t>(Object::null()));
863 __ movq(RAX, raw_null); 863 __ movq(RAX, raw_null);
864 __ ret(); 864 __ ret();
865 } 865 }
866 866
867 867
868 // TODO(srdjan): For Math.sqrt read type feedback in Math.sqrt and decide
869 // if the argument is double, smi or something else.
870 void FlowGraphCompiler::GenerateInlinedMathSqrt(Label* done) {
871 Label smi_to_double, call_method;
872 __ movq(RAX, Address(RSP, 0));
873 __ testq(RAX, Immediate(kSmiTagMask));
874 __ j(ZERO, &smi_to_double, Assembler::kNearJump);
875 __ CompareClassId(RAX, kDouble);
876 __ j(NOT_EQUAL, &call_method, Assembler::kNearJump);
877 __ movsd(XMM1, FieldAddress(RAX, Double::value_offset()));
878 __ sqrtsd(XMM0, XMM1);
879 // TODO(regis): Should we cache double_class in FlowGraphCompiler instance?
880 const Class& double_class =
881 Class::ZoneHandle(Isolate::Current()->object_store()->double_class());
882 AssemblerMacros::TryAllocate(assembler_,
883 double_class,
884 &call_method,
885 RAX); // Result register.
886 __ movsd(FieldAddress(RAX, Double::value_offset()), XMM0);
887 __ jmp(done);
888 __ Bind(&smi_to_double);
889 __ Bind(&call_method);
890 }
891
892
868 void FlowGraphCompiler::CompileGraph() { 893 void FlowGraphCompiler::CompileGraph() {
869 InitCompiler(); 894 InitCompiler();
870 if (TryIntrinsify()) { 895 if (TryIntrinsify()) {
871 // Make it patchable: code must have a minimum code size, nop(2) increases 896 // Make it patchable: code must have a minimum code size, nop(2) increases
872 // the minimum code size appropriately. 897 // the minimum code size appropriately.
873 __ nop(2); 898 __ nop(2);
874 __ int3(); 899 __ int3();
875 __ jmp(&StubCode::FixCallersTargetLabel()); 900 __ jmp(&StubCode::FixCallersTargetLabel());
876 return; 901 return;
877 } 902 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 __ cvtsi2sd(result, temp); 1051 __ cvtsi2sd(result, temp);
1027 __ Bind(&done); 1052 __ Bind(&done);
1028 } 1053 }
1029 1054
1030 1055
1031 #undef __ 1056 #undef __
1032 1057
1033 } // namespace dart 1058 } // namespace dart
1034 1059
1035 #endif // defined TARGET_ARCH_X64 1060 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698