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

Side by Side Diff: src/ast.cc

Issue 490173002: Take ast node id counting away from Isolate. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 years, 4 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/ast.h ('k') | src/compiler.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/ast.h" 5 #include "src/ast.h"
6 6
7 #include <cmath> // For isfinite. 7 #include <cmath> // For isfinite.
8 #include "src/builtins.h" 8 #include "src/builtins.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/contexts.h" 10 #include "src/contexts.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 const VariableProxy* var_proxy = AsVariableProxy(); 52 const VariableProxy* var_proxy = AsVariableProxy();
53 if (var_proxy == NULL) return false; 53 if (var_proxy == NULL) return false;
54 Variable* var = var_proxy->var(); 54 Variable* var = var_proxy->var();
55 // The global identifier "undefined" is immutable. Everything 55 // The global identifier "undefined" is immutable. Everything
56 // else could be reassigned. 56 // else could be reassigned.
57 return var != NULL && var->location() == Variable::UNALLOCATED && 57 return var != NULL && var->location() == Variable::UNALLOCATED &&
58 var_proxy->raw_name()->IsOneByteEqualTo("undefined"); 58 var_proxy->raw_name()->IsOneByteEqualTo("undefined");
59 } 59 }
60 60
61 61
62 VariableProxy::VariableProxy(Zone* zone, Variable* var, int position) 62 VariableProxy::VariableProxy(Zone* zone, Variable* var, int position,
63 : Expression(zone, position), 63 IdGen* id_gen)
64 : Expression(zone, position, id_gen),
64 name_(var->raw_name()), 65 name_(var->raw_name()),
65 var_(NULL), // Will be set by the call to BindTo. 66 var_(NULL), // Will be set by the call to BindTo.
66 is_this_(var->is_this()), 67 is_this_(var->is_this()),
67 is_assigned_(false), 68 is_assigned_(false),
68 interface_(var->interface()), 69 interface_(var->interface()),
69 variable_feedback_slot_(kInvalidFeedbackSlot) { 70 variable_feedback_slot_(kInvalidFeedbackSlot) {
70 BindTo(var); 71 BindTo(var);
71 } 72 }
72 73
73 74
74 VariableProxy::VariableProxy(Zone* zone, 75 VariableProxy::VariableProxy(Zone* zone, const AstRawString* name, bool is_this,
75 const AstRawString* name, 76 Interface* interface, int position, IdGen* id_gen)
76 bool is_this, 77 : Expression(zone, position, id_gen),
77 Interface* interface,
78 int position)
79 : Expression(zone, position),
80 name_(name), 78 name_(name),
81 var_(NULL), 79 var_(NULL),
82 is_this_(is_this), 80 is_this_(is_this),
83 is_assigned_(false), 81 is_assigned_(false),
84 interface_(interface), 82 interface_(interface),
85 variable_feedback_slot_(kInvalidFeedbackSlot) { 83 variable_feedback_slot_(kInvalidFeedbackSlot) {}
86 }
87 84
88 85
89 void VariableProxy::BindTo(Variable* var) { 86 void VariableProxy::BindTo(Variable* var) {
90 DCHECK(var_ == NULL); // must be bound only once 87 DCHECK(var_ == NULL); // must be bound only once
91 DCHECK(var != NULL); // must bind 88 DCHECK(var != NULL); // must bind
92 DCHECK(!FLAG_harmony_modules || interface_->IsUnified(var->interface())); 89 DCHECK(!FLAG_harmony_modules || interface_->IsUnified(var->interface()));
93 DCHECK((is_this() && var->is_this()) || name_ == var->raw_name()); 90 DCHECK((is_this() && var->is_this()) || name_ == var->raw_name());
94 // Ideally CONST-ness should match. However, this is very hard to achieve 91 // Ideally CONST-ness should match. However, this is very hard to achieve
95 // because we don't know the exact semantics of conflicting (const and 92 // because we don't know the exact semantics of conflicting (const and
96 // non-const) multiple variable declarations, const vars introduced via 93 // non-const) multiple variable declarations, const vars introduced via
97 // eval() etc. Const-ness and variable declarations are a complete mess 94 // eval() etc. Const-ness and variable declarations are a complete mess
98 // in JS. Sigh... 95 // in JS. Sigh...
99 var_ = var; 96 var_ = var;
100 var->set_is_used(); 97 var->set_is_used();
101 } 98 }
102 99
103 100
104 Assignment::Assignment(Zone* zone, 101 Assignment::Assignment(Zone* zone, Token::Value op, Expression* target,
105 Token::Value op, 102 Expression* value, int pos, IdGen* id_gen)
106 Expression* target, 103 : Expression(zone, pos, id_gen),
107 Expression* value,
108 int pos)
109 : Expression(zone, pos),
110 op_(op), 104 op_(op),
111 target_(target), 105 target_(target),
112 value_(value), 106 value_(value),
113 binary_operation_(NULL), 107 binary_operation_(NULL),
114 assignment_id_(GetNextId(zone)), 108 assignment_id_(id_gen->GetNextId()),
115 is_uninitialized_(false), 109 is_uninitialized_(false),
116 store_mode_(STANDARD_STORE) { } 110 store_mode_(STANDARD_STORE) {}
117 111
118 112
119 Token::Value Assignment::binary_op() const { 113 Token::Value Assignment::binary_op() const {
120 switch (op_) { 114 switch (op_) {
121 case Token::ASSIGN_BIT_OR: return Token::BIT_OR; 115 case Token::ASSIGN_BIT_OR: return Token::BIT_OR;
122 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR; 116 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR;
123 case Token::ASSIGN_BIT_AND: return Token::BIT_AND; 117 case Token::ASSIGN_BIT_AND: return Token::BIT_AND;
124 case Token::ASSIGN_SHL: return Token::SHL; 118 case Token::ASSIGN_SHL: return Token::SHL;
125 case Token::ASSIGN_SAR: return Token::SAR; 119 case Token::ASSIGN_SAR: return Token::SAR;
126 case Token::ASSIGN_SHR: return Token::SHR; 120 case Token::ASSIGN_SHR: return Token::SHR;
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 for (int i = 0; i < nodes->length(); i++) { 980 for (int i = 0; i < nodes->length(); i++) {
987 RegExpTree* node = nodes->at(i); 981 RegExpTree* node = nodes->at(i);
988 int node_min_match = node->min_match(); 982 int node_min_match = node->min_match();
989 min_match_ = IncreaseBy(min_match_, node_min_match); 983 min_match_ = IncreaseBy(min_match_, node_min_match);
990 int node_max_match = node->max_match(); 984 int node_max_match = node->max_match();
991 max_match_ = IncreaseBy(max_match_, node_max_match); 985 max_match_ = IncreaseBy(max_match_, node_max_match);
992 } 986 }
993 } 987 }
994 988
995 989
996 CaseClause::CaseClause(Zone* zone, 990 CaseClause::CaseClause(Zone* zone, Expression* label,
997 Expression* label, 991 ZoneList<Statement*>* statements, int pos, IdGen* id_gen)
998 ZoneList<Statement*>* statements, 992 : Expression(zone, pos, id_gen),
999 int pos)
1000 : Expression(zone, pos),
1001 label_(label), 993 label_(label),
1002 statements_(statements), 994 statements_(statements),
1003 compare_type_(Type::None(zone)), 995 compare_type_(Type::None(zone)),
1004 compare_id_(AstNode::GetNextId(zone)), 996 compare_id_(id_gen->GetNextId()),
1005 entry_id_(AstNode::GetNextId(zone)) { 997 entry_id_(id_gen->GetNextId()) {}
1006 }
1007 998
1008 999
1009 #define REGULAR_NODE(NodeType) \ 1000 #define REGULAR_NODE(NodeType) \
1010 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ 1001 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1011 increase_node_count(); \ 1002 increase_node_count(); \
1012 } 1003 }
1013 #define REGULAR_NODE_WITH_FEEDBACK_SLOTS(NodeType) \ 1004 #define REGULAR_NODE_WITH_FEEDBACK_SLOTS(NodeType) \
1014 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ 1005 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1015 increase_node_count(); \ 1006 increase_node_count(); \
1016 add_slot_node(node); \ 1007 add_slot_node(node); \
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 SNPrintF(buffer, "%d", Smi::cast(*value())->value()); 1126 SNPrintF(buffer, "%d", Smi::cast(*value())->value());
1136 str = arr; 1127 str = arr;
1137 } else { 1128 } else {
1138 str = DoubleToCString(value()->Number(), buffer); 1129 str = DoubleToCString(value()->Number(), buffer);
1139 } 1130 }
1140 return isolate_->factory()->NewStringFromAsciiChecked(str); 1131 return isolate_->factory()->NewStringFromAsciiChecked(str);
1141 } 1132 }
1142 1133
1143 1134
1144 } } // namespace v8::internal 1135 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.h ('k') | src/compiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698