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

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

Issue 22715004: Version 3.20.15 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Add TypedArray API and correctness patches r16033 and r16084 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
« no previous file with comments | « src/full-codegen.cc ('k') | src/global-handles.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 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 13 matching lines...) Expand all
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_GLOBAL_HANDLES_H_ 28 #ifndef V8_GLOBAL_HANDLES_H_
29 #define V8_GLOBAL_HANDLES_H_ 29 #define V8_GLOBAL_HANDLES_H_
30 30
31 #include "../include/v8.h" 31 #include "../include/v8.h"
32 #include "../include/v8-profiler.h" 32 #include "../include/v8-profiler.h"
33 33
34 #include "handles.h"
35 #include "list.h" 34 #include "list.h"
36 #include "v8utils.h" 35 #include "v8utils.h"
37 36
38 namespace v8 { 37 namespace v8 {
39 namespace internal { 38 namespace internal {
40 39
41 class GCTracer; 40 class GCTracer;
42 class HeapStats; 41 class HeapStats;
43 class ObjectVisitor; 42 class ObjectVisitor;
44 43
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 List<ObjectGroupConnection> object_group_connections_; 324 List<ObjectGroupConnection> object_group_connections_;
326 List<ObjectGroupRetainerInfo> retainer_infos_; 325 List<ObjectGroupRetainerInfo> retainer_infos_;
327 List<ObjectGroupConnection> implicit_ref_connections_; 326 List<ObjectGroupConnection> implicit_ref_connections_;
328 327
329 friend class Isolate; 328 friend class Isolate;
330 329
331 DISALLOW_COPY_AND_ASSIGN(GlobalHandles); 330 DISALLOW_COPY_AND_ASSIGN(GlobalHandles);
332 }; 331 };
333 332
334 333
335 class EternalHandles {
336 public:
337 enum SingletonHandle {
338 I18N_TEMPLATE_ONE,
339 I18N_TEMPLATE_TWO,
340
341 NUMBER_OF_SINGLETON_HANDLES
342 };
343
344 EternalHandles();
345 ~EternalHandles();
346
347 int NumberOfHandles() { return size_; }
348
349 // Create an EternalHandle, returning the index.
350 int Create(Isolate* isolate, Object* object);
351
352 // Grab the handle for an existing EternalHandle.
353 inline Handle<Object> Get(int index) {
354 return Handle<Object>(GetLocation(index));
355 }
356
357 // Grab the handle for an existing SingletonHandle.
358 inline Handle<Object> GetSingleton(SingletonHandle singleton) {
359 ASSERT(Exists(singleton));
360 return Get(singleton_handles_[singleton]);
361 }
362
363 // Checks whether a SingletonHandle has been assigned.
364 inline bool Exists(SingletonHandle singleton) {
365 return singleton_handles_[singleton] != kInvalidIndex;
366 }
367
368 // Assign a SingletonHandle to an empty slot and returns the handle.
369 Handle<Object> CreateSingleton(Isolate* isolate,
370 Object* object,
371 SingletonHandle singleton) {
372 ASSERT(singleton_handles_[singleton] == kInvalidIndex);
373 singleton_handles_[singleton] = Create(isolate, object);
374 return Get(singleton_handles_[singleton]);
375 }
376
377 // Iterates over all handles.
378 void IterateAllRoots(ObjectVisitor* visitor);
379 // Iterates over all handles which might be in new space.
380 void IterateNewSpaceRoots(ObjectVisitor* visitor);
381 // Rebuilds new space list.
382 void PostGarbageCollectionProcessing(Heap* heap);
383
384 private:
385 static const int kInvalidIndex = -1;
386 static const int kShift = 8;
387 static const int kSize = 1 << kShift;
388 static const int kMask = 0xff;
389
390 // Gets the slot for an index
391 inline Object** GetLocation(int index) {
392 ASSERT(index >= 0 && index < size_);
393 return &blocks_[index >> kShift][index & kMask];
394 }
395
396 int size_;
397 List<Object**> blocks_;
398 List<int> new_space_indices_;
399 int singleton_handles_[NUMBER_OF_SINGLETON_HANDLES];
400
401 DISALLOW_COPY_AND_ASSIGN(EternalHandles);
402 };
403
404
405 } } // namespace v8::internal 334 } } // namespace v8::internal
406 335
407 #endif // V8_GLOBAL_HANDLES_H_ 336 #endif // V8_GLOBAL_HANDLES_H_
OLDNEW
« no previous file with comments | « src/full-codegen.cc ('k') | src/global-handles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698