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

Side by Side Diff: test/cctest/compiler/test-structured-machine-assembler.cc

Issue 501323002: Replace our homegrown ARRAY_SIZE() with Chrome's arraysize(). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 #include "test/cctest/cctest.h" 6 #include "test/cctest/cctest.h"
7 7
8 #include "src/base/utils/random-number-generator.h" 8 #include "src/base/utils/random-number-generator.h"
9 #include "src/compiler/structured-machine-assembler.h" 9 #include "src/compiler/structured-machine-assembler.h"
10 #include "test/cctest/compiler/codegen-tester.h" 10 #include "test/cctest/compiler/codegen-tester.h"
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 for (size_t j = 0; i != inputs.end(); j++, ++i) { 272 for (size_t j = 0; i != inputs.end(); j++, ++i) {
273 int32_t result = m.Call(*i); 273 int32_t result = m.Call(*i);
274 CHECK_EQ(j < max ? hit : miss, result); 274 CHECK_EQ(j < max ? hit : miss, result);
275 } 275 }
276 } 276 }
277 277
278 278
279 TEST(RunIfBuilderDisjunction) { 279 TEST(RunIfBuilderDisjunction) {
280 size_t len = ValueHelper::int32_vector().size() - 1; 280 size_t len = ValueHelper::int32_vector().size() - 1;
281 size_t max = len > 10 ? 10 : len - 1; 281 size_t max = len > 10 ? 10 : len - 1;
282 for (size_t i = 0; i < ARRAY_SIZE(all_branch_types); i++) { 282 for (size_t i = 0; i < arraysize(all_branch_types); i++) {
283 for (size_t j = 0; j < ARRAY_SIZE(all_branch_types); j++) { 283 for (size_t j = 0; j < arraysize(all_branch_types); j++) {
284 for (size_t size = 1; size < max; size++) { 284 for (size_t size = 1; size < max; size++) {
285 RunIfBuilderDisjunction(size, all_branch_types[i], all_branch_types[j]); 285 RunIfBuilderDisjunction(size, all_branch_types[i], all_branch_types[j]);
286 } 286 }
287 RunIfBuilderDisjunction(len, all_branch_types[i], all_branch_types[j]); 287 RunIfBuilderDisjunction(len, all_branch_types[i], all_branch_types[j]);
288 } 288 }
289 } 289 }
290 } 290 }
291 291
292 292
293 static void RunIfBuilderConjunction(size_t max, IfBuilderBranchType then_type, 293 static void RunIfBuilderConjunction(size_t max, IfBuilderBranchType then_type,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 for (size_t j = 0; i != inputs.end(); j++, ++i) { 338 for (size_t j = 0; i != inputs.end(); j++, ++i) {
339 int32_t result = m.Call(*i); 339 int32_t result = m.Call(*i);
340 CHECK_EQ(j >= max ? hit : miss, result); 340 CHECK_EQ(j >= max ? hit : miss, result);
341 } 341 }
342 } 342 }
343 343
344 344
345 TEST(RunIfBuilderConjunction) { 345 TEST(RunIfBuilderConjunction) {
346 size_t len = ValueHelper::int32_vector().size() - 1; 346 size_t len = ValueHelper::int32_vector().size() - 1;
347 size_t max = len > 10 ? 10 : len - 1; 347 size_t max = len > 10 ? 10 : len - 1;
348 for (size_t i = 0; i < ARRAY_SIZE(all_branch_types); i++) { 348 for (size_t i = 0; i < arraysize(all_branch_types); i++) {
349 for (size_t j = 0; j < ARRAY_SIZE(all_branch_types); j++) { 349 for (size_t j = 0; j < arraysize(all_branch_types); j++) {
350 for (size_t size = 1; size < max; size++) { 350 for (size_t size = 1; size < max; size++) {
351 RunIfBuilderConjunction(size, all_branch_types[i], all_branch_types[j]); 351 RunIfBuilderConjunction(size, all_branch_types[i], all_branch_types[j]);
352 } 352 }
353 RunIfBuilderConjunction(len, all_branch_types[i], all_branch_types[j]); 353 RunIfBuilderConjunction(len, all_branch_types[i], all_branch_types[j]);
354 } 354 }
355 } 355 }
356 } 356 }
357 357
358 358
359 static void RunDisjunctionVariables(int disjunctions, bool explicit_then, 359 static void RunDisjunctionVariables(int disjunctions, bool explicit_then,
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 // prv_1 = res 676 // prv_1 = res
677 res.Set(m.Int32Add(prv_0.Get(), prv_1.Get())); 677 res.Set(m.Int32Add(prv_0.Get(), prv_1.Get()));
678 prv_0.Set(prv_1.Get()); 678 prv_0.Set(prv_1.Get());
679 prv_1.Set(res.Get()); 679 prv_1.Set(res.Get());
680 // cnt-- 680 // cnt--
681 cnt.Set(m.Int32Sub(cnt.Get(), one)); 681 cnt.Set(m.Int32Sub(cnt.Get(), one));
682 } 682 }
683 m.Return(res.Get()); 683 m.Return(res.Get());
684 684
685 int32_t values[] = {0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144}; 685 int32_t values[] = {0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144};
686 for (size_t i = 0; i < ARRAY_SIZE(values); i++) { 686 for (size_t i = 0; i < arraysize(values); i++) {
687 CHECK_EQ(values[i], m.Call(static_cast<int32_t>(i))); 687 CHECK_EQ(values[i], m.Call(static_cast<int32_t>(i)));
688 } 688 }
689 } 689 }
690 690
691 691
692 static int VariableIntroduction() { 692 static int VariableIntroduction() {
693 while (true) { 693 while (true) {
694 int ret = 0; 694 int ret = 0;
695 for (int i = 0; i < 10; i++) { 695 for (int i = 0; i < 10; i++) {
696 for (int j = i; j < 10; j++) { 696 for (int j = i; j < 10; j++) {
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 stack_frame_size_(Int32Constant(kFrameVariables * 4)), 887 stack_frame_size_(Int32Constant(kFrameVariables * 4)),
888 left_offset_(Int32Constant(0 * 4)), 888 left_offset_(Int32Constant(0 * 4)),
889 right_offset_(Int32Constant(1 * 4)) { 889 right_offset_(Int32Constant(1 * 4)) {
890 Build(); 890 Build();
891 } 891 }
892 892
893 int32_t DoCall(int32_t* input, int32_t input_length) { 893 int32_t DoCall(int32_t* input, int32_t input_length) {
894 int32_t stack_space[20]; 894 int32_t stack_space[20];
895 // Do call. 895 // Do call.
896 int32_t return_val = Call(input, input_length, stack_space, 896 int32_t return_val = Call(input, input_length, stack_space,
897 static_cast<int32_t>(ARRAY_SIZE(stack_space))); 897 static_cast<int32_t>(arraysize(stack_space)));
898 // Ran out of stack space. 898 // Ran out of stack space.
899 if (return_val != 0) return return_val; 899 if (return_val != 0) return return_val;
900 // Check sorted. 900 // Check sorted.
901 int32_t last = input[0]; 901 int32_t last = input[0];
902 for (int32_t i = 0; i < input_length; i++) { 902 for (int32_t i = 0; i < input_length; i++) {
903 CHECK(last <= input[i]); 903 CHECK(last <= input[i]);
904 last = input[i]; 904 last = input[i];
905 } 905 }
906 return return_val; 906 return return_val;
907 } 907 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 // Frame constants. 1011 // Frame constants.
1012 Node* const stack_frame_size_; 1012 Node* const stack_frame_size_;
1013 Node* const left_offset_; 1013 Node* const left_offset_;
1014 Node* const right_offset_; 1014 Node* const right_offset_;
1015 }; 1015 };
1016 1016
1017 1017
1018 TEST(RunSimpleQuicksort) { 1018 TEST(RunSimpleQuicksort) {
1019 QuicksortHelper m; 1019 QuicksortHelper m;
1020 int32_t inputs[] = {9, 7, 1, 8, 11}; 1020 int32_t inputs[] = {9, 7, 1, 8, 11};
1021 CHECK_EQ(0, m.DoCall(inputs, ARRAY_SIZE(inputs))); 1021 CHECK_EQ(0, m.DoCall(inputs, arraysize(inputs)));
1022 } 1022 }
1023 1023
1024 1024
1025 TEST(RunRandomQuicksort) { 1025 TEST(RunRandomQuicksort) {
1026 QuicksortHelper m; 1026 QuicksortHelper m;
1027 1027
1028 v8::base::RandomNumberGenerator rng; 1028 v8::base::RandomNumberGenerator rng;
1029 static const int kMaxLength = 40; 1029 static const int kMaxLength = 40;
1030 int32_t inputs[kMaxLength]; 1030 int32_t inputs[kMaxLength];
1031 1031
(...skipping 14 matching lines...) Expand all
1046 for (int i = 0; i < 10; i++) { 1046 for (int i = 0; i < 10; i++) {
1047 IfBuilder b(&m); 1047 IfBuilder b(&m);
1048 b.If(m.Int32Constant(0)).Then(); 1048 b.If(m.Int32Constant(0)).Then();
1049 m.NewVariable(m.Int32Constant(0)); 1049 m.NewVariable(m.Int32Constant(0));
1050 } 1050 }
1051 m.Return(m.Int32Constant(0)); 1051 m.Return(m.Int32Constant(0));
1052 CHECK_EQ(0, m.Call()); 1052 CHECK_EQ(0, m.Call());
1053 } 1053 }
1054 1054
1055 #endif 1055 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698