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

Side by Side Diff: vm/symbols.h

Issue 11549010: Dynamically Allocate the predefined handles structure in Symbols (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years 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 | vm/symbols.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef VM_SYMBOLS_H_ 5 #ifndef VM_SYMBOLS_H_
6 #define VM_SYMBOLS_H_ 6 #define VM_SYMBOLS_H_
7 7
8 #include "vm/object.h" 8 #include "vm/object.h"
9 #include "vm/snapshot_ids.h" 9 #include "vm/snapshot_ids.h"
10 10
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 static intptr_t LookupVMSymbol(RawObject* obj); 266 static intptr_t LookupVMSymbol(RawObject* obj);
267 static RawObject* GetVMSymbol(intptr_t object_id); 267 static RawObject* GetVMSymbol(intptr_t object_id);
268 static bool IsVMSymbolId(intptr_t object_id) { 268 static bool IsVMSymbolId(intptr_t object_id) {
269 return (object_id >= kMaxPredefinedObjectIds && 269 return (object_id >= kMaxPredefinedObjectIds &&
270 object_id < (kMaxPredefinedObjectIds + kMaxId)); 270 object_id < (kMaxPredefinedObjectIds + kMaxId));
271 } 271 }
272 272
273 // List of symbols that are stored in the vm isolate for easy access. 273 // List of symbols that are stored in the vm isolate for easy access.
274 static RawString* predefined_[kMaxId]; 274 static RawString* predefined_[kMaxId];
275 275
276 // Structure for managing handles allocation for symbols that are
277 // stored in the vm isolate.
278 static VMHandles predefined_handles_;
279
280 // Statistics used to measure the efficiency of the symbol table. 276 // Statistics used to measure the efficiency of the symbol table.
281 static const intptr_t kMaxCollisionBuckets = 10; 277 static const intptr_t kMaxCollisionBuckets = 10;
282 static intptr_t num_of_grows_; 278 static intptr_t num_of_grows_;
283 static intptr_t collision_count_[kMaxCollisionBuckets]; 279 static intptr_t collision_count_[kMaxCollisionBuckets];
284 280
281 // Structure for managing handles allocation for symbols that are
282 // stored in the vm isolate. We don't want these handles to be
283 // destroyed as part of the C++ static destructors and hence this
284 // object is dynamically allocated.
285 class ReadOnlyHandles {
286 public:
287 ReadOnlyHandles() { }
288 uword AllocateHandle() {
289 return handles_.AllocateScopedHandle();
290 }
291 bool IsValidHandle(uword address) {
292 return handles_.IsValidScopedHandle(address);
293 }
294
295 private:
296 VMHandles handles_;
297
298 DISALLOW_COPY_AND_ASSIGN(ReadOnlyHandles);
299 };
300 static ReadOnlyHandles* predefined_handles_;
301
285 #define DECLARE_SYMBOL_HANDLE(symbol) \ 302 #define DECLARE_SYMBOL_HANDLE(symbol) \
286 static String* symbol##_handle_; 303 static String* symbol##_handle_;
287 PREDEFINED_SYMBOL_HANDLES_LIST(DECLARE_SYMBOL_HANDLE) 304 PREDEFINED_SYMBOL_HANDLES_LIST(DECLARE_SYMBOL_HANDLE)
288 #undef DECLARE_SYMBOL_HANDLE 305 #undef DECLARE_SYMBOL_HANDLE
289 306
290 friend class String; 307 friend class String;
291 friend class SnapshotReader; 308 friend class SnapshotReader;
292 friend class SnapshotWriter; 309 friend class SnapshotWriter;
293 friend class ApiMessageReader; 310 friend class ApiMessageReader;
294 311
295 DISALLOW_COPY_AND_ASSIGN(Symbols); 312 DISALLOW_COPY_AND_ASSIGN(Symbols);
296 }; 313 };
297 314
298 } // namespace dart 315 } // namespace dart
299 316
300 #endif // VM_SYMBOLS_H_ 317 #endif // VM_SYMBOLS_H_
OLDNEW
« no previous file with comments | « no previous file | vm/symbols.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698