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

Side by Side Diff: test/cctest/test-utils.cc

Issue 680883004: Introduce FeedbackNexus for vector-based ics. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comment response. Created 6 years, 1 month 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 | « test/cctest/test-feedback-vector.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 CHECK_EQ(0, FastD2IChecked(0.345)); 69 CHECK_EQ(0, FastD2IChecked(0.345));
70 CHECK_EQ(1, FastD2IChecked(1.234)); 70 CHECK_EQ(1, FastD2IChecked(1.234));
71 CHECK_EQ(1000000, FastD2IChecked(1000000.123)); 71 CHECK_EQ(1000000, FastD2IChecked(1000000.123));
72 72
73 CHECK_EQ(INT_MAX, FastD2IChecked(1.0e100)); 73 CHECK_EQ(INT_MAX, FastD2IChecked(1.0e100));
74 CHECK_EQ(INT_MIN, FastD2IChecked(-1.0e100)); 74 CHECK_EQ(INT_MIN, FastD2IChecked(-1.0e100));
75 CHECK_EQ(INT_MIN, FastD2IChecked(v8::base::OS::nan_value())); 75 CHECK_EQ(INT_MIN, FastD2IChecked(v8::base::OS::nan_value()));
76 } 76 }
77 77
78 78
79 TEST(BitSetComputer) {
80 typedef BitSetComputer<bool, 1, kSmiValueSize, uint32_t> BoolComputer;
81 CHECK_EQ(0, BoolComputer::word_count(0));
82 CHECK_EQ(1, BoolComputer::word_count(8));
83 CHECK_EQ(2, BoolComputer::word_count(50));
84 CHECK_EQ(0, BoolComputer::index(0, 8));
85 CHECK_EQ(100, BoolComputer::index(100, 8));
86 CHECK_EQ(1, BoolComputer::index(0, 40));
87 uint32_t data = 0;
88 data = BoolComputer::encode(data, 1, true);
89 data = BoolComputer::encode(data, 4, true);
90 CHECK_EQ(true, BoolComputer::decode(data, 1));
91 CHECK_EQ(true, BoolComputer::decode(data, 4));
92 CHECK_EQ(false, BoolComputer::decode(data, 0));
93 CHECK_EQ(false, BoolComputer::decode(data, 2));
94 CHECK_EQ(false, BoolComputer::decode(data, 3));
95
96 // Lets store 2 bits per item with 3000 items and verify the values are
97 // correct.
98 typedef BitSetComputer<unsigned char, 2, 8, unsigned char> TwoBits;
99 const int words = 750;
100 CHECK_EQ(words, TwoBits::word_count(3000));
101 const int offset = 10;
102 Vector<unsigned char> buffer = Vector<unsigned char>::New(offset + words);
103 memset(buffer.start(), 0, sizeof(unsigned char) * buffer.length());
104 for (int i = 0; i < words; i++) {
105 const int index = TwoBits::index(offset, i);
106 unsigned char data = buffer[index];
107 data = TwoBits::encode(data, i, i % 4);
108 buffer[index] = data;
109 }
110
111 for (int i = 0; i < words; i++) {
112 const int index = TwoBits::index(offset, i);
113 unsigned char data = buffer[index];
114 CHECK_EQ(i % 4, TwoBits::decode(data, i));
115 }
116 }
117
118
79 TEST(SNPrintF) { 119 TEST(SNPrintF) {
80 // Make sure that strings that are truncated because of too small 120 // Make sure that strings that are truncated because of too small
81 // buffers are zero-terminated anyway. 121 // buffers are zero-terminated anyway.
82 const char* s = "the quick lazy .... oh forget it!"; 122 const char* s = "the quick lazy .... oh forget it!";
83 int length = StrLength(s); 123 int length = StrLength(s);
84 for (int i = 1; i < length * 2; i++) { 124 for (int i = 1; i < length * 2; i++) {
85 static const char kMarker = static_cast<char>(42); 125 static const char kMarker = static_cast<char>(42);
86 Vector<char> buffer = Vector<char>::New(i + 1); 126 Vector<char> buffer = Vector<char>::New(i + 1);
87 buffer[i] = kMarker; 127 buffer[i] = kMarker;
88 int n = SNPrintF(Vector<char>(buffer.start(), i), "%s", s); 128 int n = SNPrintF(Vector<char>(buffer.start(), i), "%s", s);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 vec.push_back(66); 287 vec.push_back(66);
248 for (auto& i : vec) { 288 for (auto& i : vec) {
249 ++i; 289 ++i;
250 } 290 }
251 int j = 12; 291 int j = 12;
252 for (auto i : vec) { 292 for (auto i : vec) {
253 CHECK_EQ(j, i); 293 CHECK_EQ(j, i);
254 j += 11; 294 j += 11;
255 } 295 }
256 } 296 }
OLDNEW
« no previous file with comments | « test/cctest/test-feedback-vector.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698