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

Side by Side Diff: src/hydrogen.cc

Issue 7111047: Make valgrind happy with SparseSet. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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
« no previous file with comments | « no previous file | 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 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 } 1279 }
1280 1280
1281 1281
1282 // Simple sparse set with O(1) add, contains, and clear. 1282 // Simple sparse set with O(1) add, contains, and clear.
1283 class SparseSet { 1283 class SparseSet {
1284 public: 1284 public:
1285 SparseSet(Zone* zone, int capacity) 1285 SparseSet(Zone* zone, int capacity)
1286 : capacity_(capacity), 1286 : capacity_(capacity),
1287 length_(0), 1287 length_(0),
1288 dense_(zone->NewArray<int>(capacity)), 1288 dense_(zone->NewArray<int>(capacity)),
1289 sparse_(zone->NewArray<int>(capacity)) {} 1289 sparse_(zone->NewArray<int>(capacity)) {
1290 #ifndef NVALGRIND
1291 // Initialize the sparse array to make valgrind happy.
1292 memset(sparse_, 0, sizeof(sparse_[0]) * capacity);
1293 #endif
1294 }
1290 1295
1291 bool Contains(int n) const { 1296 bool Contains(int n) const {
1292 ASSERT(0 <= n && n < capacity_); 1297 ASSERT(0 <= n && n < capacity_);
1293 int d = sparse_[n]; 1298 int d = sparse_[n];
1294 return 0 <= d && d < length_ && dense_[d] == n; 1299 return 0 <= d && d < length_ && dense_[d] == n;
1295 } 1300 }
1296 1301
1297 bool Add(int n) { 1302 bool Add(int n) {
1298 if (Contains(n)) return false; 1303 if (Contains(n)) return false;
1299 dense_[length_] = n; 1304 dense_[length_] = n;
(...skipping 5102 matching lines...) Expand 10 before | Expand all | Expand 10 after
6402 } 6407 }
6403 } 6408 }
6404 6409
6405 #ifdef DEBUG 6410 #ifdef DEBUG
6406 if (graph_ != NULL) graph_->Verify(); 6411 if (graph_ != NULL) graph_->Verify();
6407 if (allocator_ != NULL) allocator_->Verify(); 6412 if (allocator_ != NULL) allocator_->Verify();
6408 #endif 6413 #endif
6409 } 6414 }
6410 6415
6411 } } // namespace v8::internal 6416 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698