v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
regexp-result-vector.cc
Go to the documentation of this file.
1// Copyright 2024 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
6
8
9namespace v8 {
10namespace internal {
11
14
16 : isolate_(isolate) {
17 Initialize(size);
18}
19
21 if (is_dynamic_) {
23 } else if (value_ != nullptr) {
24 // Return ownership of the static vector.
26 } else {
27 // The scope was created but Initialize never called. Nothing to do.
28 }
29}
30
33 int32_t* static_vector_or_null =
36 static_vector_or_null == nullptr) {
37 is_dynamic_ = true;
39 } else {
40 value_ = static_vector_or_null;
41 // Take ownership of the static vector. See also:
42 // RegExpBuiltinsAssembler::TryLoadStaticRegExpResultVector.
44 }
46 return value_;
47}
48
49// Note this may be called through CallCFunction.
50// static
51int32_t* RegExpResultVector::Allocate(Isolate* isolate, uint32_t size) {
53 auto vector = new int32_t[size];
54 isolate->active_dynamic_regexp_result_vectors().insert(vector);
55 return vector;
56}
57
58// Note this may be called through CallCFunction.
59// static
60void RegExpResultVector::Free(Isolate* isolate, int32_t* vector) {
62 DCHECK_NOT_NULL(vector);
63 isolate->active_dynamic_regexp_result_vectors().erase(vector);
64 delete[] vector;
65}
66
67} // namespace internal
68} // namespace v8
Isolate * isolate_
int32_t * regexp_static_result_offsets_vector() const
Definition isolate.h:1449
static const int kJSRegexpStaticOffsetsVectorSize
Definition isolate.h:1533
void set_regexp_static_result_offsets_vector(int32_t *value)
Definition isolate.h:1452
static void Free(Isolate *isolate, int32_t *vector)
static int32_t * Allocate(Isolate *isolate, uint32_t size)
#define DCHECK_NULL(val)
Definition logging.h:491
#define DCHECK_NOT_NULL(val)
Definition logging.h:492