V8 Project
v8::internal::AstValue Class Reference

#include <ast-value-factory.h>

+ Inheritance diagram for v8::internal::AstValue:
+ Collaboration diagram for v8::internal::AstValue:

Public Member Functions

bool IsString () const
 
bool IsNumber () const
 
const AstRawStringAsString () const
 
double AsNumber () const
 
bool EqualsString (const AstRawString *string) const
 
bool IsPropertyName () const
 
bool BooleanValue () const
 
void Internalize (Isolate *isolate)
 
Handle< Objectvalue () const
 
- Public Member Functions inherited from v8::internal::ZoneObject
 INLINE (void *operator new(size_t size, Zone *zone))
 
void operator delete (void *, size_t)
 
void operator delete (void *pointer, Zone *zone)
 

Private Types

enum  Type {
  STRING , SYMBOL , NUMBER , SMI ,
  BOOLEAN , STRING_ARRAY , NULL_TYPE , UNDEFINED ,
  THE_HOLE
}
 

Private Member Functions

 AstValue (const AstRawString *s)
 
 AstValue (const char *name)
 
 AstValue (double n)
 
 AstValue (Type t, int i)
 
 AstValue (bool b)
 
 AstValue (ZoneList< const AstRawString * > *s)
 
 AstValue (Type t)
 

Private Attributes

Type type_
 
union {
   const AstRawString *   string_
 
   double   number_
 
   int   smi_
 
   bool   bool_
 
   ZoneList< const AstRawString * > *   strings_
 
   const char *   symbol_name_
 
}; 
 
Handle< Objectvalue_
 

Friends

class AstValueFactory
 

Detailed Description

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

Member Enumeration Documentation

◆ Type

Enumerator
STRING 
SYMBOL 
NUMBER 
SMI 
BOOLEAN 
STRING_ARRAY 
NULL_TYPE 
UNDEFINED 
THE_HOLE 

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

Constructor & Destructor Documentation

◆ AstValue() [1/7]

v8::internal::AstValue::AstValue ( const AstRawString s)
inlineexplicitprivate

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

199 : type_(STRING) { string_ = s; }
const AstRawString * string_

References string_.

◆ AstValue() [2/7]

v8::internal::AstValue::AstValue ( const char *  name)
inlineexplicitprivate

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

201 : type_(SYMBOL) { symbol_name_ = name; }
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 name, and symbol_name_.

◆ AstValue() [3/7]

v8::internal::AstValue::AstValue ( double  n)
inlineexplicitprivate

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

203 : type_(NUMBER) { number_ = n; }

References number_.

◆ AstValue() [4/7]

v8::internal::AstValue::AstValue ( Type  t,
int  i 
)
inlineprivate

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

205  : type_(t) {
206  DCHECK(type_ == SMI);
207  smi_ = i;
208  }
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK, SMI, smi_, and type_.

◆ AstValue() [5/7]

v8::internal::AstValue::AstValue ( bool  b)
inlineexplicitprivate

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

References bool_.

◆ AstValue() [6/7]

v8::internal::AstValue::AstValue ( ZoneList< const AstRawString * > *  s)
inlineexplicitprivate

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

212  : type_(STRING_ARRAY) {
213  strings_ = s;
214  }
ZoneList< const AstRawString * > * strings_

References strings_.

◆ AstValue() [7/7]

v8::internal::AstValue::AstValue ( Type  t)
inlineexplicitprivate

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

216  : type_(t) {
217  DCHECK(t == NULL_TYPE || t == UNDEFINED || t == THE_HOLE);
218  }

References DCHECK, NULL_TYPE, THE_HOLE, and UNDEFINED.

Member Function Documentation

◆ AsNumber()

double v8::internal::AstValue::AsNumber ( ) const
inline

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

156  {
157  if (type_ == NUMBER)
158  return number_;
159  if (type_ == SMI)
160  return smi_;
161  UNREACHABLE();
162  return 0;
163  }
#define UNREACHABLE()
Definition: logging.h:30

References NUMBER, number_, SMI, smi_, type_, and UNREACHABLE.

Referenced by v8::internal::ParserTraits::BuildUnaryExpression().

+ Here is the caller graph for this function:

◆ AsString()

const AstRawString* v8::internal::AstValue::AsString ( ) const
inline

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

149  {
150  if (type_ == STRING)
151  return string_;
152  UNREACHABLE();
153  return 0;
154  }

References STRING, string_, type_, and UNREACHABLE.

◆ BooleanValue()

bool v8::internal::AstValue::BooleanValue ( ) const

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

149  {
150  switch (type_) {
151  case STRING:
152  DCHECK(string_ != NULL);
153  return !string_->IsEmpty();
154  case SYMBOL:
155  UNREACHABLE();
156  break;
157  case NUMBER:
158  return DoubleToBoolean(number_);
159  case SMI:
160  return smi_ != 0;
161  case STRING_ARRAY:
162  UNREACHABLE();
163  break;
164  case BOOLEAN:
165  return bool_;
166  case NULL_TYPE:
167  return false;
168  case THE_HOLE:
169  UNREACHABLE();
170  break;
171  case UNDEFINED:
172  return false;
173  }
174  UNREACHABLE();
175  return false;
176 }
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
bool DoubleToBoolean(double d)
Definition: utils.cc:397

References bool_, BOOLEAN, DCHECK, v8::internal::DoubleToBoolean(), v8::internal::AstString::IsEmpty(), NULL, NULL_TYPE, NUMBER, number_, SMI, smi_, STRING, string_, STRING_ARRAY, SYMBOL, THE_HOLE, type_, UNDEFINED, and UNREACHABLE.

