V8 Project
v8::internal::SerializedCodeData Class Reference

#include <serialize.h>

+ Collaboration diagram for v8::internal::SerializedCodeData:

Public Member Functions

 SerializedCodeData (ScriptData *data, String *source)
 
 SerializedCodeData (List< byte > *payload, CodeSerializer *cs)
 
 ~SerializedCodeData ()
 
ScriptDataGetScriptData ()
 
Vector< const uint32_tCodeStubKeys () const
 
const bytePayload () const
 
int PayloadLength () const
 
int GetReservation (int space) const
 

Private Member Functions

void SetHeaderValue (int offset, int value)
 
int GetHeaderValue (int offset) const
 
bool IsSane (String *source)
 
int CheckSum (String *source)
 

Private Attributes

ScriptDatascript_data_
 
bool owns_script_data_
 

Static Private Attributes

static const int kCheckSumOffset = 0
 
static const int kNumCodeStubKeysOffset = 1
 
static const int kPayloadLengthOffset = 2
 
static const int kReservationsOffset = 3
 
static const int kHeaderEntries
 
static const int kHeaderSize = kHeaderEntries * kIntSize
 

Detailed Description

Definition at line 628 of file serialize.h.

Constructor & Destructor Documentation

◆ SerializedCodeData() [1/2]

v8::internal::SerializedCodeData::SerializedCodeData ( ScriptData data,
String source 
)
inlineexplicit

Definition at line 631 of file serialize.h.

632  : script_data_(data), owns_script_data_(false) {
634  CHECK(IsSane(source));
635  }
bool IsSane(String *source)
Definition: serialize.cc:2103
#define CHECK(condition)
Definition: logging.h:36
PerThreadAssertScopeDebugOnly< HEAP_ALLOCATION_ASSERT, false > DisallowHeapAllocation
Definition: assert-scope.h:110

References CHECK, and IsSane().

+ Here is the call graph for this function:

◆ SerializedCodeData() [2/2]

v8::internal::SerializedCodeData::SerializedCodeData ( List< byte > *  payload,
CodeSerializer cs 
)

Definition at line 2068 of file serialize.cc.

2069  : owns_script_data_(true) {
2070  DisallowHeapAllocation no_gc;
2071  List<uint32_t>* stub_keys = cs->stub_keys();
2072 
2073  // Calculate sizes.
2074  int num_stub_keys = stub_keys->length();
2075  int stub_keys_size = stub_keys->length() * kInt32Size;
2076  int data_length = kHeaderSize + stub_keys_size + payload->length();
2077 
2078  // Allocate backing store and create result data.
2079  byte* data = NewArray<byte>(data_length);
2080  DCHECK(IsAligned(reinterpret_cast<intptr_t>(data), kPointerAlignment));
2081  script_data_ = new ScriptData(data, data_length);
2083 
2084  // Set header values.
2086  SetHeaderValue(kNumCodeStubKeysOffset, num_stub_keys);
2087  SetHeaderValue(kPayloadLengthOffset, payload->length());
2088  STATIC_ASSERT(NEW_SPACE == 0);
2089  for (int i = 0; i < SerializerDeserializer::kNumberOfSpaces; i++) {
2090  SetHeaderValue(kReservationsOffset + i, cs->CurrentAllocationAddress(i));
2091  }
2092 
2093  // Copy code stub keys.
2094  CopyBytes(data + kHeaderSize, reinterpret_cast<byte*>(stub_keys->begin()),
2095  stub_keys_size);
2096 
2097  // Copy serialized data.
2098  CopyBytes(data + kHeaderSize + stub_keys_size, payload->begin(),
2099  static_cast<size_t>(payload->length()));
2100 }
iterator begin() const
Definition: list.h:74
static const int kPayloadLengthOffset
Definition: serialize.h:696
void SetHeaderValue(int offset, int value)
Definition: serialize.h:676
static const int kReservationsOffset
Definition: serialize.h:697
static const int kCheckSumOffset
Definition: serialize.h:694
int CheckSum(String *source)
Definition: serialize.cc:2109
static const int kNumCodeStubKeysOffset
Definition: serialize.h:695
static const int kHeaderSize
Definition: serialize.h:701
#define DCHECK(condition)
Definition: logging.h:205
const int kInt32Size
Definition: globals.h:125
STATIC_ASSERT(sizeof(CPURegister)==sizeof(Register))
bool IsAligned(T value, U alignment)
Definition: utils.h:123
const intptr_t kPointerAlignment
Definition: globals.h:230
void CopyBytes(uint8_t *target, uint8_t *source)

