/
githubmirror
/
node
Обзор
Документация
Войти
/
githubmirror
/
node
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
deps/v8/src/objects/regexp-match-info.cc
45 строк
2 KB
Michaël Zasso
deps: update V8 to 13.6.233.8
02 май 2025, 16:06
Не верифицирован
02 май 2025, 16:06
918fe04
Код
Авторство
О чём код?
// Copyright 2023 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include <optional> #include "src/objects/regexp-match-info-inl.h" namespace v8::internal { // static DirectHandle<RegExpMatchInfo> RegExpMatchInfo::New(Isolate* isolate, int capture_count, AllocationType allocation) { int capacity = JSRegExp::RegistersForCaptureCount(capture_count); DCHECK_GE(capacity, kMinCapacity); std::optional<DisallowGarbageCollection> no_gc; DirectHandle<RegExpMatchInfo> result = Allocate(isolate, capacity, &no_gc, allocation); ReadOnlyRoots roots{isolate}; MemsetTagged(result->RawFieldOfFirstElement(), Smi::zero(), capacity); result->set_number_of_capture_registers(capacity); result->set_last_subject(*isolate->factory()->empty_string(), SKIP_WRITE_BARRIER); result->set_last_input(roots.undefined_value(), SKIP_WRITE_BARRIER); return result; } DirectHandle<RegExpMatchInfo> RegExpMatchInfo::ReserveCaptures( Isolate* isolate, DirectHandle<RegExpMatchInfo> match_info, int capture_count) { int required_capacity = JSRegExp::RegistersForCaptureCount(capture_count); if (required_capacity > match_info->capacity()) { DirectHandle<RegExpMatchInfo> new_info = New(isolate, capture_count); RegExpMatchInfo::CopyElements(isolate, *new_info, 0, *match_info, 0, match_info->capacity()); match_info = new_info; } match_info->set_number_of_capture_registers(required_capacity); return match_info; } } // namespace v8::internal