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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 // This logic that computes the number of slots needed for vector store | 369 // This logic that computes the number of slots needed for vector store |
370 // ICs must mirror FullCodeGenerator::VisitClassLiteral. | 370 // ICs must mirror FullCodeGenerator::VisitClassLiteral. |
371 prototype_slot_ = spec->AddLoadICSlot(); | 371 prototype_slot_ = spec->AddLoadICSlot(); |
372 if (NeedsProxySlot()) { | 372 if (NeedsProxySlot()) { |
373 proxy_slot_ = spec->AddStoreICSlot(); | 373 proxy_slot_ = spec->AddStoreICSlot(); |
374 } | 374 } |
375 | 375 |
376 for (int i = 0; i < properties()->length(); i++) { | 376 for (int i = 0; i < properties()->length(); i++) { |
377 ClassLiteral::Property* property = properties()->at(i); | 377 ClassLiteral::Property* property = properties()->at(i); |
378 Expression* value = property->value(); | 378 Expression* value = property->value(); |
| 379 int slot_offset = 0; |
379 if (FunctionLiteral::NeedsHomeObject(value)) { | 380 if (FunctionLiteral::NeedsHomeObject(value)) { |
380 property->SetSlot(spec->AddStoreICSlot()); | 381 property->SetSlot(spec->AddStoreICSlot()); |
| 382 slot_offset++; |
381 } | 383 } |
| 384 property->SetSlot(spec->AddStoreDataPropertyInLiteralICSlot(), slot_offset); |
382 } | 385 } |
383 } | 386 } |
384 | 387 |
385 bool ObjectLiteral::Property::IsCompileTimeValue() const { | 388 bool ObjectLiteral::Property::IsCompileTimeValue() const { |
386 return kind_ == CONSTANT || | 389 return kind_ == CONSTANT || |
387 (kind_ == MATERIALIZED_LITERAL && | 390 (kind_ == MATERIALIZED_LITERAL && |
388 CompileTimeValue::IsCompileTimeValue(value_)); | 391 CompileTimeValue::IsCompileTimeValue(value_)); |
389 } | 392 } |
390 | 393 |
391 | 394 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 if (property->emit_store() && FunctionLiteral::NeedsHomeObject(value)) { | 443 if (property->emit_store() && FunctionLiteral::NeedsHomeObject(value)) { |
441 property->SetSlot(spec->AddStoreICSlot()); | 444 property->SetSlot(spec->AddStoreICSlot()); |
442 } | 445 } |
443 break; | 446 break; |
444 } | 447 } |
445 } | 448 } |
446 | 449 |
447 for (; property_index < properties()->length(); property_index++) { | 450 for (; property_index < properties()->length(); property_index++) { |
448 ObjectLiteral::Property* property = properties()->at(property_index); | 451 ObjectLiteral::Property* property = properties()->at(property_index); |
449 | 452 |
| 453 int slot_offset = 0; |
450 Expression* value = property->value(); | 454 Expression* value = property->value(); |
451 if (property->kind() != ObjectLiteral::Property::PROTOTYPE) { | 455 if (property->kind() != ObjectLiteral::Property::PROTOTYPE) { |
452 if (FunctionLiteral::NeedsHomeObject(value)) { | 456 if (FunctionLiteral::NeedsHomeObject(value)) { |
453 property->SetSlot(spec->AddStoreICSlot()); | 457 property->SetSlot(spec->AddStoreICSlot()); |
| 458 slot_offset++; |
454 } | 459 } |
455 } | 460 } |
| 461 property->SetSlot(spec->AddStoreDataPropertyInLiteralICSlot(), slot_offset); |
456 } | 462 } |
457 } | 463 } |
458 | 464 |
459 | 465 |
460 void ObjectLiteral::CalculateEmitStore(Zone* zone) { | 466 void ObjectLiteral::CalculateEmitStore(Zone* zone) { |
461 const auto GETTER = ObjectLiteral::Property::GETTER; | 467 const auto GETTER = ObjectLiteral::Property::GETTER; |
462 const auto SETTER = ObjectLiteral::Property::SETTER; | 468 const auto SETTER = ObjectLiteral::Property::SETTER; |
463 | 469 |
464 ZoneAllocationPolicy allocator(zone); | 470 ZoneAllocationPolicy allocator(zone); |
465 | 471 |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 // static | 967 // static |
962 bool Literal::Match(void* literal1, void* literal2) { | 968 bool Literal::Match(void* literal1, void* literal2) { |
963 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 969 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
964 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 970 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
965 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || | 971 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || |
966 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 972 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
967 } | 973 } |
968 | 974 |
969 } // namespace internal | 975 } // namespace internal |
970 } // namespace v8 | 976 } // namespace v8 |
OLD | NEW |