References v8::internal::ScriptData::AcquireDataOwnership(), v8::internal::List< T, AllocationPolicy >::begin(), CheckSum(), v8::internal::CopyBytes(), v8::internal::cs, DCHECK, v8::internal::IsAligned(), kCheckSumOffset, kHeaderSize, v8::internal::kInt32Size, v8::internal::SerializerDeserializer::kNumberOfSpaces, kNumCodeStubKeysOffset, kPayloadLengthOffset, v8::internal::kPointerAlignment, kReservationsOffset, v8::internal::NEW_SPACE, script_data_, SetHeaderValue(), and v8::internal::STATIC_ASSERT().

+ Here is the call graph for this function:

◆ ~SerializedCodeData()

v8::internal::SerializedCodeData::~SerializedCodeData ( )
inline

Definition at line 640 of file serialize.h.

640  {
641  if (owns_script_data_) delete script_data_;
642  }

References owns_script_data_, and script_data_.

Member Function Documentation

◆ CheckSum()

int v8::internal::SerializedCodeData::CheckSum ( String source)
private

Definition at line 2109 of file serialize.cc.

2109  {
2110  int checksum = Version::Hash();
2111 #ifdef DEBUG
2112  uint32_t seed = static_cast<uint32_t>(checksum);
2113  checksum = static_cast<int>(IteratingStringHasher::Hash(string, seed));
2114 #endif // DEBUG
2115  return checksum;
2116 }
static uint32_t Hash(String *string, uint32_t seed)
Definition: objects-inl.h:6572
static int Hash()
Definition: version.h:19

References v8::internal::Version::Hash(), and v8::internal::IteratingStringHasher::Hash().

Referenced by IsSane(), and SerializedCodeData().

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

◆ CodeStubKeys()

Vector<const uint32_t> v8::internal::SerializedCodeData::CodeStubKeys ( ) const
inline

Definition at line 653 of file serialize.h.

