V8 Project
v8::internal::AstValueFactory Class Reference

#include <ast-value-factory.h>

+ Collaboration diagram for v8::internal::AstValueFactory:

Public Member Functions

 AstValueFactory (Zone *zone, uint32_t hash_seed)
 
const AstRawStringGetOneByteString (Vector< const uint8_t > literal)
 
const AstRawStringGetOneByteString (const char *string)
 
const AstRawStringGetTwoByteString (Vector< const uint16_t > literal)
 
const AstRawStringGetString (Handle< String > literal)
 
const AstConsStringNewConsString (const AstString *left, const AstString *right)
 
void Internalize (Isolate *isolate)
 
bool IsInternalized ()
 
const AstValueNewString (const AstRawString *string)
 
const AstValueNewSymbol (const char *name)
 
const AstValueNewNumber (double number)
 
const AstValueNewSmi (int number)
 
const AstValueNewBoolean (bool b)
 
const AstValueNewStringList (ZoneList< const AstRawString * > *strings)
 
const AstValueNewNull ()
 
const AstValueNewUndefined ()
 
const AstValueNewTheHole ()
 

Private Member Functions

const AstRawStringGetString (uint32_t hash, bool is_one_byte, Vector< const byte > literal_bytes)
 

Private Attributes

HashMap string_table_
 
List< AstValue * > values_
 
List< AstString * > strings_
 
Zonezone_
 
Isolateisolate_
 
uint32_t hash_seed_
 

Detailed Description

Definition at line 268 of file ast-value-factory.h.

Constructor & Destructor Documentation

◆ AstValueFactory()

v8::internal::AstValueFactory::AstValueFactory ( Zone zone,
uint32_t  hash_seed 
)
inline

Definition at line 270 of file ast-value-factory.h.

272  zone_(zone),
273  isolate_(NULL),
274  hash_seed_(hash_seed) {
275 #define F(name, str) \
276  name##_string_ = NULL;
278 #undef F
279  }
#define STRING_CONSTANTS(F)
static bool Compare(void *a, void *b)
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 v8::internal::F, and STRING_CONSTANTS.

Member Function Documentation

◆ GetOneByteString() [1/2]

const AstRawString* v8::internal::AstValueFactory::GetOneByteString ( const char *  string)
inline

Definition at line 282 of file ast-value-factory.h.

282  {
283  return GetOneByteString(Vector<const uint8_t>(
284  reinterpret_cast<const uint8_t*>(string), StrLength(string)));
285  }
const AstRawString * GetOneByteString(Vector< const uint8_t > literal)
int StrLength(const char *string)
Definition: vector.h:147

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

+ Here is the call graph for this function:

◆ GetOneByteString() [2/2]

const AstRawString * v8::internal::AstValueFactory::GetOneByteString ( Vector< const uint8_t >  literal)

Definition at line 233 of file ast-value-factory.cc.

234  {
235  uint32_t hash = StringHasher::HashSequentialString<uint8_t>(
236  literal.start(), literal.length(), hash_seed_);
237  return GetString(hash, true, literal);
238 }
const AstRawString * GetString(Handle< String > literal)

References GetString(), hash_seed_, v8::internal::Vector< T >::length(), and v8::internal::Vector< T >::start().

Referenced by v8::internal::Scanner::CurrentSymbol(), v8::internal::ParserTraits::GetNumberAsSymbol(), GetOneByteString(), GetString(), v8::internal::ParserTraits::NewThrowError(), and v8::internal::Scanner::NextSymbol().

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

◆ GetString() [1/2]

const AstRawString * v8::internal::AstValueFactory::GetString ( Handle< String literal)

Definition at line 249 of file ast-value-factory.cc.

249  {
251  String::FlatContent content = literal->GetFlatContent();
252  if (content.IsOneByte()) {
253  return GetOneByteString(content.ToOneByteVector());
254  }
255  DCHECK(content.IsTwoByte());
256  return GetTwoByteString(content.ToUC16Vector());
257 }
const AstRawString * GetTwoByteString(Vector< const uint16_t > literal)
#define DCHECK(condition)
Definition: logging.h:205
PerThreadAssertScopeDebugOnly< HEAP_ALLOCATION_ASSERT, false > DisallowHeapAllocation
Definition: assert-scope.h:110

References DCHECK, GetOneByteString(), GetTwoByteString(), v8::internal::String::FlatContent::IsOneByte(), v8::internal::String::FlatContent::IsTwoByte(), v8::internal::String::FlatContent::ToOneByteVector(), and v8::internal::String::FlatContent::ToUC16Vector().

Referenced by v8::internal::Scope::DeserializeScopeChain(), GetOneByteString(), GetTwoByteString(), and v8::internal::Parser::ParseLazy().

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

◆ GetString() [2/2]

const AstRawString * v8::internal::AstValueFactory::GetString ( uint32_t  hash,
bool  is_one_byte,
Vector< const byte literal_bytes 
)
private