Referenced by v8::internal::ParserTraits::BuildUnaryExpression().

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

◆ EqualsString()

bool v8::internal::AstValue::EqualsString ( const AstRawString string) const
inline

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

165  {
166  return type_ == STRING && string_ == string;
167  }

References STRING, string_, and type_.

◆ Internalize()

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

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

179  {
180  switch (type_) {
181  case STRING:
182  DCHECK(string_ != NULL);
183  // Strings are already internalized.
184  DCHECK(!string_->string().is_null());
185  break;
186  case SYMBOL:
188  isolate, handle(isolate->native_context()->builtins()),
189  symbol_name_).ToHandleChecked();
190  break;
191  case NUMBER:
192  value_ = isolate->factory()->NewNumber(number_, TENURED);
193  break;
194  case SMI:
195  value_ = handle(Smi::FromInt(smi_), isolate);
196  break;
197  case BOOLEAN:
198  if (bool_) {
199  value_ = isolate->factory()->true_value();
200  } else {
201  value_ = isolate->factory()->false_value();
202  }
203  break;
204  case STRING_ARRAY: {
205  DCHECK(strings_ != NULL);
206  Factory* factory = isolate->factory();
207  int len = strings_->length();
208  Handle<FixedArray> elements = factory->NewFixedArray(len, TENURED);
209  for (int i = 0; i < len; i++) {
210  const AstRawString* string = (*strings_)[i];
211  Handle<Object> element = string->string();
212  // Strings are already internalized.
213  DCHECK(!element.is_null());
214  elements->set(i, *element);
215  }
216  value_ =
217  factory->NewJSArrayWithElements(elements, FAST_ELEMENTS, TENURED);
218  break;
219  }
220  case NULL_TYPE:
221  value_ = isolate->factory()->null_value();
222  break;
223  case THE_HOLE:
224  value_ = isolate->factory()->the_hole_value();
225  break;
226  case UNDEFINED:
227  value_ = isolate->factory()->undefined_value();
228  break;
229  }
230 }
Handle< String > string() const
static MUST_USE_RESULT MaybeHandle< Object > GetProperty(LookupIterator *it)
Definition: objects.cc:109
static Smi * FromInt(int value)
Definition: objects-inl.h:1321
Handle< T > handle(T *t, Isolate *isolate)
Definition: handles.h:146

References bool_, BOOLEAN, DCHECK, v8::internal::Isolate::factory(), v8::internal::FAST_ELEMENTS, v8::internal::Smi::FromInt(), v8::internal::Object::GetProperty(), v8::internal::handle(), v8::internal::Handle< T >::is_null(), v8::internal::Isolate::native_context(), NULL, NULL_TYPE, NUMBER, number_, SMI, smi_, v8::internal::AstString::string(), STRING, string_, STRING_ARRAY, strings_, SYMBOL, symbol_name_, v8::internal::TENURED, THE_HOLE, type_, UNDEFINED, and value_.

Referenced by v8::internal::AstValueFactory::NewBoolean(), v8::internal::AstValueFactory::NewNull(), v8::internal::AstValueFactory::NewNumber(), v8::internal::AstValueFactory::NewSmi(), v8::internal::AstValueFactory::NewString(), v8::internal::AstValueFactory::NewStringList(), v8::internal::AstValueFactory::NewSymbol(), v8::internal::AstValueFactory::NewTheHole(), and v8::internal::AstValueFactory::NewUndefined().

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

◆ IsNumber()

bool v8::internal::AstValue::IsNumber ( ) const
inline

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

145  {
146  return type_ == NUMBER || type_ == SMI;
147  }

References NUMBER, SMI, and type_.

Referenced by v8::internal::ParserTraits::BuildUnaryExpression().

+ Here is the caller graph for this function:

◆ IsPropertyName()

bool v8::internal::AstValue::IsPropertyName ( ) const

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

140  {
141  if (type_ == STRING) {
142  uint32_t index;
143  return !string_->AsArrayIndex(&index);
144  }
145  return false;
146 }
bool AsArrayIndex(uint32_t *index) const

References v8::internal::AstRawString::AsArrayIndex(), STRING, string_, and type_.

+ Here is the call graph for this function:

◆ IsString()

bool v8::internal::AstValue::IsString ( ) const
inline

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

141  {
142  return type_ == STRING;
143  }

References STRING, and type_.

◆ value()

Handle<Object> v8::internal::AstValue::value ( ) const
inline

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

176  {
177  if (type_ == STRING) {
178  return string_->string();
179  }
180  DCHECK(!value_.is_null());
181  return value_;
182  }

References DCHECK, v8::internal::AstString::string(), STRING, string_, type_, and value_.

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ AstValueFactory

friend class AstValueFactory
friend

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

Member Data Documentation

◆ 

union { ... }

◆ bool_

bool v8::internal::AstValue::bool_

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

Referenced by AstValue(), BooleanValue(), and Internalize().

◆ number_

double v8::internal::AstValue::number_

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

Referenced by AsNumber(), AstValue(), BooleanValue(), and Internalize().

◆ smi_

int v8::internal::AstValue::smi_

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

Referenced by AsNumber(), AstValue(), BooleanValue(), and Internalize().

◆ string_

const AstRawString* v8::internal::AstValue::string_

◆ strings_

ZoneList<const AstRawString*>* v8::internal::AstValue::strings_

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

Referenced by AstValue(), and Internalize().

◆ symbol_name_

const char* v8::internal::AstValue::symbol_name_

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

Referenced by AstValue(), and Internalize().

◆ type_

Type v8::internal::AstValue::type_
private

◆ value_

Handle<Object> v8::internal::AstValue::value_
private

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

Referenced by Internalize(), and value().


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