653  {
654  return Vector<const uint32_t>(
655  reinterpret_cast<const uint32_t*>(script_data_->data() + kHeaderSize),
657  }
const byte * data() const
Definition: compiler.h:40
int GetHeaderValue(int offset) const
Definition: serialize.h:681

References v8::internal::ScriptData::data(), GetHeaderValue(), kHeaderSize, kNumCodeStubKeysOffset, and script_data_.

Referenced by v8::internal::CodeSerializer::Deserialize().

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

◆ GetHeaderValue()

int v8::internal::SerializedCodeData::GetHeaderValue ( int  offset) const
inlineprivate

Definition at line 681 of file serialize.h.

681  {
682  return reinterpret_cast<const int*>(script_data_->data())[offset];
683  }

References v8::internal::ScriptData::data(), and script_data_.

Referenced by CodeStubKeys(), GetReservation(), IsSane(), Payload(), and PayloadLength().

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

◆ GetReservation()

int v8::internal::SerializedCodeData::GetReservation ( int  space) const
inline

Definition at line 671 of file serialize.h.

671  {
673  }
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi space(in MBytes)

References GetHeaderValue(), kReservationsOffset, and space().

Referenced by v8::internal::CodeSerializer::Deserialize().

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

◆ GetScriptData()

ScriptData* v8::internal::SerializedCodeData::GetScriptData ( )
inline

Definition at line 645 of file serialize.h.

645  {
646  ScriptData* result = script_data_;
647  script_data_ = NULL;
649  owns_script_data_ = false;
650  return result;
651  }
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL

References DCHECK, NULL, owns_script_data_, and script_data_.

Referenced by v8::internal::CodeSerializer::Serialize().

+ Here is the caller graph for this function:

◆ IsSane()

bool v8::internal::SerializedCodeData::IsSane ( String source)
private

Definition at line 2103 of file serialize.cc.

2103  {
2104  return GetHeaderValue(kCheckSumOffset) == CheckSum(source) &&
2106 }

References CheckSum(), GetHeaderValue(), kCheckSumOffset, v8::internal::SharedFunctionInfo::kSize, and PayloadLength().

Referenced by SerializedCodeData().

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

◆ Payload()

const byte* v8::internal::SerializedCodeData::Payload ( ) const
inline

Definition at line 659 of file serialize.h.

659  {
660  int code_stubs_size = GetHeaderValue(kNumCodeStubKeysOffset) * kInt32Size;
661  return script_data_->data() + kHeaderSize + code_stubs_size;
662  }

References v8::internal::ScriptData::data(), GetHeaderValue(), kHeaderSize, v8::internal::kInt32Size, kNumCodeStubKeysOffset, and script_data_.

Referenced by v8::internal::CodeSerializer::Deserialize(), and PayloadLength().

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

◆ PayloadLength()

int v8::internal::SerializedCodeData::PayloadLength ( ) const
inline

Definition at line 664 of file serialize.h.

664  {
665  int payload_length = GetHeaderValue(kPayloadLengthOffset);
667  Payload() + payload_length);
668  return payload_length;
669  }
int length() const
Definition: compiler.h:41
const byte * Payload() const
Definition: serialize.h:659
#define DCHECK_EQ(v1, v2)
Definition: logging.h:206

References v8::internal::ScriptData::data(), DCHECK_EQ, GetHeaderValue(), kPayloadLengthOffset, v8::internal::ScriptData::length(), Payload(), and script_data_.

Referenced by v8::internal::CodeSerializer::Deserialize(), and IsSane().

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

◆ SetHeaderValue()

void v8::internal::SerializedCodeData::SetHeaderValue ( int  offset,
int  value 
)
inlineprivate

Definition at line 676 of file serialize.h.

676  {
677  reinterpret_cast<int*>(const_cast<byte*>(script_data_->data()))[offset] =
678  value;
679  }

References v8::internal::ScriptData::data(), and script_data_.

Referenced by SerializedCodeData().

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

Member Data Documentation

◆ kCheckSumOffset

const int v8::internal::SerializedCodeData::kCheckSumOffset = 0
staticprivate

Definition at line 694 of file serialize.h.

Referenced by IsSane(), and SerializedCodeData().

◆ kHeaderEntries

const int v8::internal::SerializedCodeData::kHeaderEntries
staticprivate
Initial value:

Definition at line 699 of file serialize.h.

◆ kHeaderSize

const int v8::internal::SerializedCodeData::kHeaderSize = kHeaderEntries * kIntSize
staticprivate

Definition at line 701 of file serialize.h.

Referenced by CodeStubKeys(), Payload(), and SerializedCodeData().

◆ kNumCodeStubKeysOffset

const int v8::internal::SerializedCodeData::kNumCodeStubKeysOffset = 1
staticprivate

Definition at line 695 of file serialize.h.

Referenced by CodeStubKeys(), Payload(), and SerializedCodeData().

◆ kPayloadLengthOffset

const int v8::internal::SerializedCodeData::kPayloadLengthOffset = 2
staticprivate

Definition at line 696 of file serialize.h.

Referenced by PayloadLength(), and SerializedCodeData().

◆ kReservationsOffset

const int v8::internal::SerializedCodeData::kReservationsOffset = 3
staticprivate

Definition at line 697 of file serialize.h.

Referenced by GetReservation(), and SerializedCodeData().

◆ owns_script_data_

bool v8::internal::SerializedCodeData::owns_script_data_
private

Definition at line 708 of file serialize.h.

Referenced by GetScriptData(), and ~SerializedCodeData().

◆ script_data_

ScriptData* v8::internal::SerializedCodeData::script_data_
private

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