Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(838)

Side by Side Diff: src/typing.h

Issue 19054006: Implement simple effect typing for variables (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comments Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/types.h ('k') | src/typing.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 17 matching lines...) Expand all
28 #ifndef V8_TYPING_H_ 28 #ifndef V8_TYPING_H_
29 #define V8_TYPING_H_ 29 #define V8_TYPING_H_
30 30
31 #include "v8.h" 31 #include "v8.h"
32 32
33 #include "allocation.h" 33 #include "allocation.h"
34 #include "ast.h" 34 #include "ast.h"
35 #include "compiler.h" 35 #include "compiler.h"
36 #include "type-info.h" 36 #include "type-info.h"
37 #include "types.h" 37 #include "types.h"
38 #include "effects.h"
38 #include "zone.h" 39 #include "zone.h"
39 #include "scopes.h" 40 #include "scopes.h"
40 41
41 namespace v8 { 42 namespace v8 {
42 namespace internal { 43 namespace internal {
43 44
44 45
45 class AstTyper: public AstVisitor { 46 class AstTyper: public AstVisitor {
46 public: 47 public:
47 static void Run(CompilationInfo* info); 48 static void Run(CompilationInfo* info);
48 49
49 void* operator new(size_t size, Zone* zone) { 50 void* operator new(size_t size, Zone* zone) {
50 return zone->New(static_cast<int>(size)); 51 return zone->New(static_cast<int>(size));
51 } 52 }
52 void operator delete(void* pointer, Zone* zone) { } 53 void operator delete(void* pointer, Zone* zone) { }
53 void operator delete(void* pointer) { } 54 void operator delete(void* pointer) { }
54 55
55 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); 56 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
56 57
57 private: 58 private:
58 explicit AstTyper(CompilationInfo* info); 59 explicit AstTyper(CompilationInfo* info);
59 60
61 static const int kNoVar = INT_MIN;
62 typedef v8::internal::Effects<int, kNoVar> Effects;
63 typedef v8::internal::NestedEffects<int, kNoVar> Store;
64
60 CompilationInfo* info_; 65 CompilationInfo* info_;
61 TypeFeedbackOracle oracle_; 66 TypeFeedbackOracle oracle_;
67 Store store_;
62 68
63 TypeFeedbackOracle* oracle() { return &oracle_; } 69 TypeFeedbackOracle* oracle() { return &oracle_; }
64 Zone* zone() const { return info_->zone(); } 70 Zone* zone() const { return info_->zone(); }
65 71
66 void NarrowType(Expression* e, Bounds b) { 72 void NarrowType(Expression* e, Bounds b) {
67 e->set_bounds(Bounds::Both(e->bounds(), b, isolate_)); 73 e->set_bounds(Bounds::Both(e->bounds(), b, isolate_));
68 } 74 }
69 void NarrowLowerType(Expression* e, Handle<Type> t) { 75 void NarrowLowerType(Expression* e, Handle<Type> t) {
70 e->set_bounds(Bounds::NarrowLower(e->bounds(), t, isolate_)); 76 e->set_bounds(Bounds::NarrowLower(e->bounds(), t, isolate_));
71 } 77 }
72 78
79 Effects EnterEffects() {
80 store_ = store_.Push();
81 return store_.Top();
82 }
83 void ExitEffects() { store_ = store_.Pop(); }
84
85 int variable_index(Variable* var) {
86 return var->IsStackLocal() ? var->index() :
87 var->IsParameter() ? -var->index() : kNoVar;
88 }
89
73 void VisitDeclarations(ZoneList<Declaration*>* declarations); 90 void VisitDeclarations(ZoneList<Declaration*>* declarations);
74 void VisitStatements(ZoneList<Statement*>* statements); 91 void VisitStatements(ZoneList<Statement*>* statements);
75 92
76 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); 93 #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
77 AST_NODE_LIST(DECLARE_VISIT) 94 AST_NODE_LIST(DECLARE_VISIT)
78 #undef DECLARE_VISIT 95 #undef DECLARE_VISIT
79 96
80 DISALLOW_COPY_AND_ASSIGN(AstTyper); 97 DISALLOW_COPY_AND_ASSIGN(AstTyper);
81 }; 98 };
82 99
83 } } // namespace v8::internal 100 } } // namespace v8::internal
84 101
85 #endif // V8_TYPING_H_ 102 #endif // V8_TYPING_H_
OLDNEW
« no previous file with comments | « src/types.h ('k') | src/typing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698