11cb0ef41Sopenharmony_ci// Copyright 2021 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#ifndef V8_HANDLES_GLOBAL_HANDLES_INL_H_
61cb0ef41Sopenharmony_ci#define V8_HANDLES_GLOBAL_HANDLES_INL_H_
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci#include "src/handles/global-handles.h"
91cb0ef41Sopenharmony_ci#include "src/handles/handles-inl.h"
101cb0ef41Sopenharmony_ci#include "src/objects/heap-object-inl.h"
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_cinamespace v8 {
131cb0ef41Sopenharmony_cinamespace internal {
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_citemplate <typename T>
161cb0ef41Sopenharmony_ciHandle<T> GlobalHandles::Create(T value) {
171cb0ef41Sopenharmony_ci  static_assert(std::is_base_of<Object, T>::value, "static type violation");
181cb0ef41Sopenharmony_ci  // The compiler should only pick this method if T is not Object.
191cb0ef41Sopenharmony_ci  static_assert(!std::is_same<Object, T>::value, "compiler error");
201cb0ef41Sopenharmony_ci  return Handle<T>::cast(Create(Object(value)));
211cb0ef41Sopenharmony_ci}
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_citemplate <typename T>
241cb0ef41Sopenharmony_ciT GlobalHandleVector<T>::Pop() {
251cb0ef41Sopenharmony_ci  T obj = T::cast(Object(locations_.back()));
261cb0ef41Sopenharmony_ci  locations_.pop_back();
271cb0ef41Sopenharmony_ci  return obj;
281cb0ef41Sopenharmony_ci}
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ci}  // namespace internal
311cb0ef41Sopenharmony_ci}  // namespace v8
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ci#endif  // V8_HANDLES_GLOBAL_HANDLES_INL_H_
34