V8 Project
v8::internal::FuncNameInferrer Class Reference

#include <func-name-inferrer.h>

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

Classes

struct  Name
 

Public Member Functions

 FuncNameInferrer (AstValueFactory *ast_value_factory, Zone *zone)
 
bool IsOpen () const
 
void PushEnclosingName (const AstRawString *name)
 
void Enter ()
 
void PushLiteralName (const AstRawString *name)
 
void PushVariableName (const AstRawString *name)
 
void AddFunction (FunctionLiteral *func_to_infer)
 
void RemoveLastFunction ()
 
void Infer ()
 
void Leave ()
 
- 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  NameType { kEnclosingConstructorName , kLiteralName , kVariableName }
 

Private Member Functions

Zonezone () const
 
const AstStringMakeNameFromStack ()
 
const AstStringMakeNameFromStackHelper (int pos, const AstString *prev)
 
void InferFunctionsNames ()
 
 DISALLOW_COPY_AND_ASSIGN (FuncNameInferrer)
 

Private Attributes

AstValueFactoryast_value_factory_
 
ZoneList< intentries_stack_
 
ZoneList< Namenames_stack_
 
ZoneList< FunctionLiteral * > funcs_to_infer_
 
Zonezone_
 

Detailed Description

Definition at line 29 of file func-name-inferrer.h.

Member Enumeration Documentation

◆ NameType

Enumerator
kEnclosingConstructorName 
kLiteralName 
kVariableName 

Definition at line 79 of file func-name-inferrer.h.

Constructor & Destructor Documentation

◆ FuncNameInferrer()

v8::internal::FuncNameInferrer::FuncNameInferrer ( AstValueFactory ast_value_factory,
Zone zone 
)

Definition at line 15 of file func-name-inferrer.cc.

17  : ast_value_factory_(ast_value_factory),
18  entries_stack_(10, zone),
19  names_stack_(5, zone),
21  zone_(zone) {
22 }
ZoneList< FunctionLiteral * > funcs_to_infer_

Member Function Documentation

◆ AddFunction()

void v8::internal::FuncNameInferrer::AddFunction ( FunctionLiteral *  func_to_infer)
inline

Definition at line 50 of file func-name-inferrer.h.

50  {
51  if (IsOpen()) {
52  funcs_to_infer_.Add(func_to_infer, zone());
53  }
54  }
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
Definition: list-inl.h:17

References v8::internal::List< T, AllocationPolicy >::Add(), funcs_to_infer_, IsOpen(), and zone().

Referenced by v8::internal::ParserTraits::InferFunctionName(), and v8::internal::Parser::ParseFunctionLiteral().

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

◆ DISALLOW_COPY_AND_ASSIGN()

v8::internal::FuncNameInferrer::DISALLOW_COPY_AND_ASSIGN ( FuncNameInferrer  )
private

◆ Enter()

void v8::internal::FuncNameInferrer::Enter ( )
inline

Definition at line 40 of file func-name-inferrer.h.

40  {
41  entries_stack_.Add(names_stack_.length(), zone());
42  }

References v8::internal::List< T, AllocationPolicy >::Add(), entries_stack_, names_stack_, and zone().

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

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

◆ Infer()

void v8::internal::FuncNameInferrer::Infer ( )
inline

Definition at line 63 of file func-name-inferrer.h.

63  {
64  DCHECK(IsOpen());
65  if (!funcs_to_infer_.is_empty()) {
67  }
68  }
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK, funcs_to_infer_, InferFunctionsNames(), and IsOpen().

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

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

◆ InferFunctionsNames()

void v8::internal::FuncNameInferrer::InferFunctionsNames ( )
private

Definition at line 76 of file func-name-inferrer.cc.

76  {
77  const AstString* func_name = MakeNameFromStack();
78  for (int i = 0; i < funcs_to_infer_.length(); ++i) {
79  funcs_to_infer_[i]->set_raw_inferred_name(func_name);
80  }
81  funcs_to_infer_.Rewind(0);
82 }
const AstString * MakeNameFromStack()

References funcs_to_infer_, and MakeNameFromStack().

Referenced by Infer().

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

◆ IsOpen()

bool v8::internal::FuncNameInferrer::IsOpen ( ) const
inline

Definition at line 34 of file func-name-inferrer.h.

34 { return !entries_stack_.is_empty(); }

References entries_stack_.

Referenced by AddFunction(), Infer(), Leave(), PushLiteralName(), PushVariableName(), and RemoveLastFunction().

+ Here is the caller graph for this function:

◆ Leave()

void v8::internal::FuncNameInferrer::Leave ( )
inline

Definition at line 71 of file func-name-inferrer.h.

71  {
72  DCHECK(IsOpen());
73  names_stack_.Rewind(entries_stack_.RemoveLast());
74  if (entries_stack_.is_empty())
75  funcs_to_infer_.Clear();
76  }

References DCHECK, entries_stack_, funcs_to_infer_, IsOpen(), and names_stack_.

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

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

◆ MakeNameFromStack()

const AstString * v8::internal::FuncNameInferrer::MakeNameFromStack ( )
private

Definition at line 49 of file func-name-inferrer.cc.

