OLD | NEW |
---|---|
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/ast.h" | 5 #include "src/ast/ast.h" |
6 | 6 |
7 #include <cmath> // For isfinite. | 7 #include <cmath> // For isfinite. |
8 | 8 |
9 #include "src/ast/prettyprinter.h" | 9 #include "src/ast/prettyprinter.h" |
10 #include "src/ast/scopes.h" | 10 #include "src/ast/scopes.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 } | 139 } |
140 | 140 |
141 bool Expression::IsValidReferenceExpressionOrThis() const { | 141 bool Expression::IsValidReferenceExpressionOrThis() const { |
142 return IsValidReferenceExpression() || | 142 return IsValidReferenceExpression() || |
143 (IsVariableProxy() && AsVariableProxy()->is_this()); | 143 (IsVariableProxy() && AsVariableProxy()->is_this()); |
144 } | 144 } |
145 | 145 |
146 bool Expression::IsAnonymousFunctionDefinition() const { | 146 bool Expression::IsAnonymousFunctionDefinition() const { |
147 return (IsFunctionLiteral() && | 147 return (IsFunctionLiteral() && |
148 AsFunctionLiteral()->IsAnonymousFunctionDefinition()) || | 148 AsFunctionLiteral()->IsAnonymousFunctionDefinition()) || |
149 (IsClassLiteral() && | 149 (IsDoExpression() && |
150 AsClassLiteral()->IsAnonymousFunctionDefinition()); | 150 AsDoExpression()->IsAnonymousFunctionDefinition()); |
151 } | 151 } |
152 | 152 |
153 void Expression::MarkTail() { | 153 void Expression::MarkTail() { |
154 if (IsConditional()) { | 154 if (IsConditional()) { |
155 AsConditional()->MarkTail(); | 155 AsConditional()->MarkTail(); |
156 } else if (IsCall()) { | 156 } else if (IsCall()) { |
157 AsCall()->MarkTail(); | 157 AsCall()->MarkTail(); |
158 } else if (IsBinaryOperation()) { | 158 } else if (IsBinaryOperation()) { |
159 AsBinaryOperation()->MarkTail(); | 159 AsBinaryOperation()->MarkTail(); |
160 } | 160 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
273 AssignVectorSlots(target(), spec, &slot_); | 273 AssignVectorSlots(target(), spec, &slot_); |
274 } | 274 } |
275 | 275 |
276 | 276 |
277 void CountOperation::AssignFeedbackVectorSlots(Isolate* isolate, | 277 void CountOperation::AssignFeedbackVectorSlots(Isolate* isolate, |
278 FeedbackVectorSpec* spec, | 278 FeedbackVectorSpec* spec, |
279 FeedbackVectorSlotCache* cache) { | 279 FeedbackVectorSlotCache* cache) { |
280 AssignVectorSlots(expression(), spec, &slot_); | 280 AssignVectorSlots(expression(), spec, &slot_); |
281 } | 281 } |
282 | 282 |
283 bool DoExpression::IsAnonymousFunctionDefinition() const { | |
284 return represented_function_ != nullptr && | |
285 represented_function_->raw_name()->length() == 0; | |
marja
2016/07/19 09:54:33
This second part looks hacky; why is it needed? Wh
| |
286 } | |
283 | 287 |
284 Token::Value Assignment::binary_op() const { | 288 Token::Value Assignment::binary_op() const { |
285 switch (op()) { | 289 switch (op()) { |
286 case Token::ASSIGN_BIT_OR: return Token::BIT_OR; | 290 case Token::ASSIGN_BIT_OR: return Token::BIT_OR; |
287 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR; | 291 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR; |
288 case Token::ASSIGN_BIT_AND: return Token::BIT_AND; | 292 case Token::ASSIGN_BIT_AND: return Token::BIT_AND; |
289 case Token::ASSIGN_SHL: return Token::SHL; | 293 case Token::ASSIGN_SHL: return Token::SHL; |
290 case Token::ASSIGN_SAR: return Token::SAR; | 294 case Token::ASSIGN_SAR: return Token::SAR; |
291 case Token::ASSIGN_SHR: return Token::SHR; | 295 case Token::ASSIGN_SHR: return Token::SHR; |
292 case Token::ASSIGN_ADD: return Token::ADD; | 296 case Token::ASSIGN_ADD: return Token::ADD; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
365 } | 369 } |
366 } | 370 } |
367 | 371 |
368 bool ObjectLiteralProperty::NeedsSetFunctionName() const { | 372 bool ObjectLiteralProperty::NeedsSetFunctionName() const { |
369 return is_computed_name_ && | 373 return is_computed_name_ && |
370 (value_->IsAnonymousFunctionDefinition() || | 374 (value_->IsAnonymousFunctionDefinition() || |
371 (value_->IsFunctionLiteral() && | 375 (value_->IsFunctionLiteral() && |
372 IsConciseMethod(value_->AsFunctionLiteral()->kind()))); | 376 IsConciseMethod(value_->AsFunctionLiteral()->kind()))); |
373 } | 377 } |
374 | 378 |
375 void ClassLiteral::AssignFeedbackVectorSlots(Isolate* isolate, | |
376 FeedbackVectorSpec* spec, | |
377 FeedbackVectorSlotCache* cache) { | |
378 // This logic that computes the number of slots needed for vector store | |
379 // ICs must mirror FullCodeGenerator::VisitClassLiteral. | |
380 prototype_slot_ = spec->AddLoadICSlot(); | |
381 if (NeedsProxySlot()) { | |
382 proxy_slot_ = spec->AddStoreICSlot(); | |
383 } | |
384 | |
385 for (int i = 0; i < properties()->length(); i++) { | |
386 ObjectLiteral::Property* property = properties()->at(i); | |
387 Expression* value = property->value(); | |
388 if (FunctionLiteral::NeedsHomeObject(value)) { | |
389 property->SetSlot(spec->AddStoreICSlot()); | |
390 } | |
391 } | |
392 } | |
393 | |
394 | |
395 bool ObjectLiteral::Property::IsCompileTimeValue() { | 379 bool ObjectLiteral::Property::IsCompileTimeValue() { |
396 return kind_ == CONSTANT || | 380 return kind_ == CONSTANT || |
397 (kind_ == MATERIALIZED_LITERAL && | 381 (kind_ == MATERIALIZED_LITERAL && |
398 CompileTimeValue::IsCompileTimeValue(value_)); | 382 CompileTimeValue::IsCompileTimeValue(value_)); |
399 } | 383 } |
400 | 384 |
401 | 385 |
402 void ObjectLiteral::Property::set_emit_store(bool emit_store) { | 386 void ObjectLiteral::Property::set_emit_store(bool emit_store) { |
403 emit_store_ = emit_store; | 387 emit_store_ = emit_store; |
404 } | 388 } |
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1213 RECURSE_EXPRESSION(Visit(expr->right())); | 1197 RECURSE_EXPRESSION(Visit(expr->right())); |
1214 } | 1198 } |
1215 | 1199 |
1216 void AstTraversalVisitor::VisitCompareOperation(CompareOperation* expr) { | 1200 void AstTraversalVisitor::VisitCompareOperation(CompareOperation* expr) { |
1217 RECURSE_EXPRESSION(Visit(expr->left())); | 1201 RECURSE_EXPRESSION(Visit(expr->left())); |
1218 RECURSE_EXPRESSION(Visit(expr->right())); | 1202 RECURSE_EXPRESSION(Visit(expr->right())); |
1219 } | 1203 } |
1220 | 1204 |
1221 void AstTraversalVisitor::VisitThisFunction(ThisFunction* expr) {} | 1205 void AstTraversalVisitor::VisitThisFunction(ThisFunction* expr) {} |
1222 | 1206 |
1223 void AstTraversalVisitor::VisitClassLiteral(ClassLiteral* expr) { | |
1224 if (expr->extends() != nullptr) { | |
1225 RECURSE_EXPRESSION(Visit(expr->extends())); | |
1226 } | |
1227 RECURSE_EXPRESSION(Visit(expr->constructor())); | |
1228 ZoneList<ObjectLiteralProperty*>* props = expr->properties(); | |
1229 for (int i = 0; i < props->length(); ++i) { | |
1230 ObjectLiteralProperty* prop = props->at(i); | |
1231 if (!prop->key()->IsLiteral()) { | |
1232 RECURSE_EXPRESSION(Visit(prop->key())); | |
1233 } | |
1234 RECURSE_EXPRESSION(Visit(prop->value())); | |
1235 } | |
1236 } | |
1237 | |
1238 void AstTraversalVisitor::VisitSpread(Spread* expr) { | 1207 void AstTraversalVisitor::VisitSpread(Spread* expr) { |
1239 RECURSE_EXPRESSION(Visit(expr->expression())); | 1208 RECURSE_EXPRESSION(Visit(expr->expression())); |
1240 } | 1209 } |
1241 | 1210 |
1242 void AstTraversalVisitor::VisitEmptyParentheses(EmptyParentheses* expr) {} | 1211 void AstTraversalVisitor::VisitEmptyParentheses(EmptyParentheses* expr) {} |
1243 | 1212 |
1244 void AstTraversalVisitor::VisitSuperPropertyReference( | 1213 void AstTraversalVisitor::VisitSuperPropertyReference( |
1245 SuperPropertyReference* expr) { | 1214 SuperPropertyReference* expr) { |
1246 RECURSE_EXPRESSION(VisitVariableProxy(expr->this_var())); | 1215 RECURSE_EXPRESSION(VisitVariableProxy(expr->this_var())); |
1247 RECURSE_EXPRESSION(Visit(expr->home_object())); | 1216 RECURSE_EXPRESSION(Visit(expr->home_object())); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1279 bool Literal::Match(void* literal1, void* literal2) { | 1248 bool Literal::Match(void* literal1, void* literal2) { |
1280 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 1249 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
1281 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 1250 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
1282 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || | 1251 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || |
1283 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 1252 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
1284 } | 1253 } |
1285 | 1254 |
1286 | 1255 |
1287 } // namespace internal | 1256 } // namespace internal |
1288 } // namespace v8 | 1257 } // namespace v8 |
OLD | NEW |