V8 Project
v8::internal::OutputStreamWriter Class Reference
+ Collaboration diagram for v8::internal::OutputStreamWriter:

Public Member Functions

 OutputStreamWriter (v8::OutputStream *stream)
 
bool aborted ()
 
void AddCharacter (char c)
 
void AddString (const char *s)
 
void AddSubstring (const char *s, int n)
 
void AddNumber (unsigned n)
 
void Finalize ()
 

Private Member Functions

template<typename T >
void AddNumberImpl (T n, const char *format)
 
void MaybeWriteChunk ()
 
void WriteChunk ()
 

Private Attributes

v8::OutputStreamstream_
 
int chunk_size_
 
ScopedVector< char > chunk_
 
int chunk_pos_
 
bool aborted_
 

Detailed Description

Definition at line 2631 of file heap-snapshot-generator.cc.

Constructor & Destructor Documentation

◆ OutputStreamWriter()

v8::internal::OutputStreamWriter::OutputStreamWriter ( v8::OutputStream stream)
inlineexplicit

Definition at line 2633 of file heap-snapshot-generator.cc.

2634  : stream_(stream),
2635  chunk_size_(stream->GetChunkSize()),
2637  chunk_pos_(0),
2638  aborted_(false) {
2639  DCHECK(chunk_size_ > 0);
2640  }
virtual int GetChunkSize()
Get preferred output chunk size.
Definition: v8-profiler.h:282
#define DCHECK(condition)
Definition: logging.h:205

References chunk_size_, and DCHECK.

Member Function Documentation

◆ aborted()

bool v8::internal::OutputStreamWriter::aborted ( )
inline

Definition at line 2641 of file heap-snapshot-generator.cc.

2641 { return aborted_; }

References aborted_.

Referenced by v8::internal::HeapSnapshotJSONSerializer::SerializeEdges(), v8::internal::HeapSnapshotJSONSerializer::SerializeImpl(), v8::internal::HeapSnapshotJSONSerializer::SerializeNodes(), and v8::internal::HeapSnapshotJSONSerializer::SerializeStrings().

+ Here is the caller graph for this function:

◆ AddCharacter()

void v8::internal::OutputStreamWriter::AddCharacter ( char  c)
inline

Definition at line 2642 of file heap-snapshot-generator.cc.

2642  {
2643  DCHECK(c != '\0');
2645  chunk_[chunk_pos_++] = c;
2646  MaybeWriteChunk();
2647  }

References chunk_, chunk_pos_, chunk_size_, DCHECK, and MaybeWriteChunk().

Referenced by v8::internal::HeapSnapshotJSONSerializer::SerializeImpl(), v8::internal::HeapSnapshotJSONSerializer::SerializeString(), v8::internal::HeapSnapshotJSONSerializer::SerializeStrings(), v8::internal::HeapSnapshotJSONSerializer::SerializeTraceNode(), and v8::internal::WriteUChar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddNumber()

void v8::internal::OutputStreamWriter::AddNumber ( unsigned  n)
inline

Definition at line 2665 of file heap-snapshot-generator.cc.

2665 { AddNumberImpl<unsigned>(n, "%u"); }

Referenced by v8::internal::HeapSnapshotJSONSerializer::SerializeSnapshot().

+ Here is the caller graph for this function:

◆ AddNumberImpl()

template<typename T >
void v8::internal::OutputStreamWriter::AddNumberImpl ( T  n,
const char *  format 
)
inlineprivate

Definition at line 2677 of file heap-snapshot-generator.cc.

2677  {
2678  // Buffer for the longest value plus trailing \0
2679  static const int kMaxNumberSize =
2680  MaxDecimalDigitsIn<sizeof(T)>::kUnsigned + 1;
2681  if (chunk_size_ - chunk_pos_ >= kMaxNumberSize) {
2682  int result = SNPrintF(
2683  chunk_.SubVector(chunk_pos_, chunk_size_), format, n);
2684  DCHECK(result != -1);
2685  chunk_pos_ += result;
2686  MaybeWriteChunk();
2687  } else {
2688  EmbeddedVector<char, kMaxNumberSize> buffer;
2689  int result = SNPrintF(buffer, format, n);
2690  USE(result);
2691  DCHECK(result != -1);
2692  AddString(buffer.start());
2693  }
2694  }
Vector< T > SubVector(int from, int to)
Definition: vector.h:33
void USE(T)
Definition: macros.h:322
int SNPrintF(Vector< char > str, const char *format,...)
Definition: utils.cc:105
#define T(name, string, precedence)
Definition: token.cc:25

References AddString(), chunk_, chunk_pos_, chunk_size_, DCHECK, v8::internal::kUnsigned, MaybeWriteChunk(), v8::internal::SNPrintF(), v8::internal::Vector< T >::start(), v8::internal::Vector< T >::SubVector(), T, and USE().

+ Here is the call graph for this function:

◆ AddString()

