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 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 constant_properties_ = constant_properties; | 567 constant_properties_ = constant_properties; |
568 bit_field_ = FastElementsField::update( | 568 bit_field_ = FastElementsField::update( |
569 bit_field_, | 569 bit_field_, |
570 (max_element_index <= 32) || ((2 * elements) >= max_element_index)); | 570 (max_element_index <= 32) || ((2 * elements) >= max_element_index)); |
571 bit_field_ = HasElementsField::update(bit_field_, elements > 0); | 571 bit_field_ = HasElementsField::update(bit_field_, elements > 0); |
572 | 572 |
573 set_is_simple(is_simple); | 573 set_is_simple(is_simple); |
574 set_depth(depth_acc); | 574 set_depth(depth_acc); |
575 } | 575 } |
576 | 576 |
| 577 bool ObjectLiteral::IsFastCloningSupported() const { |
| 578 // FastCloneShallowObjectStub doesn't copy elements, and object literals don't |
| 579 // support copy-on-write (COW) elements for now. |
| 580 // TODO(mvstanton): make object literals support COW elements. |
| 581 return fast_elements() && has_shallow_properties() && |
| 582 properties_count() <= |
| 583 FastCloneShallowObjectStub::kMaximumClonedProperties; |
| 584 } |
577 | 585 |
578 void ArrayLiteral::BuildConstantElements(Isolate* isolate) { | 586 void ArrayLiteral::BuildConstantElements(Isolate* isolate) { |
579 DCHECK_LT(first_spread_index_, 0); | 587 DCHECK_LT(first_spread_index_, 0); |
580 | 588 |
581 if (!constant_elements_.is_null()) return; | 589 if (!constant_elements_.is_null()) return; |
582 | 590 |
583 int constants_length = values()->length(); | 591 int constants_length = values()->length(); |
584 ElementsKind kind = FIRST_FAST_ELEMENTS_KIND; | 592 ElementsKind kind = FIRST_FAST_ELEMENTS_KIND; |
585 Handle<FixedArray> fixed_array = | 593 Handle<FixedArray> fixed_array = |
586 isolate->factory()->NewFixedArrayWithHoles(constants_length); | 594 isolate->factory()->NewFixedArrayWithHoles(constants_length); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 // in a 2-element FixedArray. | 649 // in a 2-element FixedArray. |
642 Handle<FixedArray> literals = isolate->factory()->NewFixedArray(2, TENURED); | 650 Handle<FixedArray> literals = isolate->factory()->NewFixedArray(2, TENURED); |
643 literals->set(0, Smi::FromInt(kind)); | 651 literals->set(0, Smi::FromInt(kind)); |
644 literals->set(1, *elements); | 652 literals->set(1, *elements); |
645 | 653 |
646 constant_elements_ = literals; | 654 constant_elements_ = literals; |
647 set_is_simple(is_simple); | 655 set_is_simple(is_simple); |
648 set_depth(depth_acc); | 656 set_depth(depth_acc); |
649 } | 657 } |
650 | 658 |
| 659 bool ArrayLiteral::IsFastCloningSupported() const { |
| 660 return depth() <= 1 && |
| 661 values()->length() <= |
| 662 FastCloneShallowArrayStub::kMaximumClonedElements; |
| 663 } |
651 | 664 |
652 void ArrayLiteral::AssignFeedbackVectorSlots(Isolate* isolate, | 665 void ArrayLiteral::AssignFeedbackVectorSlots(Isolate* isolate, |
653 FeedbackVectorSpec* spec, | 666 FeedbackVectorSpec* spec, |
654 FeedbackVectorSlotCache* cache) { | 667 FeedbackVectorSlotCache* cache) { |
655 // This logic that computes the number of slots needed for vector store | 668 // This logic that computes the number of slots needed for vector store |
656 // ics must mirror FullCodeGenerator::VisitArrayLiteral. | 669 // ics must mirror FullCodeGenerator::VisitArrayLiteral. |
657 for (int array_index = 0; array_index < values()->length(); array_index++) { | 670 for (int array_index = 0; array_index < values()->length(); array_index++) { |
658 Expression* subexpr = values()->at(array_index); | 671 Expression* subexpr = values()->at(array_index); |
659 DCHECK(!subexpr->IsSpread()); | 672 DCHECK(!subexpr->IsSpread()); |
660 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; | 673 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 // static | 960 // static |
948 bool Literal::Match(void* literal1, void* literal2) { | 961 bool Literal::Match(void* literal1, void* literal2) { |
949 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 962 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
950 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 963 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
951 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || | 964 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || |
952 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 965 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
953 } | 966 } |
954 | 967 |
955 } // namespace internal | 968 } // namespace internal |
956 } // namespace v8 | 969 } // namespace v8 |
OLD | NEW |