Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: src/api.cc

Issue 2801073006: Decouple root visitors from object visitors. (Closed)
Patch Set: rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 10157 matching lines...) Expand 10 before | Expand all | Expand 10 after
10168 return sizeof(HandleScopeImplementer); 10168 return sizeof(HandleScopeImplementer);
10169 } 10169 }
10170 10170
10171 10171
10172 char* HandleScopeImplementer::RestoreThread(char* storage) { 10172 char* HandleScopeImplementer::RestoreThread(char* storage) {
10173 MemCopy(this, storage, sizeof(*this)); 10173 MemCopy(this, storage, sizeof(*this));
10174 *isolate_->handle_scope_data() = handle_scope_data_; 10174 *isolate_->handle_scope_data() = handle_scope_data_;
10175 return storage + ArchiveSpacePerThread(); 10175 return storage + ArchiveSpacePerThread();
10176 } 10176 }
10177 10177
10178 10178 void HandleScopeImplementer::IterateThis(RootVisitor* v) {
10179 void HandleScopeImplementer::IterateThis(ObjectVisitor* v) {
10180 #ifdef DEBUG 10179 #ifdef DEBUG
10181 bool found_block_before_deferred = false; 10180 bool found_block_before_deferred = false;
10182 #endif 10181 #endif
10183 // Iterate over all handles in the blocks except for the last. 10182 // Iterate over all handles in the blocks except for the last.
10184 for (int i = blocks()->length() - 2; i >= 0; --i) { 10183 for (int i = blocks()->length() - 2; i >= 0; --i) {
10185 Object** block = blocks()->at(i); 10184 Object** block = blocks()->at(i);
10186 if (last_handle_before_deferred_block_ != NULL && 10185 if (last_handle_before_deferred_block_ != NULL &&
10187 (last_handle_before_deferred_block_ <= &block[kHandleBlockSize]) && 10186 (last_handle_before_deferred_block_ <= &block[kHandleBlockSize]) &&
10188 (last_handle_before_deferred_block_ >= block)) { 10187 (last_handle_before_deferred_block_ >= block)) {
10189 v->VisitPointers(block, last_handle_before_deferred_block_); 10188 v->VisitRootPointers(Root::kHandleScope, block,
10189 last_handle_before_deferred_block_);
10190 DCHECK(!found_block_before_deferred); 10190 DCHECK(!found_block_before_deferred);
10191 #ifdef DEBUG 10191 #ifdef DEBUG
10192 found_block_before_deferred = true; 10192 found_block_before_deferred = true;
10193 #endif 10193 #endif
10194 } else { 10194 } else {
10195 v->VisitPointers(block, &block[kHandleBlockSize]); 10195 v->VisitRootPointers(Root::kHandleScope, block, &block[kHandleBlockSize]);
10196 } 10196 }
10197 } 10197 }
10198 10198
10199 DCHECK(last_handle_before_deferred_block_ == NULL || 10199 DCHECK(last_handle_before_deferred_block_ == NULL ||
10200 found_block_before_deferred); 10200 found_block_before_deferred);
10201 10201
10202 // Iterate over live handles in the last block (if any). 10202 // Iterate over live handles in the last block (if any).
10203 if (!blocks()->is_empty()) { 10203 if (!blocks()->is_empty()) {
10204 v->VisitPointers(blocks()->last(), handle_scope_data_.next); 10204 v->VisitRootPointers(Root::kHandleScope, blocks()->last(),
10205 handle_scope_data_.next);
10205 } 10206 }
10206 10207
10207 List<Context*>* context_lists[2] = { &saved_contexts_, &entered_contexts_}; 10208 List<Context*>* context_lists[2] = { &saved_contexts_, &entered_contexts_};
10208 for (unsigned i = 0; i < arraysize(context_lists); i++) { 10209 for (unsigned i = 0; i < arraysize(context_lists); i++) {
10209 if (context_lists[i]->is_empty()) continue; 10210 if (context_lists[i]->is_empty()) continue;
10210 Object** start = reinterpret_cast<Object**>(&context_lists[i]->first()); 10211 Object** start = reinterpret_cast<Object**>(&context_lists[i]->first());
10211 v->VisitPointers(start, start + context_lists[i]->length()); 10212 v->VisitRootPointers(Root::kHandleScope, start,
10213 start + context_lists[i]->length());
10212 } 10214 }
10213 if (microtask_context_) { 10215 if (microtask_context_) {
10214 Object** start = reinterpret_cast<Object**>(&microtask_context_); 10216 v->VisitRootPointer(Root::kHandleScope,
10215 v->VisitPointers(start, start + 1); 10217 reinterpret_cast<Object**>(&microtask_context_));
10216 } 10218 }
10217 } 10219 }
10218 10220
10219 10221 void HandleScopeImplementer::Iterate(RootVisitor* v) {
10220 void HandleScopeImplementer::Iterate(ObjectVisitor* v) {
10221 HandleScopeData* current = isolate_->handle_scope_data(); 10222 HandleScopeData* current = isolate_->handle_scope_data();
10222 handle_scope_data_ = *current; 10223 handle_scope_data_ = *current;
10223 IterateThis(v); 10224 IterateThis(v);
10224 } 10225 }
10225 10226
10226 10227 char* HandleScopeImplementer::Iterate(RootVisitor* v, char* storage) {
10227 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
10228 HandleScopeImplementer* scope_implementer = 10228 HandleScopeImplementer* scope_implementer =
10229 reinterpret_cast<HandleScopeImplementer*>(storage); 10229 reinterpret_cast<HandleScopeImplementer*>(storage);
10230 scope_implementer->IterateThis(v); 10230 scope_implementer->IterateThis(v);
10231 return storage + ArchiveSpacePerThread(); 10231 return storage + ArchiveSpacePerThread();
10232 } 10232 }
10233 10233
10234 10234
10235 DeferredHandles* HandleScopeImplementer::Detach(Object** prev_limit) { 10235 DeferredHandles* HandleScopeImplementer::Detach(Object** prev_limit) {
10236 DeferredHandles* deferred = 10236 DeferredHandles* deferred =
10237 new DeferredHandles(isolate()->handle_scope_data()->next, isolate()); 10237 new DeferredHandles(isolate()->handle_scope_data()->next, isolate());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
10270 isolate_->UnlinkDeferredHandles(this); 10270 isolate_->UnlinkDeferredHandles(this);
10271 10271
10272 for (int i = 0; i < blocks_.length(); i++) { 10272 for (int i = 0; i < blocks_.length(); i++) {
10273 #ifdef ENABLE_HANDLE_ZAPPING 10273 #ifdef ENABLE_HANDLE_ZAPPING
10274 HandleScope::ZapRange(blocks_[i], &blocks_[i][kHandleBlockSize]); 10274 HandleScope::ZapRange(blocks_[i], &blocks_[i][kHandleBlockSize]);
10275 #endif 10275 #endif
10276 isolate_->handle_scope_implementer()->ReturnBlock(blocks_[i]); 10276 isolate_->handle_scope_implementer()->ReturnBlock(blocks_[i]);
10277 } 10277 }
10278 } 10278 }
10279 10279
10280 10280 void DeferredHandles::Iterate(RootVisitor* v) {
10281 void DeferredHandles::Iterate(ObjectVisitor* v) {
10282 DCHECK(!blocks_.is_empty()); 10281 DCHECK(!blocks_.is_empty());
10283 10282
10284 DCHECK((first_block_limit_ >= blocks_.first()) && 10283 DCHECK((first_block_limit_ >= blocks_.first()) &&
10285 (first_block_limit_ <= &(blocks_.first())[kHandleBlockSize])); 10284 (first_block_limit_ <= &(blocks_.first())[kHandleBlockSize]));
10286 10285
10287 v->VisitPointers(blocks_.first(), first_block_limit_); 10286 v->VisitRootPointers(Root::kHandleScope, blocks_.first(), first_block_limit_);
10288 10287
10289 for (int i = 1; i < blocks_.length(); i++) { 10288 for (int i = 1; i < blocks_.length(); i++) {
10290 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); 10289 v->VisitRootPointers(Root::kHandleScope, blocks_[i],
10290 &blocks_[i][kHandleBlockSize]);
10291 } 10291 }
10292 } 10292 }
10293 10293
10294 10294
10295 void InvokeAccessorGetterCallback( 10295 void InvokeAccessorGetterCallback(
10296 v8::Local<v8::Name> property, 10296 v8::Local<v8::Name> property,
10297 const v8::PropertyCallbackInfo<v8::Value>& info, 10297 const v8::PropertyCallbackInfo<v8::Value>& info,
10298 v8::AccessorNameGetterCallback getter) { 10298 v8::AccessorNameGetterCallback getter) {
10299 // Leaving JavaScript. 10299 // Leaving JavaScript.
10300 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 10300 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
(...skipping 15 matching lines...) Expand all
10316 Address callback_address = 10316 Address callback_address =
10317 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 10317 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
10318 VMState<EXTERNAL> state(isolate); 10318 VMState<EXTERNAL> state(isolate);
10319 ExternalCallbackScope call_scope(isolate, callback_address); 10319 ExternalCallbackScope call_scope(isolate, callback_address);
10320 callback(info); 10320 callback(info);
10321 } 10321 }
10322 10322
10323 10323
10324 } // namespace internal 10324 } // namespace internal
10325 } // namespace v8 10325 } // namespace v8
OLDNEW
« no previous file with comments | « src/api.h ('k') | src/api-arguments.h » ('j') | src/heap/mark-compact.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698