OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
402 // so that the currently executing thread always has its own copy of this | 402 // so that the currently executing thread always has its own copy of this |
403 // data. | 403 // data. |
404 class HandleScopeImplementer { | 404 class HandleScopeImplementer { |
405 public: | 405 public: |
406 explicit HandleScopeImplementer(Isolate* isolate) | 406 explicit HandleScopeImplementer(Isolate* isolate) |
407 : isolate_(isolate), | 407 : isolate_(isolate), |
408 blocks_(0), | 408 blocks_(0), |
409 entered_contexts_(0), | 409 entered_contexts_(0), |
410 saved_contexts_(0), | 410 saved_contexts_(0), |
411 spare_(NULL), | 411 spare_(NULL), |
412 call_depth_(0) { } | 412 call_depth_(0), |
413 last_non_persistent_block_(NULL), | |
414 last_non_persistent_handle_(NULL), | |
415 persistent_extensions_head_(NULL) { } | |
413 | 416 |
414 ~HandleScopeImplementer() { | 417 ~HandleScopeImplementer() { |
415 DeleteArray(spare_); | 418 DeleteArray(spare_); |
416 } | 419 } |
417 | 420 |
418 // Threading support for handle data. | 421 // Threading support for handle data. |
419 static int ArchiveSpacePerThread(); | 422 static int ArchiveSpacePerThread(); |
420 char* RestoreThread(char* from); | 423 char* RestoreThread(char* from); |
421 char* ArchiveThread(char* to); | 424 char* ArchiveThread(char* to); |
422 void FreeThreadResources(); | 425 void FreeThreadResources(); |
423 | 426 |
424 // Garbage collection support. | 427 // Garbage collection support. |
425 void Iterate(v8::internal::ObjectVisitor* v); | 428 void Iterate(v8::internal::ObjectVisitor* v); |
426 static char* Iterate(v8::internal::ObjectVisitor* v, char* data); | 429 static char* Iterate(v8::internal::ObjectVisitor* v, char* data); |
427 | 430 |
431 struct PersistentExtensions { | |
danno
2012/06/24 11:07:03
Perhaps DeferredReleaseHandleScope?
| |
432 List<Object**> blocks; | |
433 Object** last_block_end; | |
434 PersistentExtensions* previous; | |
435 PersistentExtensions* next; | |
436 }; | |
428 | 437 |
429 inline internal::Object** GetSpareOrNewBlock(); | 438 inline internal::Object** GetSpareOrNewBlock(); |
430 inline void DeleteExtensions(internal::Object** prev_limit); | 439 inline void DeleteExtensions(internal::Object** prev_limit); |
431 | 440 |
441 // HideExtensions must be called _before_ the next field in | |
442 // HandleScopeData is reverted. | |
443 PersistentExtensions* PersistExtensions(internal::Object** prev_limit); | |
danno
2012/06/24 11:07:03
BeginDeferredHandleScope?
| |
444 void ReleaseExtensions(PersistentExtensions* extension); | |
danno
2012/06/24 11:07:03
Should be a private method only called by the Defe
| |
445 | |
432 inline void IncrementCallDepth() {call_depth_++;} | 446 inline void IncrementCallDepth() {call_depth_++;} |
433 inline void DecrementCallDepth() {call_depth_--;} | 447 inline void DecrementCallDepth() {call_depth_--;} |
434 inline bool CallDepthIsZero() { return call_depth_ == 0; } | 448 inline bool CallDepthIsZero() { return call_depth_ == 0; } |
435 | 449 |
436 inline void EnterContext(Handle<Object> context); | 450 inline void EnterContext(Handle<Object> context); |
437 inline bool LeaveLastContext(); | 451 inline bool LeaveLastContext(); |
438 | 452 |
439 // Returns the last entered context or an empty handle if no | 453 // Returns the last entered context or an empty handle if no |
440 // contexts have been entered. | 454 // contexts have been entered. |
441 inline Handle<Object> LastEnteredContext(); | 455 inline Handle<Object> LastEnteredContext(); |
442 | 456 |
443 inline void SaveContext(Context* context); | 457 inline void SaveContext(Context* context); |
444 inline Context* RestoreContext(); | 458 inline Context* RestoreContext(); |
445 inline bool HasSavedContexts(); | 459 inline bool HasSavedContexts(); |
446 | 460 |
447 inline List<internal::Object**>* blocks() { return &blocks_; } | 461 inline List<internal::Object**>* blocks() { return &blocks_; } |
448 | 462 |
463 void begin_persistence() { | |
danno
2012/06/24 11:07:03
I think you can merge this with PersistExtensions
| |
464 // We only track one such special block. | |
465 ASSERT(!last_non_persistent_block_); | |
466 last_non_persistent_block_ = blocks_.last(); | |
467 last_non_persistent_handle_ = isolate_->handle_scope_data()->next; | |
468 } | |
469 | |
470 void end_persistence() { | |
danno
2012/06/24 11:07:03
This should by a private method called "DeferHandl
| |
471 ASSERT(last_non_persistent_block_); | |
472 last_non_persistent_block_ = NULL; | |
473 last_non_persistent_handle_ = NULL; | |
474 } | |
475 | |
449 private: | 476 private: |
450 void ResetAfterArchive() { | 477 void ResetAfterArchive() { |
451 blocks_.Initialize(0); | 478 blocks_.Initialize(0); |
452 entered_contexts_.Initialize(0); | 479 entered_contexts_.Initialize(0); |
453 saved_contexts_.Initialize(0); | 480 saved_contexts_.Initialize(0); |
454 spare_ = NULL; | 481 spare_ = NULL; |
455 call_depth_ = 0; | 482 call_depth_ = 0; |
456 } | 483 } |
457 | 484 |
458 void Free() { | 485 void Free() { |
(...skipping 13 matching lines...) Expand all Loading... | |
472 Isolate* isolate_; | 499 Isolate* isolate_; |
473 List<internal::Object**> blocks_; | 500 List<internal::Object**> blocks_; |
474 // Used as a stack to keep track of entered contexts. | 501 // Used as a stack to keep track of entered contexts. |
475 List<Handle<Object> > entered_contexts_; | 502 List<Handle<Object> > entered_contexts_; |
476 // Used as a stack to keep track of saved contexts. | 503 // Used as a stack to keep track of saved contexts. |
477 List<Context*> saved_contexts_; | 504 List<Context*> saved_contexts_; |
478 Object** spare_; | 505 Object** spare_; |
479 int call_depth_; | 506 int call_depth_; |
480 // This is only used for threading support. | 507 // This is only used for threading support. |
481 v8::ImplementationUtilities::HandleScopeData handle_scope_data_; | 508 v8::ImplementationUtilities::HandleScopeData handle_scope_data_; |
509 Object** last_non_persistent_block_; | |
510 Object** last_non_persistent_handle_; | |
511 PersistentExtensions* persistent_extensions_head_; | |
482 | 512 |
483 void IterateThis(ObjectVisitor* v); | 513 void IterateThis(ObjectVisitor* v); |
484 char* RestoreThreadHelper(char* from); | 514 char* RestoreThreadHelper(char* from); |
485 char* ArchiveThreadHelper(char* to); | 515 char* ArchiveThreadHelper(char* to); |
486 | 516 |
487 DISALLOW_COPY_AND_ASSIGN(HandleScopeImplementer); | 517 DISALLOW_COPY_AND_ASSIGN(HandleScopeImplementer); |
488 }; | 518 }; |
489 | 519 |
490 | 520 |
491 const int kHandleBlockSize = v8::internal::KB - 2; // fit in one page | 521 const int kHandleBlockSize = v8::internal::KB - 2; // fit in one page |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
566 stress_type_ = stress_type; | 596 stress_type_ = stress_type; |
567 } | 597 } |
568 | 598 |
569 private: | 599 private: |
570 static v8::Testing::StressType stress_type_; | 600 static v8::Testing::StressType stress_type_; |
571 }; | 601 }; |
572 | 602 |
573 } } // namespace v8::internal | 603 } } // namespace v8::internal |
574 | 604 |
575 #endif // V8_API_H_ | 605 #endif // V8_API_H_ |
OLD | NEW |