v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
zone-utils.h
Go to the documentation of this file.
1
// Copyright 2020 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_ZONE_ZONE_UTILS_H_
6
#define V8_ZONE_ZONE_UTILS_H_
7
8
#include <algorithm>
9
#include <type_traits>
10
11
#include "
src/base/vector.h
"
12
#include "
src/zone/zone.h
"
13
14
namespace
v8
{
15
namespace
internal
{
16
17
template
<
typename
T>
18
base::Vector<T>
CloneVector
(
Zone
* zone,
base::Vector<const T>
other) {
19
int
length = other.
length
();
20
if
(length == 0)
return
base::Vector<T>
();
21
22
T* data = zone->
AllocateArray
<T>(
length
);
23
if
(std::is_trivially_copyable<T>::value) {
24
MemCopy
(data, other.data(), length *
sizeof
(T));
25
}
else
{
26
std::copy(other.begin(), other.end(), data);
27
}
28
return
base::Vector<T>
(data, length);
29
}
30
31
}
// namespace internal
32
}
// namespace v8
33
34
#endif
// V8_ZONE_ZONE_UTILS_H_
v8::base::Vector
Definition
zone-list.h:15
v8::base::Vector::length
int length() const
Definition
vector.h:64
v8::internal::Zone
Definition
zone.h:43
v8::internal::Zone::AllocateArray
T * AllocateArray(size_t length)
Definition
zone.h:127
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
v8::internal::CloneVector
base::Vector< T > CloneVector(Zone *zone, base::Vector< const T > other)
Definition
zone-utils.h:18
v8::internal::MemCopy
void MemCopy(void *dest, const void *src, size_t size)
Definition
memcopy.h:124
v8::internal::length
size_t length
Definition
external-reference.cc:1491
v8
Definition
api-arguments-inl.h:19
vector.h
zone.h
src
zone
zone-utils.h
Generated on Sun Apr 6 2025 21:08:58 for v8 by
1.12.0