Definition at line 383 of file ast-value-factory.cc.

384  {
385  // literal_bytes here points to whatever the user passed, and this is OK
386  // because we use vector_compare (which checks the contents) to compare
387  // against the AstRawStrings which are in the string_table_. We should not
388  // return this AstRawString.
389  AstRawString key(is_one_byte, literal_bytes, hash);
390  HashMap::Entry* entry = string_table_.Lookup(&key, hash, true);
391  if (entry->value == NULL) {
392  // Copy literal contents for later comparison.
393  int length = literal_bytes.length();
394  byte* new_literal_bytes = zone_->NewArray<byte>(length);
395  memcpy(new_literal_bytes, literal_bytes.start(), length);
396  AstRawString* new_string = new (zone_) AstRawString(
397  is_one_byte, Vector<const byte>(new_literal_bytes, length), hash);
398  entry->key = new_string;
399  strings_.Add(new_string);
400  if (isolate_) {
401  new_string->Internalize(isolate_);
402  }
403  entry->value = reinterpret_cast<void*>(1);
404  }
405  return reinterpret_cast<AstRawString*>(entry->key);
406 }
Entry * Lookup(void *key, uint32_t hash, bool insert, AllocationPolicy allocator=AllocationPolicy())
Definition: hashmap.h:114
T * start() const
Definition: vector.h:47
int length() const
Definition: vector.h:41
T * NewArray(int length)
Definition: zone.h:46

References v8::internal::AstRawString::Internalize(), isolate_, v8::internal::Vector< T >::length(), v8::internal::TemplateHashMapImpl< AllocationPolicy >::Lookup(), v8::internal::Zone::NewArray(), NULL, v8::internal::Vector< T >::start(), string_table_, strings_, and zone_.

+ Here is the call graph for this function:

◆ GetTwoByteString()

const AstRawString * v8::internal::AstValueFactory::GetTwoByteString ( Vector< const uint16_t >  literal)

Definition at line 241 of file ast-value-factory.cc.

242  {
243  uint32_t hash = StringHasher::HashSequentialString<uint16_t>(
244  literal.start(), literal.length(), hash_seed_);
245  return GetString(hash, false, Vector<const byte>::cast(literal));
246 }
static Vector< const byte > cast(Vector< S > input)
Definition: vector.h:98

References GetString(), hash_seed_, v8::internal::Vector< T >::length(), and v8::internal::Vector< T >::start().

Referenced by v8::internal::Scanner::CurrentSymbol(), GetString(), and v8::internal::Scanner::NextSymbol().

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

◆ Internalize()

void v8::internal::AstValueFactory::Internalize ( Isolate isolate)

Definition at line 273 of file ast-value-factory.cc.

273  {
274  if (isolate_) {
275  // Everything is already internalized.
276  return;
277  }
278  // Strings need to be internalized before values, because values refer to
279  // strings.
280  for (int i = 0; i < strings_.length(); ++i) {
281  strings_[i]->Internalize(isolate);
282  }
283  for (int i = 0; i < values_.length(); ++i) {
284  values_[i]->Internalize(isolate);
285  }
286  isolate_ = isolate;
287 }

References isolate_, strings_, and values_.

Referenced by v8::internal::Parser::DoParseProgram(), v8::internal::Parser::Internalize(), and v8::internal::Parser::Parse().

+ Here is the caller graph for this function:

◆ IsInternalized()

bool v8::internal::AstValueFactory::IsInternalized ( )
inline

Definition at line 292 of file ast-value-factory.h.

292  {
293  return isolate_ != NULL;
294  }

References isolate_, and NULL.

◆ NewBoolean()

const AstValue * v8::internal::AstValueFactory::NewBoolean ( bool  b)

Definition at line 332 of file ast-value-factory.cc.

332  {
333  AstValue* value = new (zone_) AstValue(b);
334  if (isolate_) {
335  value->Internalize(isolate_);
336  }
337  values_.Add(value);
338  return value;
339 }

References v8::internal::AstValue::Internalize(), isolate_, values_, and zone_.

+ Here is the call graph for this function:

◆ NewConsString()

const AstConsString * v8::internal::AstValueFactory::NewConsString ( const AstString left,
const AstString right 
)

Definition at line 260 of file ast-value-factory.cc.

261  {
262  // This Vector will be valid as long as the Collector is alive (meaning that
263  // the AstRawString will not be moved).
264  AstConsString* new_string = new (zone_) AstConsString(left, right);
265  strings_.Add(new_string);
266  if (isolate_) {
267  new_string->Internalize(isolate_);
268  }
269  return new_string;
270 }

References v8::internal::AstConsString::Internalize(), isolate_, strings_, and zone_.

Referenced by v8::internal::FuncNameInferrer::MakeNameFromStackHelper().

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

◆ NewNull()

const AstValue * v8::internal::AstValueFactory::NewNull ( )

Definition at line 353 of file ast-value-factory.cc.

