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

Side by Side Diff: src/global-handles.h

Issue 21133006: introduce eternal handles (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: added new space iterability Created 7 years, 4 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 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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 List<ObjectGroupConnection> object_group_connections_; 324 List<ObjectGroupConnection> object_group_connections_;
325 List<ObjectGroupRetainerInfo> retainer_infos_; 325 List<ObjectGroupRetainerInfo> retainer_infos_;
326 List<ObjectGroupConnection> implicit_ref_connections_; 326 List<ObjectGroupConnection> implicit_ref_connections_;
327 327
328 friend class Isolate; 328 friend class Isolate;
329 329
330 DISALLOW_COPY_AND_ASSIGN(GlobalHandles); 330 DISALLOW_COPY_AND_ASSIGN(GlobalHandles);
331 }; 331 };
332 332
333 333
334 class EternalHandles {
335 public:
336 static const int kInvalidIndex = -1;
Michael Starzinger 2013/08/01 13:26:11 Instead of exposing the kInvalidIndex constant, ca
337 enum IndexedHandle {
Michael Starzinger 2013/08/01 13:26:11 There is a slight name collision going on here I t
338 I18N_TEMPLATE_ONE,
339 I18N_TEMPLATE_TWO,
340
341 LAST_INDEX = I18N_TEMPLATE_TWO
Michael Starzinger 2013/08/01 13:26:11 nit: Let's call this NUMBER_OF_SINGLETON_HANDLES i
342 };
343
344 EternalHandles();
345 ~EternalHandles();
346
347 int NumberOfHandles() { return size_; }
348
349 int Create(Isolate* isolate, Object* object);
350
351 inline Object** Get(int index) {
Michael Starzinger 2013/08/01 13:26:11 The publicly visible Get() method should return Ha
352 ASSERT(index >= 0 && index < size_);
353 return &blocks_[index >> kShift][index & kMask];
354 }
355
356 inline int GetIndex(IndexedHandle i) {
357 return indexed_handles_[i];
358 }
359
360 int CreateIndexed(Isolate* isolate, Object* object, IndexedHandle i) {
361 ASSERT(GetIndex(i) == kInvalidIndex);
362 indexed_handles_[i] = Create(isolate, object);
363 return indexed_handles_[i];
364 }
365
366 void IterateAllRoots(ObjectVisitor* visitor);
367 void IterateNewSpaceRoots(ObjectVisitor* visitor);
368 void PostGarbageCollectionProcessing(Heap* heap);
369
370 private:
371 static const int kShift = 8;
372 static const int kSize = 1 << kShift;
373 static const int kMask = 0xff;
374 int size_;
Michael Starzinger 2013/08/01 13:26:11 nit: Let's add an empty newline after the constant
375 List<Object**> blocks_;
376 List<int> new_space_indices_;
377 int indexed_handles_[LAST_INDEX+1];
378
379 DISALLOW_COPY_AND_ASSIGN(EternalHandles);
380 };
381
382
334 } } // namespace v8::internal 383 } } // namespace v8::internal
335 384
336 #endif // V8_GLOBAL_HANDLES_H_ 385 #endif // V8_GLOBAL_HANDLES_H_
OLDNEW
« no previous file with comments | « src/extensions/i18n/i18n-utils.cc ('k') | src/global-handles.cc » ('j') | src/global-handles.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698