V8 Project
v8::internal::ParseData Class Reference

#include <parser.h>

+ Collaboration diagram for v8::internal::ParseData:

Public Member Functions

 ParseData (ScriptData *script_data)
 
void Initialize ()
 
FunctionEntry GetFunctionEntry (int start)
 
int FunctionCount ()
 
bool HasError ()
 
unsigned * Data ()
 

Private Member Functions

bool IsSane ()
 
unsigned Magic ()
 
unsigned Version ()
 
int FunctionsSize ()
 
int Length () const
 
 DISALLOW_COPY_AND_ASSIGN (ParseData)
 

Private Attributes

ScriptDatascript_data_
 
int function_index_
 

Detailed Description

Definition at line 63 of file parser.h.

Constructor & Destructor Documentation

◆ ParseData()

v8::internal::ParseData::ParseData ( ScriptData script_data)
inlineexplicit

Definition at line 65 of file parser.h.

65  : script_data_(script_data) {
66  CHECK(IsAligned(script_data->length(), sizeof(unsigned)));
67  CHECK(IsSane());
68  }
ScriptData * script_data_
Definition: parser.h:89
#define CHECK(condition)
Definition: logging.h:36
bool IsAligned(T value, U alignment)
Definition: utils.h:123

References CHECK, v8::internal::IsAligned(), IsSane(), and v8::internal::ScriptData::length().

+ Here is the call graph for this function:

Member Function Documentation

◆ Data()

unsigned* v8::internal::ParseData::Data ( )
inline

Definition at line 75 of file parser.h.

75  { // Writable data as unsigned int array.
76  return reinterpret_cast<unsigned*>(const_cast<byte*>(script_data_->data()));
77  }
const byte * data() const
Definition: compiler.h:40

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

Referenced by FunctionsSize(), GetFunctionEntry(), HasError(), Magic(), and Version().

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

◆ DISALLOW_COPY_AND_ASSIGN()

v8::internal::ParseData::DISALLOW_COPY_AND_ASSIGN ( ParseData  )
private

◆ FunctionCount()

int v8::internal::ParseData::FunctionCount ( )

Definition at line 200 of file parser.cc.

200  {
201  int functions_size = FunctionsSize();
202  if (functions_size < 0) return 0;
203  if (functions_size % FunctionEntry::kSize != 0) return 0;
204  return functions_size / FunctionEntry::kSize;
205 }

References FunctionsSize().

+ Here is the call graph for this function:

◆ FunctionsSize()

int v8::internal::ParseData::FunctionsSize ( )
private

Definition at line 252 of file parser.cc.

252  {
253  return static_cast<int>(Data()[PreparseDataConstants::kFunctionsSizeOffset]);
254 }
unsigned * Data()
Definition: parser.h:75

References Data(), and v8::internal::PreparseDataConstants::kFunctionsSizeOffset.

Referenced by FunctionCount(), and IsSane().

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

◆ GetFunctionEntry()

FunctionEntry v8::internal::ParseData::GetFunctionEntry ( int  start)

Definition at line 186 of file parser.cc.

186  {
187  // The current pre-data entry must be a FunctionEntry with the given
188  // start position.
189  if ((function_index_ + FunctionEntry::kSize <= Length()) &&
190  (static_cast<int>(Data()[function_index_]) == start)) {
191  int index = function_index_;
192  function_index_ += FunctionEntry::kSize;
193  Vector<unsigned> subvector(&(Data()[index]), FunctionEntry::kSize);
194  return FunctionEntry(subvector);
195  }
196  return FunctionEntry();
197 }
int Length() const
Definition: parser.h:84

References Data(), function_index_, and Length().

Referenced by v8::internal::Parser::SkipLazyFunctionBody().

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

◆ HasError()

bool v8::internal::ParseData::HasError ( )

Definition at line 237 of file parser.cc.

237  {
239 }

References Data(), and v8::internal::PreparseDataConstants::kHasErrorOffset.

Referenced by IsSane().

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

◆ Initialize()

void v8::internal::ParseData::Initialize ( )

Definition at line 228 of file parser.cc.

228  {
229  // Prepares state for use.
230  int data_length = Length();
231  if (data_length >= PreparseDataConstants::kHeaderSize) {
233  }
234 }

References function_index_, v8::internal::PreparseDataConstants::kHeaderSize, and Length().

Referenced by v8::internal::Parser::ParseProgram().

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

◆ IsSane()

bool v8::internal::ParseData::IsSane ( )
private

Definition at line 208 of file parser.cc.

208  {
209  // Check that the header data is valid and doesn't specify
210  // point to positions outside the store.
211  int data_length = Length();
212  if (data_length < PreparseDataConstants::kHeaderSize) return false;
213  if (Magic() != PreparseDataConstants::kMagicNumber) return false;
214  if (Version() != PreparseDataConstants::kCurrentVersion) return false;
215  if (HasError()) return false;
216  // Check that the space allocated for function entries is sane.
217  int functions_size = FunctionsSize();
218  if (functions_size < 0) return false;
219  if (functions_size % FunctionEntry::kSize != 0) return false;
220  // Check that the total size has room for header and function entries.
221  int minimum_size =
222  PreparseDataConstants::kHeaderSize + functions_size;
223  if (data_length < minimum_size) return false;
224  return true;
225 }
unsigned Version()
Definition: parser.cc:247

References FunctionsSize(), HasError(), v8::internal::PreparseDataConstants::kCurrentVersion, v8::internal::PreparseDataConstants::kHeaderSize, v8::internal::PreparseDataConstants::kMagicNumber, Length(), Magic(), and Version().

Referenced by ParseData().

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

◆ Length()

int v8::internal::ParseData::Length ( ) const
inlineprivate

Definition at line 84 of file parser.h.

84  {
85  // Script data length is already checked to be a multiple of unsigned size.
86  return script_data_->length() / sizeof(unsigned);
87  }
int length() const
Definition: compiler.h:41

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

Referenced by GetFunctionEntry(), Initialize(), and IsSane().

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

◆ Magic()

unsigned v8::internal::ParseData::Magic ( )
private

Definition at line 242 of file parser.cc.

242  {
244 }

References Data(), and v8::internal::PreparseDataConstants::kMagicOffset.

Referenced by IsSane().

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

◆ Version()

unsigned v8::internal::ParseData::Version ( )
private

Definition at line 247 of file parser.cc.

247  {
249 }

References Data(), and v8::internal::PreparseDataConstants::kVersionOffset.

Referenced by IsSane().

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

Member Data Documentation

◆ function_index_

int v8::internal::ParseData::function_index_
private

Definition at line 90 of file parser.h.

Referenced by GetFunctionEntry(), and Initialize().

◆ script_data_

ScriptData* v8::internal::ParseData::script_data_
private

Definition at line 89 of file parser.h.

Referenced by Data(), and Length().


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