353  {
354  AstValue* value = new (zone_) AstValue(AstValue::NULL_TYPE);
355  if (isolate_) {
356  value->Internalize(isolate_);
357  }
358  values_.Add(value);
359  return value;
360 }

References v8::internal::AstValue::Internalize(), isolate_, v8::internal::AstValue::NULL_TYPE, values_, and zone_.

+ Here is the call graph for this function:

◆ NewNumber()

const AstValue * v8::internal::AstValueFactory::NewNumber ( double  number)

Definition at line 311 of file ast-value-factory.cc.

311  {
312  AstValue* value = new (zone_) AstValue(number);
313  if (isolate_) {
314  value->Internalize(isolate_);
315  }
316  values_.Add(value);
317  return value;
318 }

References v8::internal::AstValue::Internalize(), isolate_, values_, and zone_.

+ Here is the call graph for this function:

◆ NewSmi()

const AstValue * v8::internal::AstValueFactory::NewSmi ( int  number)

Definition at line 321 of file ast-value-factory.cc.

321  {
322  AstValue* value =
323  new (zone_) AstValue(AstValue::SMI, number);
324  if (isolate_) {
325  value->Internalize(isolate_);
326  }
327  values_.Add(value);
328  return value;
329 }

References v8::internal::AstValue::Internalize(), isolate_, v8::internal::AstValue::SMI, values_, and zone_.

+ Here is the call graph for this function:

◆ NewString()

const AstValue * v8::internal::AstValueFactory::NewString ( const AstRawString string)

Definition at line 290 of file ast-value-factory.cc.

290  {
291  AstValue* value = new (zone_) AstValue(string);
292  DCHECK(string != NULL);
293  if (isolate_) {
294  value->Internalize(isolate_);
295  }
296  values_.Add(value);
297  return value;
298 }

References DCHECK, v8::internal::AstValue::Internalize(), isolate_, NULL, values_, and zone_.

+ Here is the call graph for this function:

◆ NewStringList()

const AstValue * v8::internal::AstValueFactory::NewStringList ( ZoneList< const AstRawString * > *  strings)

Definition at line 342 of file ast-value-factory.cc.

343  {
344  AstValue* value = new (zone_) AstValue(strings);
345  if (isolate_) {
346  value->Internalize(isolate_);
347  }
348  values_.Add(value);
349  return value;
350 }

References v8::internal::AstValue::Internalize(), isolate_, values_, and zone_.

+ Here is the call graph for this function:

◆ NewSymbol()

const AstValue * v8::internal::AstValueFactory::NewSymbol ( const char *  name)

Definition at line 301 of file ast-value-factory.cc.

301  {
302  AstValue* value = new (zone_) AstValue(name);
303  if (isolate_) {
304  value->Internalize(isolate_);
305  }
306  values_.Add(value);
307  return value;
308 }
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 the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in name

References v8::internal::AstValue::Internalize(), isolate_, name, values_, and zone_.

+ Here is the call graph for this function:

◆ NewTheHole()

const AstValue * v8::internal::AstValueFactory::NewTheHole ( )

Definition at line 373 of file ast-value-factory.cc.

373  {
374  AstValue* value = new (zone_) AstValue(AstValue::THE_HOLE);
375  if (isolate_) {
376  value->Internalize(isolate_);
377  }
378  values_.Add(value);
379  return value;
380 }

References v8::internal::AstValue::Internalize(), isolate_, v8::internal::AstValue::THE_HOLE, values_, and zone_.

+ Here is the call graph for this function:

◆ NewUndefined()

const AstValue * v8::internal::AstValueFactory::NewUndefined ( )

Definition at line 363 of file ast-value-factory.cc.

363  {
364  AstValue* value = new (zone_) AstValue(AstValue::UNDEFINED);
365  if (isolate_) {
366  value->Internalize(isolate_);
367  }
368  values_.Add(value);
369  return value;
370 }

References v8::internal::AstValue::Internalize(), isolate_, v8::internal::AstValue::UNDEFINED, values_, and zone_.

+ Here is the call graph for this function:

Member Data Documentation

◆ hash_seed_

uint32_t v8::internal::AstValueFactory::hash_seed_
private

Definition at line 333 of file ast-value-factory.h.

Referenced by GetOneByteString(), and GetTwoByteString().

◆ isolate_

Isolate* v8::internal::AstValueFactory::isolate_
private

◆ string_table_

HashMap v8::internal::AstValueFactory::string_table_
private

Definition at line 325 of file ast-value-factory.h.

Referenced by GetString().

◆ strings_

List<AstString*> v8::internal::AstValueFactory::strings_
private

Definition at line 329 of file ast-value-factory.h.

Referenced by GetString(), Internalize(), and NewConsString().

◆ values_

List<AstValue*> v8::internal::AstValueFactory::values_
private

◆ zone_

Zone* v8::internal::AstValueFactory::zone_
private

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