V8 Project
v8::internal::AstTyper Class Reference

#include <typing.h>

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

Public Member Functions

void * operator new (size_t size, Zone *zone)
 
void operator delete (void *pointer, Zone *zone)
 
void operator delete (void *pointer)
 
 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS ()
 

Static Public Member Functions

static void Run (CompilationInfo *info)
 

Private Types

typedef v8::internal::Effects< int, kNoVarEffects
 
typedef v8::internal::NestedEffects< int, kNoVarStore
 

Private Member Functions

 AstTyper (CompilationInfo *info)
 
Effect ObservedOnStack (Object *value)
 
void ObserveTypesAtOsrEntry (IterationStatement *stmt)
 
TypeFeedbackOracleoracle ()
 
void NarrowType (Expression *e, Bounds b)
 
void NarrowLowerType (Expression *e, Type *t)
 
Effects EnterEffects ()
 
void ExitEffects ()
 
int parameter_index (int index)
 
int stack_local_index (int index)
 
int variable_index (Variable *var)
 
void VisitDeclarations (ZoneList< Declaration * > *declarations)
 
void VisitStatements (ZoneList< Statement * > *statements)
 
 DISALLOW_COPY_AND_ASSIGN (AstTyper)
 

Private Attributes

CompilationInfoinfo_
 
TypeFeedbackOracle oracle_
 
Store store_
 

Static Private Attributes

static const int kNoVar = INT_MIN
 

Detailed Description

Definition at line 23 of file typing.h.

Member Typedef Documentation

◆ Effects

Definition at line 42 of file typing.h.

◆ Store

Definition at line 43 of file typing.h.

Constructor & Destructor Documentation

◆ AstTyper()

v8::internal::AstTyper::AstTyper ( CompilationInfo info)
explicitprivate

Definition at line 17 of file typing.cc.

18  : info_(info),
19  oracle_(
20  handle(info->closure()->shared()->code()),
21  handle(info->closure()->shared()->feedback_vector()),
22  handle(info->closure()->context()->native_context()),
23  info->zone()),
24  store_(info->zone()) {
25  InitializeAstVisitor(info->zone());
26 }
CompilationInfo * info_
Definition: typing.h:45
TypeFeedbackOracle oracle_
Definition: typing.h:46
Handle< T > handle(T *t, Isolate *isolate)
Definition: handles.h:146

References v8::internal::CompilationInfo::zone().

Referenced by Run().

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

Member Function Documentation

◆ DEFINE_AST_VISITOR_SUBCLASS_MEMBERS()

v8::internal::AstTyper::DEFINE_AST_VISITOR_SUBCLASS_MEMBERS ( )

◆ DISALLOW_COPY_AND_ASSIGN()

v8::internal::AstTyper::DISALLOW_COPY_AND_ASSIGN ( AstTyper  )
private

◆ EnterEffects()

Effects v8::internal::AstTyper::EnterEffects ( )
inlineprivate

Definition at line 58 of file typing.h.

58  {
59  store_ = store_.Push();
60  return store_.Top();
61  }
NestedEffects Push()
Definition: effects.h:320

References v8::internal::NestedEffects< Var, kNoVar >::Push(), and store_.

+ Here is the call graph for this function:

◆ ExitEffects()

void v8::internal::AstTyper::ExitEffects ( )
inlineprivate

Definition at line 62 of file typing.h.

62 { store_ = store_.Pop(); }
NestedEffects Pop()
Definition: effects.h:326

References v8::internal::NestedEffects< Var, kNoVar >::Pop(), and store_.

+ Here is the call graph for this function:

◆ NarrowLowerType()

void v8::internal::AstTyper::NarrowLowerType ( Expression e,
Type t 
)
inlineprivate

Definition at line 54 of file typing.h.

54  {
55  e->set_bounds(Bounds::NarrowLower(e->bounds(), t, zone()));
56  }
static BoundsImpl NarrowLower(BoundsImpl b, TypeHandle t, Region *region)
Definition: types.h:1030

References v8::internal::Expression::bounds(), v8::internal::BoundsImpl< ZoneTypeConfig >::NarrowLower(), and v8::internal::Expression::set_bounds().

+ Here is the call graph for this function:

◆ NarrowType()

void v8::internal::AstTyper::NarrowType ( Expression e,
Bounds  b 
)
inlineprivate

Definition at line 51 of file typing.h.

51  {
52  e->set_bounds(Bounds::Both(e->bounds(), b, zone()));
53  }
static BoundsImpl Both(BoundsImpl b1, BoundsImpl b2, Region *region)
Definition: types.h:1015

References v8::internal::BoundsImpl< ZoneTypeConfig >::Both(), v8::internal::Expression::bounds(), and v8::internal::Expression::set_bounds().

+ Here is the call graph for this function:

