v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
perfetto-utils.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
7#include "include/v8config.h"
10#include "src/objects/tagged.h"
11
12namespace v8 {
13namespace internal {
14
16 : is_one_byte_(string->IsOneByteRepresentation()), size_(0) {
17 if (string->length() <= 0) {
18 return;
19 }
20 size_ = static_cast<size_t>(string->length()) *
21 (string->IsOneByteRepresentation() ? sizeof(uint8_t)
22 : sizeof(base::uc16));
23 buffer_.reset(new uint8_t[size_]);
24 if (is_one_byte_) {
25 String::WriteToFlat(string, buffer_.get(), 0, string->length());
26 } else {
27 String::WriteToFlat(string, reinterpret_cast<base::uc16*>(buffer_.get()), 0,
28 string->length());
29 }
30}
31
32} // namespace internal
33} // namespace v8
PerfettoV8String(Tagged< String > string)
std::unique_ptr< uint8_t[]> buffer_
static void WriteToFlat(Tagged< String > source, SinkCharT *sink, uint32_t start, uint32_t length)
Definition string.cc:772
const int size_
Definition assembler.cc:132
uint16_t uc16
Definition strings.h:18