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

Side by Side Diff: src/ast.cc

Issue 102563004: Zonify types in compiler frontend (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 6 years, 12 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/code-stubs.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 // 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 VariableProxy* var_proxy = AsVariableProxy(); 75 VariableProxy* var_proxy = AsVariableProxy();
76 if (var_proxy == NULL) return false; 76 if (var_proxy == NULL) return false;
77 Variable* var = var_proxy->var(); 77 Variable* var = var_proxy->var();
78 // The global identifier "undefined" is immutable. Everything 78 // The global identifier "undefined" is immutable. Everything
79 // else could be reassigned. 79 // else could be reassigned.
80 return var != NULL && var->location() == Variable::UNALLOCATED && 80 return var != NULL && var->location() == Variable::UNALLOCATED &&
81 var_proxy->name()->Equals(isolate->heap()->undefined_string()); 81 var_proxy->name()->Equals(isolate->heap()->undefined_string());
82 } 82 }
83 83
84 84
85 VariableProxy::VariableProxy(Isolate* isolate, Variable* var, int position) 85 VariableProxy::VariableProxy(Zone* zone, Variable* var, int position)
86 : Expression(isolate, position), 86 : Expression(zone, position),
87 name_(var->name()), 87 name_(var->name()),
88 var_(NULL), // Will be set by the call to BindTo. 88 var_(NULL), // Will be set by the call to BindTo.
89 is_this_(var->is_this()), 89 is_this_(var->is_this()),
90 is_trivial_(false), 90 is_trivial_(false),
91 is_lvalue_(false), 91 is_lvalue_(false),
92 interface_(var->interface()) { 92 interface_(var->interface()) {
93 BindTo(var); 93 BindTo(var);
94 } 94 }
95 95
96 96
97 VariableProxy::VariableProxy(Isolate* isolate, 97 VariableProxy::VariableProxy(Zone* zone,
98 Handle<String> name, 98 Handle<String> name,
99 bool is_this, 99 bool is_this,
100 Interface* interface, 100 Interface* interface,
101 int position) 101 int position)
102 : Expression(isolate, position), 102 : Expression(zone, position),
103 name_(name), 103 name_(name),
104 var_(NULL), 104 var_(NULL),
105 is_this_(is_this), 105 is_this_(is_this),
106 is_trivial_(false), 106 is_trivial_(false),
107 is_lvalue_(false), 107 is_lvalue_(false),
108 interface_(interface) { 108 interface_(interface) {
109 // Names must be canonicalized for fast equality checks. 109 // Names must be canonicalized for fast equality checks.
110 ASSERT(name->IsInternalizedString()); 110 ASSERT(name->IsInternalizedString());
111 } 111 }
112 112
113 113
114 void VariableProxy::BindTo(Variable* var) { 114 void VariableProxy::BindTo(Variable* var) {
115 ASSERT(var_ == NULL); // must be bound only once 115 ASSERT(var_ == NULL); // must be bound only once
116 ASSERT(var != NULL); // must bind 116 ASSERT(var != NULL); // must bind
117 ASSERT(!FLAG_harmony_modules || interface_->IsUnified(var->interface())); 117 ASSERT(!FLAG_harmony_modules || interface_->IsUnified(var->interface()));
118 ASSERT((is_this() && var->is_this()) || name_.is_identical_to(var->name())); 118 ASSERT((is_this() && var->is_this()) || name_.is_identical_to(var->name()));
119 // Ideally CONST-ness should match. However, this is very hard to achieve 119 // Ideally CONST-ness should match. However, this is very hard to achieve
120 // because we don't know the exact semantics of conflicting (const and 120 // because we don't know the exact semantics of conflicting (const and
121 // non-const) multiple variable declarations, const vars introduced via 121 // non-const) multiple variable declarations, const vars introduced via
122 // eval() etc. Const-ness and variable declarations are a complete mess 122 // eval() etc. Const-ness and variable declarations are a complete mess
123 // in JS. Sigh... 123 // in JS. Sigh...
124 var_ = var; 124 var_ = var;
125 var->set_is_used(true); 125 var->set_is_used(true);
126 } 126 }
127 127
128 128
129 Assignment::Assignment(Isolate* isolate, 129 Assignment::Assignment(Zone* zone,
130 Token::Value op, 130 Token::Value op,
131 Expression* target, 131 Expression* target,
132 Expression* value, 132 Expression* value,
133 int pos) 133 int pos)
134 : Expression(isolate, pos), 134 : Expression(zone, pos),
135 op_(op), 135 op_(op),
136 target_(target), 136 target_(target),
137 value_(value), 137 value_(value),
138 binary_operation_(NULL), 138 binary_operation_(NULL),
139 assignment_id_(GetNextId(isolate)), 139 assignment_id_(GetNextId(zone)),
140 is_uninitialized_(false), 140 is_uninitialized_(false),
141 is_pre_monomorphic_(false), 141 is_pre_monomorphic_(false),
142 store_mode_(STANDARD_STORE) { } 142 store_mode_(STANDARD_STORE) { }
143 143
144 144
145 Token::Value Assignment::binary_op() const { 145 Token::Value Assignment::binary_op() const {
146 switch (op_) { 146 switch (op_) {
147 case Token::ASSIGN_BIT_OR: return Token::BIT_OR; 147 case Token::ASSIGN_BIT_OR: return Token::BIT_OR;
148 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR; 148 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR;
149 case Token::ASSIGN_BIT_AND: return Token::BIT_AND; 149 case Token::ASSIGN_BIT_AND: return Token::BIT_AND;
(...skipping 29 matching lines...) Expand all
179 int FunctionLiteral::end_position() const { 179 int FunctionLiteral::end_position() const {
180 return scope()->end_position(); 180 return scope()->end_position();
181 } 181 }
182 182
183 183
184 LanguageMode FunctionLiteral::language_mode() const { 184 LanguageMode FunctionLiteral::language_mode() const {
185 return scope()->language_mode(); 185 return scope()->language_mode();
186 } 186 }
187 187
188 188
189 ObjectLiteralProperty::ObjectLiteralProperty(Literal* key, 189 ObjectLiteralProperty::ObjectLiteralProperty(
190 Expression* value, 190 Zone* zone, Literal* key, Expression* value) {
191 Isolate* isolate) {
192 emit_store_ = true; 191 emit_store_ = true;
193 key_ = key; 192 key_ = key;
194 value_ = value; 193 value_ = value;
195 Object* k = *key->value(); 194 Object* k = *key->value();
196 if (k->IsInternalizedString() && 195 if (k->IsInternalizedString() &&
197 isolate->heap()->proto_string()->Equals(String::cast(k))) { 196 zone->isolate()->heap()->proto_string()->Equals(String::cast(k))) {
198 kind_ = PROTOTYPE; 197 kind_ = PROTOTYPE;
199 } else if (value_->AsMaterializedLiteral() != NULL) { 198 } else if (value_->AsMaterializedLiteral() != NULL) {
200 kind_ = MATERIALIZED_LITERAL; 199 kind_ = MATERIALIZED_LITERAL;
201 } else if (value_->AsLiteral() != NULL) { 200 } else if (value_->AsLiteral() != NULL) {
202 kind_ = CONSTANT; 201 kind_ = CONSTANT;
203 } else { 202 } else {
204 kind_ = COMPUTED; 203 kind_ = COMPUTED;
205 } 204 }
206 } 205 }
207 206
208 207
209 ObjectLiteralProperty::ObjectLiteralProperty(bool is_getter, 208 ObjectLiteralProperty::ObjectLiteralProperty(
210 FunctionLiteral* value) { 209 Zone* zone, bool is_getter, FunctionLiteral* value) {
211 emit_store_ = true; 210 emit_store_ = true;
212 value_ = value; 211 value_ = value;
213 kind_ = is_getter ? GETTER : SETTER; 212 kind_ = is_getter ? GETTER : SETTER;
214 } 213 }
215 214
216 215
217 bool ObjectLiteral::Property::IsCompileTimeValue() { 216 bool ObjectLiteral::Property::IsCompileTimeValue() {
218 return kind_ == CONSTANT || 217 return kind_ == CONSTANT ||
219 (kind_ == MATERIALIZED_LITERAL && 218 (kind_ == MATERIALIZED_LITERAL &&
220 CompileTimeValue::IsCompileTimeValue(value_)); 219 CompileTimeValue::IsCompileTimeValue(value_));
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 for (int i = 0; i < nodes->length(); i++) { 1109 for (int i = 0; i < nodes->length(); i++) {
1111 RegExpTree* node = nodes->at(i); 1110 RegExpTree* node = nodes->at(i);
1112 int node_min_match = node->min_match(); 1111 int node_min_match = node->min_match();
1113 min_match_ = IncreaseBy(min_match_, node_min_match); 1112 min_match_ = IncreaseBy(min_match_, node_min_match);
1114 int node_max_match = node->max_match(); 1113 int node_max_match = node->max_match();
1115 max_match_ = IncreaseBy(max_match_, node_max_match); 1114 max_match_ = IncreaseBy(max_match_, node_max_match);
1116 } 1115 }
1117 } 1116 }
1118 1117
1119 1118
1120 CaseClause::CaseClause(Isolate* isolate, 1119 CaseClause::CaseClause(Zone* zone,
1121 Expression* label, 1120 Expression* label,
1122 ZoneList<Statement*>* statements, 1121 ZoneList<Statement*>* statements,
1123 int pos) 1122 int pos)
1124 : Expression(isolate, pos), 1123 : Expression(zone, pos),
1125 label_(label), 1124 label_(label),
1126 statements_(statements), 1125 statements_(statements),
1127 compare_type_(Type::None(isolate)), 1126 compare_type_(Type::None(zone)),
1128 compare_id_(AstNode::GetNextId(isolate)), 1127 compare_id_(AstNode::GetNextId(zone)),
1129 entry_id_(AstNode::GetNextId(isolate)) { 1128 entry_id_(AstNode::GetNextId(zone)) {
1130 } 1129 }
1131 1130
1132 1131
1133 #define REGULAR_NODE(NodeType) \ 1132 #define REGULAR_NODE(NodeType) \
1134 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ 1133 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1135 increase_node_count(); \ 1134 increase_node_count(); \
1136 } 1135 }
1137 #define DONT_OPTIMIZE_NODE(NodeType) \ 1136 #define DONT_OPTIMIZE_NODE(NodeType) \
1138 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ 1137 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1139 increase_node_count(); \ 1138 increase_node_count(); \
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value()); 1244 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value());
1246 str = arr; 1245 str = arr;
1247 } else { 1246 } else {
1248 str = DoubleToCString(value_->Number(), buffer); 1247 str = DoubleToCString(value_->Number(), buffer);
1249 } 1248 }
1250 return isolate_->factory()->NewStringFromAscii(CStrVector(str)); 1249 return isolate_->factory()->NewStringFromAscii(CStrVector(str));
1251 } 1250 }
1252 1251
1253 1252
1254 } } // namespace v8::internal 1253 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.h ('k') | src/code-stubs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698