Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
dart-lang
sdk
runtime
vm
compiler
ffi
unit_test_custom_zone.h
Go to the documentation of this file.
1
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2
// for details. All rights reserved. Use of this source code is governed by a
3
// BSD-style license that can be found in the LICENSE file.
4
5
#ifndef RUNTIME_VM_COMPILER_FFI_UNIT_TEST_CUSTOM_ZONE_H_
6
#define RUNTIME_VM_COMPILER_FFI_UNIT_TEST_CUSTOM_ZONE_H_
7
8
#include <vector>
9
10
// We use a custom zone here which doesn't depend on VM internals (e.g. handles,
11
// thread, ...)
12
#if defined(RUNTIME_VM_ZONE_H_)
13
#error "We want our own zone implementation"
14
#endif
15
#define RUNTIME_VM_ZONE_H_
16
17
namespace
dart
{
18
19
class
Zone
{
20
public
:
21
Zone
() {}
22
~Zone
();
23
24
template
<
class
ElementType>
25
inline
ElementType*
Alloc
(intptr_t
length
) {
26
return
static_cast<
ElementType*
>
(
AllocUnsafe
(
sizeof
(ElementType) *
length
));
27
}
28
29
template
<
class
ElementType>
30
inline
ElementType*
Realloc
(ElementType* old_array,
31
intptr_t old_length,
32
intptr_t new_length) {
33
void
* memory =
AllocUnsafe
(
sizeof
(ElementType) * new_length);
34
memmove(memory, old_array,
sizeof
(ElementType) * old_length);
35
return
static_cast<
ElementType*
>
(memory);
36
}
37
38
template
<
class
ElementType>
39
void
Free
(ElementType* old_array, intptr_t len) {}
40
41
void
*
AllocUnsafe
(intptr_t size);
42
43
private
:
44
Zone
(
const
Zone
&) =
delete
;
45
void
operator=(
const
Zone
&) =
delete
;
46
std::vector<void*> buffers_;
47
};
48
49
}
// namespace dart
50
51
#endif
// RUNTIME_VM_COMPILER_FFI_UNIT_TEST_CUSTOM_ZONE_H_
dart::Zone
Definition
unit_test_custom_zone.h:19
dart::Zone::Zone
Zone()
Definition
unit_test_custom_zone.h:21
dart::Zone::AllocUnsafe
void * AllocUnsafe(intptr_t size)
Definition
unit_test_custom_zone.cc:29
dart::Zone::Free
void Free(ElementType *old_array, intptr_t len)
Definition
unit_test_custom_zone.h:39
dart::Zone::~Zone
~Zone()
Definition
unit_test_custom_zone.cc:22
dart::Zone::Realloc
ElementType * Realloc(ElementType *old_array, intptr_t old_length, intptr_t new_length)
Definition
unit_test_custom_zone.h:30
dart::Zone::Alloc
ElementType * Alloc(intptr_t length)
Definition
unit_test_custom_zone.h:25
length
size_t length
Definition
key_event_handler.cc:41
dart
Definition
dart_vm.cc:33
Generated on Fri Apr 26 2024 06:14:59 for Flutter Engine by
1.9.8