void v8::internal::OutputStreamWriter::AddString ( const char *  s)
inline

Definition at line 2648 of file heap-snapshot-generator.cc.

2648  {
2649  AddSubstring(s, StrLength(s));
2650  }
int StrLength(const char *string)
Definition: vector.h:147

References AddSubstring(), and v8::internal::StrLength().

Referenced by AddNumberImpl(), v8::internal::HeapSnapshotJSONSerializer::SerializeEdge(), v8::internal::HeapSnapshotJSONSerializer::SerializeImpl(), v8::internal::HeapSnapshotJSONSerializer::SerializeNode(), v8::internal::HeapSnapshotJSONSerializer::SerializeSnapshot(), v8::internal::HeapSnapshotJSONSerializer::SerializeString(), v8::internal::HeapSnapshotJSONSerializer::SerializeStrings(), v8::internal::HeapSnapshotJSONSerializer::SerializeTraceNode(), v8::internal::HeapSnapshotJSONSerializer::SerializeTraceNodeInfos(), and v8::internal::WriteUChar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddSubstring()

void v8::internal::OutputStreamWriter::AddSubstring ( const char *  s,
int  n 
)
inline

Definition at line 2651 of file heap-snapshot-generator.cc.

2651  {
2652  if (n <= 0) return;
2653  DCHECK(static_cast<size_t>(n) <= strlen(s));
2654  const char* s_end = s + n;
2655  while (s < s_end) {
2656  int s_chunk_size =
2657  Min(chunk_size_ - chunk_pos_, static_cast<int>(s_end - s));
2658  DCHECK(s_chunk_size > 0);
2659  MemCopy(chunk_.start() + chunk_pos_, s, s_chunk_size);
2660  s += s_chunk_size;
2661  chunk_pos_ += s_chunk_size;
2662  MaybeWriteChunk();
2663  }
2664  }
T * start() const
Definition: vector.h:47
static LifetimePosition Min(LifetimePosition a, LifetimePosition b)
void MemCopy(void *dest, const void *src, size_t size)
Definition: utils.h:350

References chunk_, chunk_pos_, chunk_size_, DCHECK, MaybeWriteChunk(), v8::internal::MemCopy(), v8::internal::Min(), and v8::internal::Vector< T >::start().

Referenced by AddString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Finalize()

void v8::internal::OutputStreamWriter::Finalize ( )
inline

Definition at line 2666 of file heap-snapshot-generator.cc.

2666  {
2667  if (aborted_) return;
2669  if (chunk_pos_ != 0) {
2670  WriteChunk();
2671  }
2672  stream_->EndOfStream();
2673  }
virtual void EndOfStream()=0
Notify about the end of stream.

References aborted_, chunk_pos_, chunk_size_, DCHECK, v8::OutputStream::EndOfStream(), stream_, and WriteChunk().

Referenced by v8::internal::HeapSnapshotJSONSerializer::SerializeImpl().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MaybeWriteChunk()

void v8::internal::OutputStreamWriter::MaybeWriteChunk ( )
inlineprivate

Definition at line 2695 of file heap-snapshot-generator.cc.

2695  {
2697  if (chunk_pos_ == chunk_size_) {
2698  WriteChunk();
2699  }
2700  }

References chunk_pos_, chunk_size_, DCHECK, and WriteChunk().

Referenced by AddCharacter(), AddNumberImpl(), and AddSubstring().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WriteChunk()

void v8::internal::OutputStreamWriter::WriteChunk ( )
inlineprivate

Definition at line 2701 of file heap-snapshot-generator.cc.

2701  {
2702  if (aborted_) return;
2705  chunk_pos_ = 0;
2706  }
virtual WriteResult WriteAsciiChunk(char *data, int size)=0
Writes the next chunk of snapshot data into the stream.

References aborted_, chunk_, chunk_pos_, v8::OutputStream::kAbort, v8::internal::Vector< T >::start(), stream_, and v8::OutputStream::WriteAsciiChunk().

Referenced by Finalize(), and MaybeWriteChunk().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ aborted_

bool v8::internal::OutputStreamWriter::aborted_
private

Definition at line 2712 of file heap-snapshot-generator.cc.

Referenced by aborted(), Finalize(), and WriteChunk().

◆ chunk_

ScopedVector<char> v8::internal::OutputStreamWriter::chunk_
private

Definition at line 2710 of file heap-snapshot-generator.cc.

Referenced by AddCharacter(), AddNumberImpl(), AddSubstring(), and WriteChunk().

◆ chunk_pos_

int v8::internal::OutputStreamWriter::chunk_pos_
private

◆ chunk_size_

int v8::internal::OutputStreamWriter::chunk_size_
private

◆ stream_

v8::OutputStream* v8::internal::OutputStreamWriter::stream_
private

Definition at line 2708 of file heap-snapshot-generator.cc.

Referenced by Finalize(), and WriteChunk().


The documentation for this class was generated from the following file: