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_HANDLES_GLOBAL_HANDLES_INL_H_ 6 #define V8_HANDLES_GLOBAL_HANDLES_INL_H_ 7 8 #include "src/handles/global-handles.h" 9 #include "src/handles/handles-inl.h" 10 #include "src/objects/heap-object-inl.h" 11 12 namespace v8 { 13 namespace internal { 14 15 template <typename T> Create(T value)16Handle<T> GlobalHandles::Create(T value) { 17 static_assert(std::is_base_of<Object, T>::value, "static type violation"); 18 // The compiler should only pick this method if T is not Object. 19 static_assert(!std::is_same<Object, T>::value, "compiler error"); 20 return Handle<T>::cast(Create(Object(value))); 21 } 22 23 template <typename T> Pop()24T GlobalHandleVector<T>::Pop() { 25 T obj = T::cast(Object(locations_.back())); 26 locations_.pop_back(); 27 return obj; 28 } 29 30 } // namespace internal 31 } // namespace v8 32 33 #endif // V8_HANDLES_GLOBAL_HANDLES_INL_H_ 34