49  {
50  return MakeNameFromStackHelper(0, ast_value_factory_->empty_string());
51 }
const AstString * MakeNameFromStackHelper(int pos, const AstString *prev)

References ast_value_factory_, and MakeNameFromStackHelper().

Referenced by InferFunctionsNames().

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

◆ MakeNameFromStackHelper()

const AstString * v8::internal::FuncNameInferrer::MakeNameFromStackHelper ( int  pos,
const AstString prev 
)
private

Definition at line 53 of file func-name-inferrer.cc.

54  {
55  if (pos >= names_stack_.length()) return prev;
56  if (pos < names_stack_.length() - 1 &&
57  names_stack_.at(pos).type == kVariableName &&
58  names_stack_.at(pos + 1).type == kVariableName) {
59  // Skip consecutive variable declarations.
60  return MakeNameFromStackHelper(pos + 1, prev);
61  } else {
62  if (prev->length() > 0) {
63  const AstRawString* name = names_stack_.at(pos).name;
64  if (prev->length() + name->length() + 1 > String::kMaxLength) return prev;
65  const AstConsString* curr = ast_value_factory_->NewConsString(
66  ast_value_factory_->dot_string(), name);
67  curr = ast_value_factory_->NewConsString(prev, curr);
68  return MakeNameFromStackHelper(pos + 1, curr);
69  } else {
70  return MakeNameFromStackHelper(pos + 1, names_stack_.at(pos).name);
71  }
72  }
73 }
const AstConsString * NewConsString(const AstString *left, const AstString *right)
static const int kMaxLength
Definition: objects.h:8820
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 ast_value_factory_, v8::internal::String::kMaxLength, kVariableName, v8::internal::AstString::length(), name, names_stack_, and v8::internal::AstValueFactory::NewConsString().

Referenced by MakeNameFromStack().

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

◆ PushEnclosingName()

void v8::internal::FuncNameInferrer::PushEnclosingName ( const AstRawString name)

Definition at line 25 of file func-name-inferrer.cc.

25  {
26  // Enclosing name is a name of a constructor function. To check
27  // that it is really a constructor, we check that it is not empty
28  // and starts with a capital letter.
29  if (!name->IsEmpty() && unibrow::Uppercase::Is(name->FirstCharacter())) {
31  }
32 }
static bool Is(uchar c)
Definition: unicode.cc:421

References unibrow::Uppercase::Is(), kEnclosingConstructorName, name, names_stack_, and zone().

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

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

◆ PushLiteralName()

void v8::internal::FuncNameInferrer::PushLiteralName ( const AstRawString name)

Definition at line 35 of file func-name-inferrer.cc.

35  {
36  if (IsOpen() && name != ast_value_factory_->prototype_string()) {
37  names_stack_.Add(Name(name, kLiteralName), zone());
38  }
39 }

References ast_value_factory_, IsOpen(), kLiteralName, name, names_stack_, and zone().

Referenced by v8::internal::ParserTraits::ExpressionFromString(), v8::internal::ParserTraits::PushLiteralName(), and v8::internal::ParserTraits::PushPropertyName().

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

◆ PushVariableName()

void v8::internal::FuncNameInferrer::PushVariableName ( const AstRawString name)

Definition at line 42 of file func-name-inferrer.cc.

42  {
43  if (IsOpen() && name != ast_value_factory_->dot_result_string()) {
44  names_stack_.Add(Name(name, kVariableName), zone());
45  }
46 }

References ast_value_factory_, IsOpen(), kVariableName, name, names_stack_, and zone().

Referenced by v8::internal::ParserTraits::ExpressionFromIdentifier(), and v8::internal::Parser::ParseVariableDeclarations().

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

◆ RemoveLastFunction()

void v8::internal::FuncNameInferrer::RemoveLastFunction ( )
inline

Definition at line 56 of file func-name-inferrer.h.

56  {
57  if (IsOpen() && !funcs_to_infer_.is_empty()) {
58  funcs_to_infer_.RemoveLast();
59  }
60  }

References funcs_to_infer_, and IsOpen().

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

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

◆ zone()

Zone* v8::internal::FuncNameInferrer::zone ( ) const
inlineprivate

Definition at line 90 of file func-name-inferrer.h.

90 { return zone_; }

References zone_.

Referenced by AddFunction(), Enter(), PushEnclosingName(), PushLiteralName(), and PushVariableName().

+ Here is the caller graph for this function:

Member Data Documentation

◆ ast_value_factory_

AstValueFactory* v8::internal::FuncNameInferrer::ast_value_factory_
private

◆ entries_stack_

ZoneList<int> v8::internal::FuncNameInferrer::entries_stack_
private

Definition at line 103 of file func-name-inferrer.h.

Referenced by Enter(), IsOpen(), and Leave().

◆ funcs_to_infer_

ZoneList<FunctionLiteral*> v8::internal::FuncNameInferrer::funcs_to_infer_
private

◆ names_stack_

ZoneList<Name> v8::internal::FuncNameInferrer::names_stack_
private

◆ zone_

Zone* v8::internal::FuncNameInferrer::zone_
private

Definition at line 106 of file func-name-inferrer.h.

Referenced by zone().


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