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

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

Issue 385563004: Uses a conditional move for usage counter increment instead of a branch (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/os.h" 9 #include "vm/os.h"
10 #include "vm/unit_test.h" 10 #include "vm/unit_test.h"
(...skipping 2951 matching lines...) Expand 10 before | Expand all | Expand 10 after
2962 2962
2963 2963
2964 ASSEMBLER_TEST_RUN(ConditionalMovesEqual, test) { 2964 ASSEMBLER_TEST_RUN(ConditionalMovesEqual, test) {
2965 typedef int (*ConditionalMovesEqualCode)(int i); 2965 typedef int (*ConditionalMovesEqualCode)(int i);
2966 int res = reinterpret_cast<ConditionalMovesEqualCode>(test->entry())(785); 2966 int res = reinterpret_cast<ConditionalMovesEqualCode>(test->entry())(785);
2967 EXPECT_EQ(1, res); 2967 EXPECT_EQ(1, res);
2968 res = reinterpret_cast<ConditionalMovesEqualCode>(test->entry())(-12); 2968 res = reinterpret_cast<ConditionalMovesEqualCode>(test->entry())(-12);
2969 EXPECT_EQ(0, res); 2969 EXPECT_EQ(0, res);
2970 } 2970 }
2971 2971
2972
2973 // Return 1 if overflow, 0 if no overflow.
2974 ASSEMBLER_TEST_GENERATE(ConditionalMovesNoOverflow, assembler) {
2975 __ movq(RDX, CallingConventions::kArg1Reg);
2976 __ addq(RDX, CallingConventions::kArg2Reg);
2977 __ movq(RAX, Immediate(1));
2978 __ movq(RCX, Immediate(0));
2979 __ cmovnoq(RAX, RCX);
2980 __ ret();
2981 }
2982
2983
2984 ASSEMBLER_TEST_RUN(ConditionalMovesNoOverflow, test) {
2985 typedef int (*ConditionalMovesNoOverflowCode)(int64_t i, int64_t j);
2986 int res = reinterpret_cast<ConditionalMovesNoOverflowCode>(
2987 test->entry())(0x7fffffffffffffff, 2);
2988 EXPECT_EQ(1, res);
2989 res = reinterpret_cast<ConditionalMovesNoOverflowCode>(test->entry())(1, 1);
2990 EXPECT_EQ(0, res);
2991 }
2992
2972 } // namespace dart 2993 } // namespace dart
2973 2994
2974 #endif // defined TARGET_ARCH_X64 2995 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698