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 #include "src/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 10308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10319 return sizeof(HandleScopeImplementer); | 10319 return sizeof(HandleScopeImplementer); |
10320 } | 10320 } |
10321 | 10321 |
10322 | 10322 |
10323 char* HandleScopeImplementer::RestoreThread(char* storage) { | 10323 char* HandleScopeImplementer::RestoreThread(char* storage) { |
10324 MemCopy(this, storage, sizeof(*this)); | 10324 MemCopy(this, storage, sizeof(*this)); |
10325 *isolate_->handle_scope_data() = handle_scope_data_; | 10325 *isolate_->handle_scope_data() = handle_scope_data_; |
10326 return storage + ArchiveSpacePerThread(); | 10326 return storage + ArchiveSpacePerThread(); |
10327 } | 10327 } |
10328 | 10328 |
10329 | 10329 void HandleScopeImplementer::IterateThis(RootVisitor* v) { |
10330 void HandleScopeImplementer::IterateThis(ObjectVisitor* v) { | |
10331 #ifdef DEBUG | 10330 #ifdef DEBUG |
10332 bool found_block_before_deferred = false; | 10331 bool found_block_before_deferred = false; |
10333 #endif | 10332 #endif |
10334 // Iterate over all handles in the blocks except for the last. | 10333 // Iterate over all handles in the blocks except for the last. |
10335 for (int i = blocks()->length() - 2; i >= 0; --i) { | 10334 for (int i = blocks()->length() - 2; i >= 0; --i) { |
10336 Object** block = blocks()->at(i); | 10335 Object** block = blocks()->at(i); |
10337 if (last_handle_before_deferred_block_ != NULL && | 10336 if (last_handle_before_deferred_block_ != NULL && |
10338 (last_handle_before_deferred_block_ <= &block[kHandleBlockSize]) && | 10337 (last_handle_before_deferred_block_ <= &block[kHandleBlockSize]) && |
10339 (last_handle_before_deferred_block_ >= block)) { | 10338 (last_handle_before_deferred_block_ >= block)) { |
10340 v->VisitPointers(block, last_handle_before_deferred_block_); | 10339 v->VisitRootPointers(Root::kHandleScope, block, |
| 10340 last_handle_before_deferred_block_); |
10341 DCHECK(!found_block_before_deferred); | 10341 DCHECK(!found_block_before_deferred); |
10342 #ifdef DEBUG | 10342 #ifdef DEBUG |
10343 found_block_before_deferred = true; | 10343 found_block_before_deferred = true; |
10344 #endif | 10344 #endif |
10345 } else { | 10345 } else { |
10346 v->VisitPointers(block, &block[kHandleBlockSize]); | 10346 v->VisitRootPointers(Root::kHandleScope, block, &block[kHandleBlockSize]); |
10347 } | 10347 } |
10348 } | 10348 } |
10349 | 10349 |
10350 DCHECK(last_handle_before_deferred_block_ == NULL || | 10350 DCHECK(last_handle_before_deferred_block_ == NULL || |
10351 found_block_before_deferred); | 10351 found_block_before_deferred); |
10352 | 10352 |
10353 // Iterate over live handles in the last block (if any). | 10353 // Iterate over live handles in the last block (if any). |
10354 if (!blocks()->is_empty()) { | 10354 if (!blocks()->is_empty()) { |
10355 v->VisitPointers(blocks()->last(), handle_scope_data_.next); | 10355 v->VisitRootPointers(Root::kHandleScope, blocks()->last(), |
| 10356 handle_scope_data_.next); |
10356 } | 10357 } |
10357 | 10358 |
10358 List<Context*>* context_lists[2] = { &saved_contexts_, &entered_contexts_}; | 10359 List<Context*>* context_lists[2] = { &saved_contexts_, &entered_contexts_}; |
10359 for (unsigned i = 0; i < arraysize(context_lists); i++) { | 10360 for (unsigned i = 0; i < arraysize(context_lists); i++) { |
10360 if (context_lists[i]->is_empty()) continue; | 10361 if (context_lists[i]->is_empty()) continue; |
10361 Object** start = reinterpret_cast<Object**>(&context_lists[i]->first()); | 10362 Object** start = reinterpret_cast<Object**>(&context_lists[i]->first()); |
10362 v->VisitPointers(start, start + context_lists[i]->length()); | 10363 v->VisitRootPointers(Root::kHandleScope, start, |
| 10364 start + context_lists[i]->length()); |
10363 } | 10365 } |
10364 if (microtask_context_) { | 10366 if (microtask_context_) { |
10365 Object** start = reinterpret_cast<Object**>(µtask_context_); | 10367 v->VisitRootPointer(Root::kHandleScope, |
10366 v->VisitPointers(start, start + 1); | 10368 reinterpret_cast<Object**>(µtask_context_)); |
10367 } | 10369 } |
10368 } | 10370 } |
10369 | 10371 |
10370 | 10372 void HandleScopeImplementer::Iterate(RootVisitor* v) { |
10371 void HandleScopeImplementer::Iterate(ObjectVisitor* v) { | |
10372 HandleScopeData* current = isolate_->handle_scope_data(); | 10373 HandleScopeData* current = isolate_->handle_scope_data(); |
10373 handle_scope_data_ = *current; | 10374 handle_scope_data_ = *current; |
10374 IterateThis(v); | 10375 IterateThis(v); |
10375 } | 10376 } |
10376 | 10377 |
10377 | 10378 char* HandleScopeImplementer::Iterate(RootVisitor* v, char* storage) { |
10378 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | |
10379 HandleScopeImplementer* scope_implementer = | 10379 HandleScopeImplementer* scope_implementer = |
10380 reinterpret_cast<HandleScopeImplementer*>(storage); | 10380 reinterpret_cast<HandleScopeImplementer*>(storage); |
10381 scope_implementer->IterateThis(v); | 10381 scope_implementer->IterateThis(v); |
10382 return storage + ArchiveSpacePerThread(); | 10382 return storage + ArchiveSpacePerThread(); |
10383 } | 10383 } |
10384 | 10384 |
10385 | 10385 |
10386 DeferredHandles* HandleScopeImplementer::Detach(Object** prev_limit) { | 10386 DeferredHandles* HandleScopeImplementer::Detach(Object** prev_limit) { |
10387 DeferredHandles* deferred = | 10387 DeferredHandles* deferred = |
10388 new DeferredHandles(isolate()->handle_scope_data()->next, isolate()); | 10388 new DeferredHandles(isolate()->handle_scope_data()->next, isolate()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10421 isolate_->UnlinkDeferredHandles(this); | 10421 isolate_->UnlinkDeferredHandles(this); |
10422 | 10422 |
10423 for (int i = 0; i < blocks_.length(); i++) { | 10423 for (int i = 0; i < blocks_.length(); i++) { |
10424 #ifdef ENABLE_HANDLE_ZAPPING | 10424 #ifdef ENABLE_HANDLE_ZAPPING |
10425 HandleScope::ZapRange(blocks_[i], &blocks_[i][kHandleBlockSize]); | 10425 HandleScope::ZapRange(blocks_[i], &blocks_[i][kHandleBlockSize]); |
10426 #endif | 10426 #endif |
10427 isolate_->handle_scope_implementer()->ReturnBlock(blocks_[i]); | 10427 isolate_->handle_scope_implementer()->ReturnBlock(blocks_[i]); |
10428 } | 10428 } |
10429 } | 10429 } |
10430 | 10430 |
10431 | 10431 void DeferredHandles::Iterate(RootVisitor* v) { |
10432 void DeferredHandles::Iterate(ObjectVisitor* v) { | |
10433 DCHECK(!blocks_.is_empty()); | 10432 DCHECK(!blocks_.is_empty()); |
10434 | 10433 |
10435 DCHECK((first_block_limit_ >= blocks_.first()) && | 10434 DCHECK((first_block_limit_ >= blocks_.first()) && |
10436 (first_block_limit_ <= &(blocks_.first())[kHandleBlockSize])); | 10435 (first_block_limit_ <= &(blocks_.first())[kHandleBlockSize])); |
10437 | 10436 |
10438 v->VisitPointers(blocks_.first(), first_block_limit_); | 10437 v->VisitRootPointers(Root::kHandleScope, blocks_.first(), first_block_limit_); |
10439 | 10438 |
10440 for (int i = 1; i < blocks_.length(); i++) { | 10439 for (int i = 1; i < blocks_.length(); i++) { |
10441 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); | 10440 v->VisitRootPointers(Root::kHandleScope, blocks_[i], |
| 10441 &blocks_[i][kHandleBlockSize]); |
10442 } | 10442 } |
10443 } | 10443 } |
10444 | 10444 |
10445 | 10445 |
10446 void InvokeAccessorGetterCallback( | 10446 void InvokeAccessorGetterCallback( |
10447 v8::Local<v8::Name> property, | 10447 v8::Local<v8::Name> property, |
10448 const v8::PropertyCallbackInfo<v8::Value>& info, | 10448 const v8::PropertyCallbackInfo<v8::Value>& info, |
10449 v8::AccessorNameGetterCallback getter) { | 10449 v8::AccessorNameGetterCallback getter) { |
10450 // Leaving JavaScript. | 10450 // Leaving JavaScript. |
10451 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 10451 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
(...skipping 15 matching lines...) Expand all Loading... |
10467 Address callback_address = | 10467 Address callback_address = |
10468 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 10468 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
10469 VMState<EXTERNAL> state(isolate); | 10469 VMState<EXTERNAL> state(isolate); |
10470 ExternalCallbackScope call_scope(isolate, callback_address); | 10470 ExternalCallbackScope call_scope(isolate, callback_address); |
10471 callback(info); | 10471 callback(info); |
10472 } | 10472 } |
10473 | 10473 |
10474 | 10474 |
10475 } // namespace internal | 10475 } // namespace internal |
10476 } // namespace v8 | 10476 } // namespace v8 |
OLD | NEW |