OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 6774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6785 ElementsAccessor* accessor = array_like->GetElementsAccessor(); | 6785 ElementsAccessor* accessor = array_like->GetElementsAccessor(); |
6786 accessor->AddElementsToKeyAccumulator(array_like, this, filter); | 6786 accessor->AddElementsToKeyAccumulator(array_like, this, filter); |
6787 } | 6787 } |
6788 | 6788 |
6789 | 6789 |
6790 void KeyAccumulator::PrepareForComparisons(int count) { | 6790 void KeyAccumulator::PrepareForComparisons(int count) { |
6791 // Depending on how many comparisons we do we should switch to the | 6791 // Depending on how many comparisons we do we should switch to the |
6792 // hash-table-based checks which have a one-time overhead for | 6792 // hash-table-based checks which have a one-time overhead for |
6793 // initializing but O(1) for HasKey checks. | 6793 // initializing but O(1) for HasKey checks. |
6794 if (!set_.is_null()) return; | 6794 if (!set_.is_null()) return; |
6795 // This limit was obtained through evaluation of a microbench. | 6795 // These limit were obtained through evaluation of several microbenchmarks. |
Igor Sheludko
2015/10/01 06:41:22
s/limit/limits/g
| |
6796 if (length_ * count < 50) return; | 6796 if (length_ * count < 100) return; |
6797 // Don't use a set for few elements | |
6798 if (length_ < 100 && count < 20) return; | |
6797 set_ = OrderedHashSet::Allocate(isolate_, length_); | 6799 set_ = OrderedHashSet::Allocate(isolate_, length_); |
6798 for (int i = 0; i < length_; i++) { | 6800 for (int i = 0; i < length_; i++) { |
6799 Handle<Object> value(keys_->get(i), isolate_); | 6801 Handle<Object> value(keys_->get(i), isolate_); |
6800 set_ = OrderedHashSet::Add(set_, value); | 6802 set_ = OrderedHashSet::Add(set_, value); |
6801 } | 6803 } |
6802 } | 6804 } |
6803 | 6805 |
6804 | 6806 |
6805 void KeyAccumulator::EnsureCapacity(int capacity) { | 6807 void KeyAccumulator::EnsureCapacity(int capacity) { |
6806 if (keys_.is_null() || keys_->length() <= capacity) { | 6808 if (keys_.is_null() || keys_->length() <= capacity) { |
(...skipping 9981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16788 if (cell->value() != *new_value) { | 16790 if (cell->value() != *new_value) { |
16789 cell->set_value(*new_value); | 16791 cell->set_value(*new_value); |
16790 Isolate* isolate = cell->GetIsolate(); | 16792 Isolate* isolate = cell->GetIsolate(); |
16791 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 16793 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
16792 isolate, DependentCode::kPropertyCellChangedGroup); | 16794 isolate, DependentCode::kPropertyCellChangedGroup); |
16793 } | 16795 } |
16794 } | 16796 } |
16795 | 16797 |
16796 } // namespace internal | 16798 } // namespace internal |
16797 } // namespace v8 | 16799 } // namespace v8 |
OLD | NEW |