◆ ObservedOnStack()

Effect v8::internal::AstTyper::ObservedOnStack ( Object value)
private

Definition at line 64 of file typing.cc.

64  {
65  Type* lower = Type::NowOf(value, zone());
66  return Effect(Bounds(lower, Type::Any(zone())));
67 }
static TypeHandle NowOf(i::Object *value, Region *region)
Definition: types-inl.h:30
TypeImpl< ZoneTypeConfig > Type
BoundsImpl< ZoneTypeConfig > Bounds
Definition: types.h:1047

References v8::internal::TypeImpl< ZoneTypeConfig >::NowOf().

Referenced by ObserveTypesAtOsrEntry().

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

◆ ObserveTypesAtOsrEntry()

void v8::internal::AstTyper::ObserveTypesAtOsrEntry ( IterationStatement stmt)
private

Definition at line 70 of file typing.cc.

70  {
71  if (stmt->OsrEntryId() != info_->osr_ast_id()) return;
72 
74  JavaScriptFrameIterator it(isolate());
75  JavaScriptFrame* frame = it.frame();
76  Scope* scope = info_->scope();
77 
78  // Assert that the frame on the stack belongs to the function we want to OSR.
79  DCHECK_EQ(*info_->closure(), frame->function());
80 
81  int params = scope->num_parameters();
82  int locals = scope->StackLocalCount();
83 
84  // Use sequential composition to achieve desired narrowing.
85  // The receiver is a parameter with index -1.
86  store_.Seq(parameter_index(-1), ObservedOnStack(frame->receiver()));
87  for (int i = 0; i < params; i++) {
88  store_.Seq(parameter_index(i), ObservedOnStack(frame->GetParameter(i)));
89  }
90 
91  for (int i = 0; i < locals; i++) {
92  store_.Seq(stack_local_index(i), ObservedOnStack(frame->GetExpression(i)));
93  }
94 
95 #ifdef OBJECT_PRINT
96  if (FLAG_trace_osr && FLAG_print_scopes) {
97  PrintObserved(scope->receiver(),
98  frame->receiver(),
100 
101  for (int i = 0; i < params; i++) {
102  PrintObserved(scope->parameter(i),
103  frame->GetParameter(i),
105  }
106 
107  ZoneList<Variable*> local_vars(locals, zone());
108  ZoneList<Variable*> context_vars(scope->ContextLocalCount(), zone());
109  scope->CollectStackAndContextLocals(&local_vars, &context_vars);
110  for (int i = 0; i < locals; i++) {
111  PrintObserved(local_vars.at(i),
112  frame->GetExpression(i),
114  }
115  }
116 #endif // OBJECT_PRINT
117 }
int parameter_index(int index)
Definition: typing.h:64
Effect ObservedOnStack(Object *value)
Definition: typing.cc:64
int stack_local_index(int index)
Definition: typing.h:65
BailoutId osr_ast_id() const
Definition: compiler.h:128
Handle< JSFunction > closure() const
Definition: compiler.h:111
void Seq(Var var, Effect effect)
Definition: effects.h:96
Bounds LookupBounds(Var var)
Definition: effects.h:89
#define DCHECK_EQ(v1, v2)
Definition: logging.h:206
PerThreadAssertScopeDebugOnly< HEAP_ALLOCATION_ASSERT, false > DisallowHeapAllocation
Definition: assert-scope.h:110

References v8::internal::List< T, AllocationPolicy >::at(), v8::internal::CompilationInfo::closure(), v8::internal::Scope::CollectStackAndContextLocals(), v8::internal::Scope::ContextLocalCount(), DCHECK_EQ, v8::internal::JavaScriptFrame::function(), v8::internal::StandardFrame::GetExpression(), v8::internal::JavaScriptFrame::GetParameter(), info_, v8::internal::EffectsMixin< Var, Base, Effects >::LookupBounds(), v8::internal::Scope::num_parameters(), ObservedOnStack(), v8::internal::CompilationInfo::osr_ast_id(), v8::internal::IterationStatement::OsrEntryId(), v8::internal::Scope::parameter(), parameter_index(), v8::internal::Scope::receiver(), v8::internal::JavaScriptFrame::receiver(), v8::internal::CompilationInfo::scope(), v8::internal::EffectsMixin< Var, Base, Effects >::Seq(), stack_local_index(), v8::internal::Scope::StackLocalCount(), and store_.

+ Here is the call graph for this function:

◆ operator delete() [1/2]

void v8::internal::AstTyper::operator delete ( void *  pointer)
inline

Definition at line 31 of file typing.h.

31 { }

◆ operator delete() [2/2]

void v8::internal::AstTyper::operator delete ( void *  pointer,
Zone zone 
)
inline

Definition at line 30 of file typing.h.

30 { }

◆ operator new()

void* v8::internal::AstTyper::operator new ( size_t  size,
Zone zone 
)
inline

Definition at line 27 of file typing.h.

27  {
28  return zone->New(static_cast<int>(size));
29  }
enable harmony numeric enable harmony object literal extensions Optimize object size

References size.

◆ oracle()

TypeFeedbackOracle* v8::internal::AstTyper::oracle ( )
inlineprivate

Definition at line 49 of file typing.h.

49 { return &oracle_; }

References oracle_.

◆ parameter_index()

int v8::internal::AstTyper::parameter_index ( int  index)
inlineprivate

Definition at line 64 of file typing.h.

64 { return -index - 2; }

Referenced by ObserveTypesAtOsrEntry(), and variable_index().

+ Here is the caller graph for this function:

◆ Run()

void v8::internal::AstTyper::Run ( CompilationInfo info)
static

Definition at line 36 of file typing.cc.

36  {
37  AstTyper* visitor = new(info->zone()) AstTyper(info);
38  Scope* scope = info->scope();
39 
40  // Handle implicit declaration of the function name in named function
41  // expressions before other declarations.
42  if (scope->is_function_scope() && scope->function() != NULL) {
43  RECURSE(visitor->VisitVariableDeclaration(scope->function()));
44  }
45  RECURSE(visitor->VisitDeclarations(scope->declarations()));
46  RECURSE(visitor->VisitStatements(info->function()->body()));
47 }
AstTyper(CompilationInfo *info)
Definition: typing.cc:17
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
#define RECURSE(call)
Definition: typing.cc:120

References AstTyper(), v8::internal::Scope::declarations(), v8::internal::CompilationInfo::function(), v8::internal::Scope::function(), v8::internal::Scope::is_function_scope(), NULL, RECURSE, v8::internal::CompilationInfo::scope(), VisitDeclarations(), VisitStatements(), and v8::internal::CompilationInfo::zone().

Referenced by v8::internal::OptimizedCompileJob::CreateGraph(), and v8::internal::HOptimizedGraphBuilder::TryInline().

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

◆ stack_local_index()

int v8::internal::AstTyper::stack_local_index ( int  index)
inlineprivate

Definition at line 65 of file typing.h.

65 { return index; }

Referenced by ObserveTypesAtOsrEntry(), and variable_index().

+ Here is the caller graph for this function:

◆ variable_index()

int v8::internal::AstTyper::variable_index ( Variable var)
inlineprivate

Definition at line 67 of file typing.h.

67  {
68  // Stack locals have the range [0 .. l]
69  // Parameters have the range [-1 .. p]
70  // We map this to [-p-2 .. -1, 0 .. l]
71  return var->IsStackLocal() ? stack_local_index(var->index()) :
72  var->IsParameter() ? parameter_index(var->index()) : kNoVar;
73  }
static const int kNoVar
Definition: typing.h:41

References v8::internal::Variable::index(), v8::internal::Variable::IsParameter(), v8::internal::Variable::IsStackLocal(), kNoVar, parameter_index(), and stack_local_index().

+ Here is the call graph for this function:

◆ VisitDeclarations()

void v8::internal::AstTyper::VisitDeclarations ( ZoneList< Declaration * > *  declarations)
private

Definition at line 732 of file typing.cc.

732  {
733  for (int i = 0; i < decls->length(); ++i) {
734  Declaration* decl = decls->at(i);
735  RECURSE(Visit(decl));
736  }
737 }

References v8::internal::List< T, AllocationPolicy >::at(), and RECURSE.

Referenced by Run().

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

◆ VisitStatements()

void v8::internal::AstTyper::VisitStatements ( ZoneList< Statement * > *  statements)
private

Definition at line 128 of file typing.cc.

128  {
129  for (int i = 0; i < stmts->length(); ++i) {
130  Statement* stmt = stmts->at(i);
131  RECURSE(Visit(stmt));
132  if (stmt->IsJump()) break;
133  }
134 }

References v8::internal::List< T, AllocationPolicy >::at(), v8::internal::Statement::IsJump(), and RECURSE.

Referenced by Run().

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

Member Data Documentation

◆ info_

CompilationInfo* v8::internal::AstTyper::info_
private

Definition at line 45 of file typing.h.

Referenced by ObserveTypesAtOsrEntry().

◆ kNoVar

const int v8::internal::AstTyper::kNoVar = INT_MIN
staticprivate

Definition at line 41 of file typing.h.

Referenced by variable_index().

◆ oracle_

TypeFeedbackOracle v8::internal::AstTyper::oracle_
private

Definition at line 46 of file typing.h.

Referenced by oracle().

◆ store_

Store v8::internal::AstTyper::store_
private

Definition at line 47 of file typing.h.

Referenced by EnterEffects(), ExitEffects(), and ObserveTypesAtOsrEntry().


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