1// Copyright 2021 the V8 project authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef V8_HEAP_CPPGC_JS_CPP_MARKING_STATE_INL_H_ 6#define V8_HEAP_CPPGC_JS_CPP_MARKING_STATE_INL_H_ 7 8#include "src/heap/cppgc-js/cpp-marking-state.h" 9#include "src/heap/embedder-tracing-inl.h" 10#include "src/objects/embedder-data-slot.h" 11#include "src/objects/js-objects.h" 12 13namespace v8 { 14namespace internal { 15 16bool CppMarkingState::ExtractEmbedderDataSnapshot( 17 Map map, JSObject object, EmbedderDataSnapshot& snapshot) { 18 if (JSObject::GetEmbedderFieldCount(map) < 2) return false; 19 20 EmbedderDataSlot::PopulateEmbedderDataSnapshot( 21 map, object, wrapper_descriptor_.wrappable_type_index, snapshot.first); 22 EmbedderDataSlot::PopulateEmbedderDataSnapshot( 23 map, object, wrapper_descriptor_.wrappable_instance_index, 24 snapshot.second); 25 return true; 26} 27 28void CppMarkingState::MarkAndPush(const EmbedderDataSnapshot& snapshot) { 29 const EmbedderDataSlot type_slot(snapshot.first); 30 const EmbedderDataSlot instance_slot(snapshot.second); 31 MarkAndPush(type_slot, instance_slot); 32} 33 34void CppMarkingState::MarkAndPush(const EmbedderDataSlot type_slot, 35 const EmbedderDataSlot instance_slot) { 36 LocalEmbedderHeapTracer::WrapperInfo info; 37 if (LocalEmbedderHeapTracer::ExtractWrappableInfo( 38 isolate_, wrapper_descriptor_, type_slot, instance_slot, &info)) { 39 marking_state_.MarkAndPush( 40 cppgc::internal::HeapObjectHeader::FromObject(info.second)); 41 } 42} 43 44} // namespace internal 45} // namespace v8 46 47#endif // V8_HEAP_CPPGC_JS_CPP_MARKING_STATE_INL_H_ 48