Chromium Code Reviews| Index: src/isolate.cc |
| diff --git a/src/isolate.cc b/src/isolate.cc |
| index b5bd955de5c868e1e83eab3450c0f3bca6a47ef7..217b24849010c6cc00ec9c8f2464764025712020 100644 |
| --- a/src/isolate.cc |
| +++ b/src/isolate.cc |
| @@ -507,6 +507,34 @@ void Isolate::IterateDeferredHandles(ObjectVisitor* visitor) { |
| } |
| +#ifdef DEBUG |
| +bool Isolate::IsDeferredHandle(Object** handle) { |
| + // Each DeferredHandles instance keeps the handles to one job in the |
| + // parallel recompilation queue, containing a list of blocks. Each block |
| + // contains kHandleBlockSize handles except for the first block, which may |
| + // not be fully filled. |
| + // We iterate through all the blocks to see whether the argument handle |
| + // belongs to one of the blocks. If so, it is deferred. |
| + for (DeferredHandles* deferred = deferred_handles_head_; |
| + deferred != NULL; |
| + deferred = deferred->next_) { |
| + List<Object**>* blocks = &deferred->blocks_; |
| + if (blocks->first() <= handle && |
| + handle < deferred->first_block_limit_) { |
| + return true; |
| + } |
| + for (int i = 1; i < blocks->length(); i++) { |
| + if (blocks->at(i) <= handle && |
| + handle < blocks->at(i) + kHandleBlockSize) { |
| + return true; |
| + } |
| + } |
|
mvstanton
2013/04/23 08:58:50
Why can't the check of the first block in the list
Yang
2013/04/23 09:19:09
Works. Done.
|
| + } |
| + return false; |
| +} |
| +#endif // DEBUG |
| + |
| + |
| void Isolate::RegisterTryCatchHandler(v8::TryCatch* that) { |
| // The ARM simulator has a separate JS stack. We therefore register |
| // the C++ try catch handler with the simulator and get back an |
| @@ -1757,8 +1785,8 @@ Isolate::Isolate() |
| memset(code_kind_statistics_, 0, |
| sizeof(code_kind_statistics_[0]) * Code::NUMBER_OF_KINDS); |
| - allow_compiler_thread_handle_deref_ = true; |
| - allow_execution_thread_handle_deref_ = true; |
| + compiler_thread_handle_deref_state_ = HandleDereferenceGuard::ALLOW; |
| + execution_thread_handle_deref_state_ = HandleDereferenceGuard::ALLOW; |
| #endif |
| #ifdef ENABLE_DEBUGGER_SUPPORT |
| @@ -2379,27 +2407,28 @@ void Isolate::UnlinkDeferredHandles(DeferredHandles* deferred) { |
| #ifdef DEBUG |
| -bool Isolate::AllowHandleDereference() { |
| - if (allow_execution_thread_handle_deref_ && |
| - allow_compiler_thread_handle_deref_) { |
| +HandleDereferenceGuard::State Isolate::HandleDereferenceGuardState() { |
| + if (execution_thread_handle_deref_state_ == HandleDereferenceGuard::ALLOW && |
| + compiler_thread_handle_deref_state_ == HandleDereferenceGuard::ALLOW) { |
| // Short-cut to avoid polling thread id. |
| - return true; |
| + return HandleDereferenceGuard::ALLOW; |
| } |
| if (FLAG_parallel_recompilation && |
| optimizing_compiler_thread()->IsOptimizerThread()) { |
| - return allow_compiler_thread_handle_deref_; |
| + return compiler_thread_handle_deref_state_; |
| } else { |
| - return allow_execution_thread_handle_deref_; |
| + return execution_thread_handle_deref_state_; |
| } |
| } |
| -void Isolate::SetAllowHandleDereference(bool allow) { |
| +void Isolate::SetHandleDereferenceGuardState( |
| + HandleDereferenceGuard::State state) { |
| if (FLAG_parallel_recompilation && |
| optimizing_compiler_thread()->IsOptimizerThread()) { |
| - allow_compiler_thread_handle_deref_ = allow; |
| + compiler_thread_handle_deref_state_ = state; |
| } else { |
| - allow_execution_thread_handle_deref_ = allow; |
| + execution_thread_handle_deref_state_ = state; |
| } |
| } |
| #endif |