| OLD | NEW |
| 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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 I18N_TEMPLATE_TWO, | 339 I18N_TEMPLATE_TWO, |
| 340 | 340 |
| 341 NUMBER_OF_SINGLETON_HANDLES | 341 NUMBER_OF_SINGLETON_HANDLES |
| 342 }; | 342 }; |
| 343 | 343 |
| 344 EternalHandles(); | 344 EternalHandles(); |
| 345 ~EternalHandles(); | 345 ~EternalHandles(); |
| 346 | 346 |
| 347 int NumberOfHandles() { return size_; } | 347 int NumberOfHandles() { return size_; } |
| 348 | 348 |
| 349 // Create an EternalHandle, returning the index. | 349 // Create an EternalHandle, overwriting the index. |
| 350 int Create(Isolate* isolate, Object* object); | 350 void Create(Isolate* isolate, Object* object, int* index); |
| 351 | 351 |
| 352 // Grab the handle for an existing EternalHandle. | 352 // Grab the handle for an existing EternalHandle. |
| 353 inline Handle<Object> Get(int index) { | 353 inline Handle<Object> Get(int index) { |
| 354 return Handle<Object>(GetLocation(index)); | 354 return Handle<Object>(GetLocation(index)); |
| 355 } | 355 } |
| 356 | 356 |
| 357 // Grab the handle for an existing SingletonHandle. | 357 // Grab the handle for an existing SingletonHandle. |
| 358 inline Handle<Object> GetSingleton(SingletonHandle singleton) { | 358 inline Handle<Object> GetSingleton(SingletonHandle singleton) { |
| 359 ASSERT(Exists(singleton)); | 359 ASSERT(Exists(singleton)); |
| 360 return Get(singleton_handles_[singleton]); | 360 return Get(singleton_handles_[singleton]); |
| 361 } | 361 } |
| 362 | 362 |
| 363 // Checks whether a SingletonHandle has been assigned. | 363 // Checks whether a SingletonHandle has been assigned. |
| 364 inline bool Exists(SingletonHandle singleton) { | 364 inline bool Exists(SingletonHandle singleton) { |
| 365 return singleton_handles_[singleton] != kInvalidIndex; | 365 return singleton_handles_[singleton] != kInvalidIndex; |
| 366 } | 366 } |
| 367 | 367 |
| 368 // Assign a SingletonHandle to an empty slot and returns the handle. | 368 // Assign a SingletonHandle to an empty slot and returns the handle. |
| 369 Handle<Object> CreateSingleton(Isolate* isolate, | 369 Handle<Object> CreateSingleton(Isolate* isolate, |
| 370 Object* object, | 370 Object* object, |
| 371 SingletonHandle singleton) { | 371 SingletonHandle singleton) { |
| 372 ASSERT(singleton_handles_[singleton] == kInvalidIndex); | 372 Create(isolate, object, &singleton_handles_[singleton]); |
| 373 singleton_handles_[singleton] = Create(isolate, object); | |
| 374 return Get(singleton_handles_[singleton]); | 373 return Get(singleton_handles_[singleton]); |
| 375 } | 374 } |
| 376 | 375 |
| 377 // Iterates over all handles. | 376 // Iterates over all handles. |
| 378 void IterateAllRoots(ObjectVisitor* visitor); | 377 void IterateAllRoots(ObjectVisitor* visitor); |
| 379 // Iterates over all handles which might be in new space. | 378 // Iterates over all handles which might be in new space. |
| 380 void IterateNewSpaceRoots(ObjectVisitor* visitor); | 379 void IterateNewSpaceRoots(ObjectVisitor* visitor); |
| 381 // Rebuilds new space list. | 380 // Rebuilds new space list. |
| 382 void PostGarbageCollectionProcessing(Heap* heap); | 381 void PostGarbageCollectionProcessing(Heap* heap); |
| 383 | 382 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 398 List<int> new_space_indices_; | 397 List<int> new_space_indices_; |
| 399 int singleton_handles_[NUMBER_OF_SINGLETON_HANDLES]; | 398 int singleton_handles_[NUMBER_OF_SINGLETON_HANDLES]; |
| 400 | 399 |
| 401 DISALLOW_COPY_AND_ASSIGN(EternalHandles); | 400 DISALLOW_COPY_AND_ASSIGN(EternalHandles); |
| 402 }; | 401 }; |
| 403 | 402 |
| 404 | 403 |
| 405 } } // namespace v8::internal | 404 } } // namespace v8::internal |
| 406 | 405 |
| 407 #endif // V8_GLOBAL_HANDLES_H_ | 406 #endif // V8_GLOBAL_HANDLES_H_ |
| OLD | NEW |