Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_API_H_ | 5 #ifndef V8_API_H_ |
| 6 #define V8_API_H_ | 6 #define V8_API_H_ |
| 7 | 7 |
| 8 #include "include/v8-testing.h" | 8 #include "include/v8-testing.h" |
| 9 #include "src/contexts.h" | 9 #include "src/contexts.h" |
| 10 #include "src/factory.h" | 10 #include "src/factory.h" |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 427 DeferredHandles* next_; | 427 DeferredHandles* next_; |
| 428 DeferredHandles* previous_; | 428 DeferredHandles* previous_; |
| 429 Object** first_block_limit_; | 429 Object** first_block_limit_; |
| 430 Isolate* isolate_; | 430 Isolate* isolate_; |
| 431 | 431 |
| 432 friend class HandleScopeImplementer; | 432 friend class HandleScopeImplementer; |
| 433 friend class Isolate; | 433 friend class Isolate; |
| 434 }; | 434 }; |
| 435 | 435 |
| 436 | 436 |
| 437 // Microtasks invocation policy. Keep in sync with v8::Isolate::MicrotasksPolicy | |
| 438 enum MicrotasksPolicy { | |
|
jochen (gone - plz use gerrit)
2016/03/01 14:26:08
why not just use the public version?
dgozman
2016/03/03 01:22:06
Done.
| |
| 439 kExplicitMicrotasksInvocation, | |
| 440 kScopedMicrotasksInvocation, | |
| 441 kAutoMicrotasksInvocation | |
| 442 }; | |
| 443 | |
| 444 | |
| 437 // This class is here in order to be able to declare it a friend of | 445 // This class is here in order to be able to declare it a friend of |
| 438 // HandleScope. Moving these methods to be members of HandleScope would be | 446 // HandleScope. Moving these methods to be members of HandleScope would be |
| 439 // neat in some ways, but it would expose internal implementation details in | 447 // neat in some ways, but it would expose internal implementation details in |
| 440 // our public header file, which is undesirable. | 448 // our public header file, which is undesirable. |
| 441 // | 449 // |
| 442 // An isolate has a single instance of this class to hold the current thread's | 450 // An isolate has a single instance of this class to hold the current thread's |
| 443 // data. In multithreaded V8 programs this data is copied in and out of storage | 451 // data. In multithreaded V8 programs this data is copied in and out of storage |
| 444 // so that the currently executing thread always has its own copy of this | 452 // so that the currently executing thread always has its own copy of this |
| 445 // data. | 453 // data. |
| 446 class HandleScopeImplementer { | 454 class HandleScopeImplementer { |
| 447 public: | 455 public: |
| 448 explicit HandleScopeImplementer(Isolate* isolate) | 456 explicit HandleScopeImplementer(Isolate* isolate) |
| 449 : isolate_(isolate), | 457 : isolate_(isolate), |
| 450 blocks_(0), | 458 blocks_(0), |
| 451 entered_contexts_(0), | 459 entered_contexts_(0), |
| 452 saved_contexts_(0), | 460 saved_contexts_(0), |
| 453 spare_(NULL), | 461 spare_(NULL), |
| 454 call_depth_(0), | 462 call_depth_(0), |
| 463 microtasks_suppression_(0), | |
| 464 #ifdef V8_ENABLE_CHECKS | |
| 465 debug_call_depth_(0), | |
| 466 #endif | |
| 467 internal_call_depth_(0), | |
| 468 microtasks_policy_(kAutoMicrotasksInvocation), | |
| 455 last_handle_before_deferred_block_(NULL) { } | 469 last_handle_before_deferred_block_(NULL) { } |
| 456 | 470 |
| 457 ~HandleScopeImplementer() { | 471 ~HandleScopeImplementer() { |
| 458 DeleteArray(spare_); | 472 DeleteArray(spare_); |
| 459 } | 473 } |
| 460 | 474 |
| 461 // Threading support for handle data. | 475 // Threading support for handle data. |
| 462 static int ArchiveSpacePerThread(); | 476 static int ArchiveSpacePerThread(); |
| 463 char* RestoreThread(char* from); | 477 char* RestoreThread(char* from); |
| 464 char* ArchiveThread(char* to); | 478 char* ArchiveThread(char* to); |
| 465 void FreeThreadResources(); | 479 void FreeThreadResources(); |
| 466 | 480 |
| 467 // Garbage collection support. | 481 // Garbage collection support. |
| 468 void Iterate(v8::internal::ObjectVisitor* v); | 482 void Iterate(v8::internal::ObjectVisitor* v); |
| 469 static char* Iterate(v8::internal::ObjectVisitor* v, char* data); | 483 static char* Iterate(v8::internal::ObjectVisitor* v, char* data); |
| 470 | 484 |
| 471 | 485 |
| 472 inline internal::Object** GetSpareOrNewBlock(); | 486 inline internal::Object** GetSpareOrNewBlock(); |
| 473 inline void DeleteExtensions(internal::Object** prev_limit); | 487 inline void DeleteExtensions(internal::Object** prev_limit); |
| 474 | 488 |
| 475 inline void IncrementCallDepth() {call_depth_++;} | 489 inline void IncrementCallDepth() {call_depth_++;} |
|
adamk
2016/03/01 19:10:34
Given the below new types of "call depth", I think
| |
| 476 inline void DecrementCallDepth() {call_depth_--;} | 490 inline void DecrementCallDepth() {call_depth_--;} |
| 477 inline bool CallDepthIsZero() { return call_depth_ == 0; } | 491 inline int GetCallDepth() { return call_depth_; } |
| 492 | |
| 493 inline void IncrementMicrotasksSuppression() {microtasks_suppression_++;} | |
|
adamk
2016/03/01 19:10:34
This could use a comment, what is this counter for
| |
| 494 inline void DecrementMicrotasksSuppression() {microtasks_suppression_--;} | |
| 495 inline bool GetMicrotasksSuppression() { return microtasks_suppression_; } | |
| 496 | |
| 497 #ifdef V8_ENABLE_CHECKS | |
| 498 inline void IncrementDebugCallDepth() {debug_call_depth_++;} | |
|
adamk
2016/03/01 19:10:34
Please add comments, what's a "debug call depth"?
| |
| 499 inline void DecrementDebugCallDepth() {debug_call_depth_--;} | |
| 500 inline bool GetDebugCallDepth() { return debug_call_depth_; } | |
| 501 #endif | |
| 502 | |
| 503 inline void IncrementInternalCallDepth() {internal_call_depth_++;} | |
|
adamk
2016/03/01 19:10:34
Same here, what's an "internal call depth"?
| |
| 504 inline void DecrementInternalCallDepth() {internal_call_depth_--;} | |
| 505 inline bool GetInternalCallDepth() { return internal_call_depth_; } | |
| 506 | |
| 507 inline void set_microtasks_policy(MicrotasksPolicy policy); | |
| 508 inline MicrotasksPolicy microtasks_policy() const; | |
| 478 | 509 |
| 479 inline void EnterContext(Handle<Context> context); | 510 inline void EnterContext(Handle<Context> context); |
| 480 inline void LeaveContext(); | 511 inline void LeaveContext(); |
| 481 inline bool LastEnteredContextWas(Handle<Context> context); | 512 inline bool LastEnteredContextWas(Handle<Context> context); |
| 482 | 513 |
| 483 // Returns the last entered context or an empty handle if no | 514 // Returns the last entered context or an empty handle if no |
| 484 // contexts have been entered. | 515 // contexts have been entered. |
| 485 inline Handle<Context> LastEnteredContext(); | 516 inline Handle<Context> LastEnteredContext(); |
| 486 | 517 |
| 487 inline void SaveContext(Context* context); | 518 inline void SaveContext(Context* context); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 525 DeferredHandles* Detach(Object** prev_limit); | 556 DeferredHandles* Detach(Object** prev_limit); |
| 526 | 557 |
| 527 Isolate* isolate_; | 558 Isolate* isolate_; |
| 528 List<internal::Object**> blocks_; | 559 List<internal::Object**> blocks_; |
| 529 // Used as a stack to keep track of entered contexts. | 560 // Used as a stack to keep track of entered contexts. |
| 530 List<Context*> entered_contexts_; | 561 List<Context*> entered_contexts_; |
| 531 // Used as a stack to keep track of saved contexts. | 562 // Used as a stack to keep track of saved contexts. |
| 532 List<Context*> saved_contexts_; | 563 List<Context*> saved_contexts_; |
| 533 Object** spare_; | 564 Object** spare_; |
| 534 int call_depth_; | 565 int call_depth_; |
| 566 int microtasks_suppression_; | |
| 567 #ifdef V8_ENABLE_CHECKS | |
| 568 int debug_call_depth_; | |
| 569 #endif | |
| 570 int internal_call_depth_; | |
| 571 MicrotasksPolicy microtasks_policy_; | |
| 535 Object** last_handle_before_deferred_block_; | 572 Object** last_handle_before_deferred_block_; |
| 536 // This is only used for threading support. | 573 // This is only used for threading support. |
| 537 HandleScopeData handle_scope_data_; | 574 HandleScopeData handle_scope_data_; |
| 538 | 575 |
| 539 void IterateThis(ObjectVisitor* v); | 576 void IterateThis(ObjectVisitor* v); |
| 540 char* RestoreThreadHelper(char* from); | 577 char* RestoreThreadHelper(char* from); |
| 541 char* ArchiveThreadHelper(char* to); | 578 char* ArchiveThreadHelper(char* to); |
| 542 | 579 |
| 543 friend class DeferredHandles; | 580 friend class DeferredHandles; |
| 544 friend class DeferredHandleScope; | 581 friend class DeferredHandleScope; |
| 545 | 582 |
| 546 DISALLOW_COPY_AND_ASSIGN(HandleScopeImplementer); | 583 DISALLOW_COPY_AND_ASSIGN(HandleScopeImplementer); |
| 547 }; | 584 }; |
| 548 | 585 |
| 549 | 586 |
| 550 const int kHandleBlockSize = v8::internal::KB - 2; // fit in one page | 587 const int kHandleBlockSize = v8::internal::KB - 2; // fit in one page |
| 551 | 588 |
| 552 | 589 |
| 590 void HandleScopeImplementer::set_microtasks_policy(MicrotasksPolicy policy) { | |
| 591 microtasks_policy_ = policy; | |
| 592 } | |
| 593 | |
| 594 | |
| 595 MicrotasksPolicy HandleScopeImplementer::microtasks_policy() const { | |
| 596 return microtasks_policy_; | |
| 597 } | |
| 598 | |
| 599 | |
| 553 void HandleScopeImplementer::SaveContext(Context* context) { | 600 void HandleScopeImplementer::SaveContext(Context* context) { |
| 554 saved_contexts_.Add(context); | 601 saved_contexts_.Add(context); |
| 555 } | 602 } |
| 556 | 603 |
| 557 | 604 |
| 558 Context* HandleScopeImplementer::RestoreContext() { | 605 Context* HandleScopeImplementer::RestoreContext() { |
| 559 return saved_contexts_.RemoveLast(); | 606 return saved_contexts_.RemoveLast(); |
| 560 } | 607 } |
| 561 | 608 |
| 562 | 609 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 641 } | 688 } |
| 642 | 689 |
| 643 private: | 690 private: |
| 644 static v8::Testing::StressType stress_type_; | 691 static v8::Testing::StressType stress_type_; |
| 645 }; | 692 }; |
| 646 | 693 |
| 647 } // namespace internal | 694 } // namespace internal |
| 648 } // namespace v8 | 695 } // namespace v8 |
| 649 | 696 |
| 650 #endif // V8_API_H_ | 697 #endif // V8_API_H_ |
| OLD | NEW |