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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 AssignVectorSlots(target(), spec, &slot_); | 183 AssignVectorSlots(target(), spec, &slot_); |
184 } | 184 } |
185 | 185 |
186 | 186 |
187 void CountOperation::AssignFeedbackVectorSlots(Isolate* isolate, | 187 void CountOperation::AssignFeedbackVectorSlots(Isolate* isolate, |
188 FeedbackVectorSpec* spec, | 188 FeedbackVectorSpec* spec, |
189 FeedbackVectorSlotCache* cache) { | 189 FeedbackVectorSlotCache* cache) { |
190 AssignVectorSlots(expression(), spec, &slot_); | 190 AssignVectorSlots(expression(), spec, &slot_); |
191 } | 191 } |
192 | 192 |
| 193 bool DoExpression::IsAnonymousFunctionDefinition() const { |
| 194 return represented_function_ != nullptr && |
| 195 represented_function_->raw_name()->length() == 0; |
| 196 } |
193 | 197 |
194 Token::Value Assignment::binary_op() const { | 198 Token::Value Assignment::binary_op() const { |
195 switch (op()) { | 199 switch (op()) { |
196 case Token::ASSIGN_BIT_OR: return Token::BIT_OR; | 200 case Token::ASSIGN_BIT_OR: return Token::BIT_OR; |
197 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR; | 201 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR; |
198 case Token::ASSIGN_BIT_AND: return Token::BIT_AND; | 202 case Token::ASSIGN_BIT_AND: return Token::BIT_AND; |
199 case Token::ASSIGN_SHL: return Token::SHL; | 203 case Token::ASSIGN_SHL: return Token::SHL; |
200 case Token::ASSIGN_SAR: return Token::SAR; | 204 case Token::ASSIGN_SAR: return Token::SAR; |
201 case Token::ASSIGN_SHR: return Token::SHR; | 205 case Token::ASSIGN_SHR: return Token::SHR; |
202 case Token::ASSIGN_ADD: return Token::ADD; | 206 case Token::ASSIGN_ADD: return Token::ADD; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 } | 279 } |
276 } | 280 } |
277 | 281 |
278 bool ObjectLiteralProperty::NeedsSetFunctionName() const { | 282 bool ObjectLiteralProperty::NeedsSetFunctionName() const { |
279 return is_computed_name_ && | 283 return is_computed_name_ && |
280 (value_->IsAnonymousFunctionDefinition() || | 284 (value_->IsAnonymousFunctionDefinition() || |
281 (value_->IsFunctionLiteral() && | 285 (value_->IsFunctionLiteral() && |
282 IsConciseMethod(value_->AsFunctionLiteral()->kind()))); | 286 IsConciseMethod(value_->AsFunctionLiteral()->kind()))); |
283 } | 287 } |
284 | 288 |
285 void ClassLiteral::AssignFeedbackVectorSlots(Isolate* isolate, | |
286 FeedbackVectorSpec* spec, | |
287 FeedbackVectorSlotCache* cache) { | |
288 // This logic that computes the number of slots needed for vector store | |
289 // ICs must mirror FullCodeGenerator::VisitClassLiteral. | |
290 prototype_slot_ = spec->AddLoadICSlot(); | |
291 if (NeedsProxySlot()) { | |
292 proxy_slot_ = spec->AddStoreICSlot(); | |
293 } | |
294 | |
295 for (int i = 0; i < properties()->length(); i++) { | |
296 ObjectLiteral::Property* property = properties()->at(i); | |
297 Expression* value = property->value(); | |
298 if (FunctionLiteral::NeedsHomeObject(value)) { | |
299 property->SetSlot(spec->AddStoreICSlot()); | |
300 } | |
301 } | |
302 } | |
303 | |
304 | |
305 bool ObjectLiteral::Property::IsCompileTimeValue() { | 289 bool ObjectLiteral::Property::IsCompileTimeValue() { |
306 return kind_ == CONSTANT || | 290 return kind_ == CONSTANT || |
307 (kind_ == MATERIALIZED_LITERAL && | 291 (kind_ == MATERIALIZED_LITERAL && |
308 CompileTimeValue::IsCompileTimeValue(value_)); | 292 CompileTimeValue::IsCompileTimeValue(value_)); |
309 } | 293 } |
310 | 294 |
311 | 295 |
312 void ObjectLiteral::Property::set_emit_store(bool emit_store) { | 296 void ObjectLiteral::Property::set_emit_store(bool emit_store) { |
313 emit_store_ = emit_store; | 297 emit_store_ = emit_store; |
314 } | 298 } |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 RECURSE_EXPRESSION(Visit(expr->right())); | 1045 RECURSE_EXPRESSION(Visit(expr->right())); |
1062 } | 1046 } |
1063 | 1047 |
1064 void AstTraversalVisitor::VisitCompareOperation(CompareOperation* expr) { | 1048 void AstTraversalVisitor::VisitCompareOperation(CompareOperation* expr) { |
1065 RECURSE_EXPRESSION(Visit(expr->left())); | 1049 RECURSE_EXPRESSION(Visit(expr->left())); |
1066 RECURSE_EXPRESSION(Visit(expr->right())); | 1050 RECURSE_EXPRESSION(Visit(expr->right())); |
1067 } | 1051 } |
1068 | 1052 |
1069 void AstTraversalVisitor::VisitThisFunction(ThisFunction* expr) {} | 1053 void AstTraversalVisitor::VisitThisFunction(ThisFunction* expr) {} |
1070 | 1054 |
1071 void AstTraversalVisitor::VisitClassLiteral(ClassLiteral* expr) { | |
1072 if (expr->extends() != nullptr) { | |
1073 RECURSE_EXPRESSION(Visit(expr->extends())); | |
1074 } | |
1075 RECURSE_EXPRESSION(Visit(expr->constructor())); | |
1076 ZoneList<ObjectLiteralProperty*>* props = expr->properties(); | |
1077 for (int i = 0; i < props->length(); ++i) { | |
1078 ObjectLiteralProperty* prop = props->at(i); | |
1079 if (!prop->key()->IsLiteral()) { | |
1080 RECURSE_EXPRESSION(Visit(prop->key())); | |
1081 } | |
1082 RECURSE_EXPRESSION(Visit(prop->value())); | |
1083 } | |
1084 } | |
1085 | |
1086 void AstTraversalVisitor::VisitSpread(Spread* expr) { | 1055 void AstTraversalVisitor::VisitSpread(Spread* expr) { |
1087 RECURSE_EXPRESSION(Visit(expr->expression())); | 1056 RECURSE_EXPRESSION(Visit(expr->expression())); |
1088 } | 1057 } |
1089 | 1058 |
1090 void AstTraversalVisitor::VisitEmptyParentheses(EmptyParentheses* expr) {} | 1059 void AstTraversalVisitor::VisitEmptyParentheses(EmptyParentheses* expr) {} |
1091 | 1060 |
1092 void AstTraversalVisitor::VisitSuperPropertyReference( | 1061 void AstTraversalVisitor::VisitSuperPropertyReference( |
1093 SuperPropertyReference* expr) { | 1062 SuperPropertyReference* expr) { |
1094 RECURSE_EXPRESSION(VisitVariableProxy(expr->this_var())); | 1063 RECURSE_EXPRESSION(VisitVariableProxy(expr->this_var())); |
1095 RECURSE_EXPRESSION(Visit(expr->home_object())); | 1064 RECURSE_EXPRESSION(Visit(expr->home_object())); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 bool Literal::Match(void* literal1, void* literal2) { | 1096 bool Literal::Match(void* literal1, void* literal2) { |
1128 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 1097 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
1129 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 1098 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
1130 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || | 1099 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || |
1131 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 1100 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
1132 } | 1101 } |
1133 | 1102 |
1134 | 1103 |
1135 } // namespace internal | 1104 } // namespace internal |
1136 } // namespace v8 | 1105 } // namespace v8 |
OLD | NEW |