| 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/compile-time-value.h" | 9 #include "src/ast/compile-time-value.h" |
| 10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 kind_ = PROTOTYPE; | 342 kind_ = PROTOTYPE; |
| 343 } else if (value_->AsMaterializedLiteral() != NULL) { | 343 } else if (value_->AsMaterializedLiteral() != NULL) { |
| 344 kind_ = MATERIALIZED_LITERAL; | 344 kind_ = MATERIALIZED_LITERAL; |
| 345 } else if (value_->IsLiteral()) { | 345 } else if (value_->IsLiteral()) { |
| 346 kind_ = CONSTANT; | 346 kind_ = CONSTANT; |
| 347 } else { | 347 } else { |
| 348 kind_ = COMPUTED; | 348 kind_ = COMPUTED; |
| 349 } | 349 } |
| 350 } | 350 } |
| 351 | 351 |
| 352 FeedbackVectorSlot LiteralProperty::GetStoreDataPropertySlot() const { |
| 353 int offset = FunctionLiteral::NeedsHomeObject(value_) ? 1 : 0; |
| 354 return GetSlot(offset); |
| 355 } |
| 356 |
| 357 void LiteralProperty::SetStoreDataPropertySlot(FeedbackVectorSlot slot) { |
| 358 int offset = FunctionLiteral::NeedsHomeObject(value_) ? 1 : 0; |
| 359 return SetSlot(slot, offset); |
| 360 } |
| 361 |
| 352 bool LiteralProperty::NeedsSetFunctionName() const { | 362 bool LiteralProperty::NeedsSetFunctionName() const { |
| 353 return is_computed_name_ && | 363 return is_computed_name_ && |
| 354 (value_->IsAnonymousFunctionDefinition() || | 364 (value_->IsAnonymousFunctionDefinition() || |
| 355 (value_->IsFunctionLiteral() && | 365 (value_->IsFunctionLiteral() && |
| 356 IsConciseMethod(value_->AsFunctionLiteral()->kind()))); | 366 IsConciseMethod(value_->AsFunctionLiteral()->kind()))); |
| 357 } | 367 } |
| 358 | 368 |
| 359 ClassLiteralProperty::ClassLiteralProperty(Expression* key, Expression* value, | 369 ClassLiteralProperty::ClassLiteralProperty(Expression* key, Expression* value, |
| 360 Kind kind, bool is_static, | 370 Kind kind, bool is_static, |
| 361 bool is_computed_name) | 371 bool is_computed_name) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 375 if (NeedsProxySlot()) { | 385 if (NeedsProxySlot()) { |
| 376 proxy_slot_ = spec->AddStoreICSlot(); | 386 proxy_slot_ = spec->AddStoreICSlot(); |
| 377 } | 387 } |
| 378 | 388 |
| 379 for (int i = 0; i < properties()->length(); i++) { | 389 for (int i = 0; i < properties()->length(); i++) { |
| 380 ClassLiteral::Property* property = properties()->at(i); | 390 ClassLiteral::Property* property = properties()->at(i); |
| 381 Expression* value = property->value(); | 391 Expression* value = property->value(); |
| 382 if (FunctionLiteral::NeedsHomeObject(value)) { | 392 if (FunctionLiteral::NeedsHomeObject(value)) { |
| 383 property->SetSlot(spec->AddStoreICSlot()); | 393 property->SetSlot(spec->AddStoreICSlot()); |
| 384 } | 394 } |
| 395 property->SetStoreDataPropertySlot( |
| 396 spec->AddStoreDataPropertyInLiteralICSlot()); |
| 385 } | 397 } |
| 386 } | 398 } |
| 387 | 399 |
| 388 bool ObjectLiteral::Property::IsCompileTimeValue() const { | 400 bool ObjectLiteral::Property::IsCompileTimeValue() const { |
| 389 return kind_ == CONSTANT || | 401 return kind_ == CONSTANT || |
| 390 (kind_ == MATERIALIZED_LITERAL && | 402 (kind_ == MATERIALIZED_LITERAL && |
| 391 CompileTimeValue::IsCompileTimeValue(value_)); | 403 CompileTimeValue::IsCompileTimeValue(value_)); |
| 392 } | 404 } |
| 393 | 405 |
| 394 | 406 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 | 461 |
| 450 for (; property_index < properties()->length(); property_index++) { | 462 for (; property_index < properties()->length(); property_index++) { |
| 451 ObjectLiteral::Property* property = properties()->at(property_index); | 463 ObjectLiteral::Property* property = properties()->at(property_index); |
| 452 | 464 |
| 453 Expression* value = property->value(); | 465 Expression* value = property->value(); |
| 454 if (property->kind() != ObjectLiteral::Property::PROTOTYPE) { | 466 if (property->kind() != ObjectLiteral::Property::PROTOTYPE) { |
| 455 if (FunctionLiteral::NeedsHomeObject(value)) { | 467 if (FunctionLiteral::NeedsHomeObject(value)) { |
| 456 property->SetSlot(spec->AddStoreICSlot()); | 468 property->SetSlot(spec->AddStoreICSlot()); |
| 457 } | 469 } |
| 458 } | 470 } |
| 471 property->SetStoreDataPropertySlot( |
| 472 spec->AddStoreDataPropertyInLiteralICSlot()); |
| 459 } | 473 } |
| 460 } | 474 } |
| 461 | 475 |
| 462 | 476 |
| 463 void ObjectLiteral::CalculateEmitStore(Zone* zone) { | 477 void ObjectLiteral::CalculateEmitStore(Zone* zone) { |
| 464 const auto GETTER = ObjectLiteral::Property::GETTER; | 478 const auto GETTER = ObjectLiteral::Property::GETTER; |
| 465 const auto SETTER = ObjectLiteral::Property::SETTER; | 479 const auto SETTER = ObjectLiteral::Property::SETTER; |
| 466 | 480 |
| 467 ZoneAllocationPolicy allocator(zone); | 481 ZoneAllocationPolicy allocator(zone); |
| 468 | 482 |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 // static | 978 // static |
| 965 bool Literal::Match(void* literal1, void* literal2) { | 979 bool Literal::Match(void* literal1, void* literal2) { |
| 966 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 980 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
| 967 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 981 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
| 968 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || | 982 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || |
| 969 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 983 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
| 970 } | 984 } |
| 971 | 985 |
| 972 } // namespace internal | 986 } // namespace internal |
| 973 } // namespace v8 | 987 } // namespace v8 |
| OLD | NEW |