V8 Project
typing.h
Go to the documentation of this file.
1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_TYPING_H_
6 #define V8_TYPING_H_
7 
8 #include "src/v8.h"
9 
10 #include "src/allocation.h"
11 #include "src/ast.h"
12 #include "src/compiler.h"
13 #include "src/effects.h"
14 #include "src/scopes.h"
15 #include "src/type-info.h"
16 #include "src/types.h"
17 #include "src/zone.h"
18 
19 namespace v8 {
20 namespace internal {
21 
22 
23 class AstTyper: public AstVisitor {
24  public:
25  static void Run(CompilationInfo* info);
26 
27  void* operator new(size_t size, Zone* zone) {
28  return zone->New(static_cast<int>(size));
29  }
30  void operator delete(void* pointer, Zone* zone) { }
31  void operator delete(void* pointer) { }
32 
34 
35  private:
36  explicit AstTyper(CompilationInfo* info);
37 
40 
41  static const int kNoVar = INT_MIN;
44 
48 
50 
52  e->set_bounds(Bounds::Both(e->bounds(), b, zone()));
53  }
55  e->set_bounds(Bounds::NarrowLower(e->bounds(), t, zone()));
56  }
57 
59  store_ = store_.Push();
60  return store_.Top();
61  }
62  void ExitEffects() { store_ = store_.Pop(); }
63 
64  int parameter_index(int index) { return -index - 2; }
65  int stack_local_index(int index) { return index; }
66 
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  }
74 
75  void VisitDeclarations(ZoneList<Declaration*>* declarations);
76  void VisitStatements(ZoneList<Statement*>* statements);
77 
78 #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
80 #undef DECLARE_VISIT
81 
83 };
84 
85 } } // namespace v8::internal
86 
87 #endif // V8_TYPING_H_
#define AST_NODE_LIST(V)
Definition: ast.h:102
void NarrowType(Expression *e, Bounds b)
Definition: typing.h:51
int parameter_index(int index)
Definition: typing.h:64
v8::internal::NestedEffects< int, kNoVar > Store
Definition: typing.h:43
int variable_index(Variable *var)
Definition: typing.h:67
CompilationInfo * info_
Definition: typing.h:45
void ObserveTypesAtOsrEntry(IterationStatement *stmt)
Definition: typing.cc:70
TypeFeedbackOracle oracle_
Definition: typing.h:46
v8::internal::Effects< int, kNoVar > Effects
Definition: typing.h:42
void NarrowLowerType(Expression *e, Type *t)
Definition: typing.h:54
AstTyper(CompilationInfo *info)
Definition: typing.cc:17
static const int kNoVar
Definition: typing.h:41
DISALLOW_COPY_AND_ASSIGN(AstTyper)
Effect ObservedOnStack(Object *value)
Definition: typing.cc:64
TypeFeedbackOracle * oracle()
Definition: typing.h:49
static void Run(CompilationInfo *info)
Definition: typing.cc:36
void VisitStatements(ZoneList< Statement * > *statements)
Definition: typing.cc:128
int stack_local_index(int index)
Definition: typing.h:65
Effects EnterEffects()
Definition: typing.h:58
void VisitDeclarations(ZoneList< Declaration * > *declarations)
Definition: typing.cc:732
Bounds bounds() const
Definition: ast.h:353
void set_bounds(Bounds bounds)
Definition: ast.h:354
NestedEffects Pop()
Definition: effects.h:326
NestedEffects Push()
Definition: effects.h:320
bool IsParameter() const
Definition: variables.h:94
bool IsStackLocal() const
Definition: variables.h:95
enable harmony numeric enable harmony object literal extensions Optimize object size
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20
static BoundsImpl NarrowLower(BoundsImpl b, TypeHandle t, Region *region)
Definition: types.h:1030
static BoundsImpl Both(BoundsImpl b1, BoundsImpl b2, Region *region)
Definition: types.h:1015
#define DECLARE_VISIT(type)
Definition: typing.h:78