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

Side by Side Diff: runtime/vm/assembler_ia32_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_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/cpu.h" 9 #include "vm/cpu.h"
10 #include "vm/os.h" 10 #include "vm/os.h"
(...skipping 3001 matching lines...) Expand 10 before | Expand all | Expand 10 after
3012 3012
3013 ASSEMBLER_TEST_RUN(ConditionalMovesSign, test) { 3013 ASSEMBLER_TEST_RUN(ConditionalMovesSign, test) {
3014 typedef int (*ConditionalMovesSignCode)(int i); 3014 typedef int (*ConditionalMovesSignCode)(int i);
3015 int res = reinterpret_cast<ConditionalMovesSignCode>(test->entry())(785); 3015 int res = reinterpret_cast<ConditionalMovesSignCode>(test->entry())(785);
3016 EXPECT_EQ(1, res); 3016 EXPECT_EQ(1, res);
3017 res = reinterpret_cast<ConditionalMovesSignCode>(test->entry())(-12); 3017 res = reinterpret_cast<ConditionalMovesSignCode>(test->entry())(-12);
3018 EXPECT_EQ(-1, res); 3018 EXPECT_EQ(-1, res);
3019 } 3019 }
3020 3020
3021 3021
3022 // Return 1 if overflow, 0 if no overflow.
3023 ASSEMBLER_TEST_GENERATE(ConditionalMovesNoOverflow, assembler) {
3024 __ movl(EDX, Address(ESP, 1 * kWordSize));
3025 __ addl(EDX, Address(ESP, 2 * kWordSize));
3026 __ movl(EAX, Immediate(1));
3027 __ movl(ECX, Immediate(0));
3028 __ cmovno(EAX, ECX);
3029 __ ret();
3030 }
3031
3032
3033 ASSEMBLER_TEST_RUN(ConditionalMovesNoOverflow, test) {
3034 typedef int (*ConditionalMovesNoOverflowCode)(int i, int j);
3035 int res = reinterpret_cast<ConditionalMovesNoOverflowCode>(
3036 test->entry())(0x7fffffff, 2);
3037 EXPECT_EQ(1, res);
3038 res = reinterpret_cast<ConditionalMovesNoOverflowCode>(test->entry())(1, 1);
3039 EXPECT_EQ(0, res);
3040 }
3041
3042
3022 // Return 1 if equal, 0 if not equal. 3043 // Return 1 if equal, 0 if not equal.
3023 ASSEMBLER_TEST_GENERATE(ConditionalMovesEqual, assembler) { 3044 ASSEMBLER_TEST_GENERATE(ConditionalMovesEqual, assembler) {
3024 __ xorl(EAX, EAX); 3045 __ xorl(EAX, EAX);
3025 __ movl(ECX, Immediate(1)); 3046 __ movl(ECX, Immediate(1));
3026 __ movl(EDX, Address(ESP, 1 * kWordSize)); 3047 __ movl(EDX, Address(ESP, 1 * kWordSize));
3027 __ cmpl(EDX, Immediate(785)); 3048 __ cmpl(EDX, Immediate(785));
3028 __ cmove(EAX, ECX); 3049 __ cmove(EAX, ECX);
3029 __ ret(); 3050 __ ret();
3030 } 3051 }
3031 3052
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
3240 FieldAddress(ECX, GrowableObjectArray::data_offset()), 3261 FieldAddress(ECX, GrowableObjectArray::data_offset()),
3241 EAX); 3262 EAX);
3242 __ popl(EAX); 3263 __ popl(EAX);
3243 __ popl(CTX); 3264 __ popl(CTX);
3244 __ ret(); 3265 __ ret();
3245 } 3266 }
3246 3267
3247 } // namespace dart 3268 } // namespace dart
3248 3269
3249 #endif // defined TARGET_ARCH_IA32 3270 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698