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

Side by Side Diff: src/api.cc

Issue 2798923004: Call PersistentHandleVisitor directly instead of using ObjectVisitor. (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | src/global-handles.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8778 matching lines...) Expand 10 before | Expand all | Expand 10 after
8789 isolate->heap()->VisitExternalResources(visitor); 8789 isolate->heap()->VisitExternalResources(visitor);
8790 } 8790 }
8791 8791
8792 8792
8793 bool Isolate::IsInUse() { 8793 bool Isolate::IsInUse() {
8794 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 8794 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
8795 return isolate->IsInUse(); 8795 return isolate->IsInUse();
8796 } 8796 }
8797 8797
8798 8798
8799 class VisitorAdapter : public i::ObjectVisitor {
8800 public:
8801 explicit VisitorAdapter(PersistentHandleVisitor* visitor)
8802 : visitor_(visitor) {}
8803 void VisitPointers(i::Object** start, i::Object** end) override {
8804 UNREACHABLE();
8805 }
8806 DISABLE_CFI_PERF
8807 void VisitEmbedderReference(i::Object** p, uint16_t class_id) override {
8808 Value* value = ToApi<Value>(i::Handle<i::Object>(p));
8809 visitor_->VisitPersistentHandle(
8810 reinterpret_cast<Persistent<Value>*>(&value), class_id);
8811 }
8812
8813 private:
8814 PersistentHandleVisitor* visitor_;
8815 };
8816
8817
8818 void Isolate::VisitHandlesWithClassIds(PersistentHandleVisitor* visitor) { 8799 void Isolate::VisitHandlesWithClassIds(PersistentHandleVisitor* visitor) {
8819 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 8800 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
8820 i::DisallowHeapAllocation no_allocation; 8801 i::DisallowHeapAllocation no_allocation;
8821 VisitorAdapter visitor_adapter(visitor); 8802 isolate->global_handles()->IterateAllRootsWithClassIds(visitor);
8822 isolate->global_handles()->IterateAllRootsWithClassIds(&visitor_adapter);
8823 } 8803 }
8824 8804
8825 8805
8826 void Isolate::VisitHandlesForPartialDependence( 8806 void Isolate::VisitHandlesForPartialDependence(
8827 PersistentHandleVisitor* visitor) { 8807 PersistentHandleVisitor* visitor) {
8828 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 8808 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
8829 i::DisallowHeapAllocation no_allocation; 8809 i::DisallowHeapAllocation no_allocation;
8830 VisitorAdapter visitor_adapter(visitor); 8810 isolate->global_handles()->IterateAllRootsInNewSpaceWithClassIds(visitor);
8831 isolate->global_handles()->IterateAllRootsInNewSpaceWithClassIds(
8832 &visitor_adapter);
8833 } 8811 }
8834 8812
8835 8813
8836 void Isolate::VisitWeakHandles(PersistentHandleVisitor* visitor) { 8814 void Isolate::VisitWeakHandles(PersistentHandleVisitor* visitor) {
8837 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 8815 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
8838 i::DisallowHeapAllocation no_allocation; 8816 i::DisallowHeapAllocation no_allocation;
8839 VisitorAdapter visitor_adapter(visitor); 8817 isolate->global_handles()->IterateWeakRootsInNewSpaceWithClassIds(visitor);
8840 isolate->global_handles()->IterateWeakRootsInNewSpaceWithClassIds(
8841 &visitor_adapter);
8842 } 8818 }
8843 8819
8844 8820
8845 MicrotasksScope::MicrotasksScope(Isolate* isolate, MicrotasksScope::Type type) 8821 MicrotasksScope::MicrotasksScope(Isolate* isolate, MicrotasksScope::Type type)
8846 : isolate_(reinterpret_cast<i::Isolate*>(isolate)), 8822 : isolate_(reinterpret_cast<i::Isolate*>(isolate)),
8847 run_(type == MicrotasksScope::kRunMicrotasks) { 8823 run_(type == MicrotasksScope::kRunMicrotasks) {
8848 auto handle_scope_implementer = isolate_->handle_scope_implementer(); 8824 auto handle_scope_implementer = isolate_->handle_scope_implementer();
8849 if (run_) handle_scope_implementer->IncrementMicrotasksScopeDepth(); 8825 if (run_) handle_scope_implementer->IncrementMicrotasksScopeDepth();
8850 #ifdef DEBUG 8826 #ifdef DEBUG
8851 if (!run_) handle_scope_implementer->IncrementDebugMicrotasksScopeDepth(); 8827 if (!run_) handle_scope_implementer->IncrementDebugMicrotasksScopeDepth();
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after
10333 Address callback_address = 10309 Address callback_address =
10334 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 10310 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
10335 VMState<EXTERNAL> state(isolate); 10311 VMState<EXTERNAL> state(isolate);
10336 ExternalCallbackScope call_scope(isolate, callback_address); 10312 ExternalCallbackScope call_scope(isolate, callback_address);
10337 callback(info); 10313 callback(info);
10338 } 10314 }
10339 10315
10340 10316
10341 } // namespace internal 10317 } // namespace internal
10342 } // namespace v8 10318 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/global-handles.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698