Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: src/objects.cc

Issue 2632503003: [runtime] Allocate space for computed property names (Closed)
Patch Set: Comments and reorder. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 <memory> 9 #include <memory>
10 #include <sstream> 10 #include <sstream>
(...skipping 9809 matching lines...) Expand 10 before | Expand all | Expand 10 after
9820 9820
9821 9821
9822 void FixedArray::CopyTo(int pos, FixedArray* dest, int dest_pos, int len) { 9822 void FixedArray::CopyTo(int pos, FixedArray* dest, int dest_pos, int len) {
9823 DisallowHeapAllocation no_gc; 9823 DisallowHeapAllocation no_gc;
9824 WriteBarrierMode mode = dest->GetWriteBarrierMode(no_gc); 9824 WriteBarrierMode mode = dest->GetWriteBarrierMode(no_gc);
9825 for (int index = 0; index < len; index++) { 9825 for (int index = 0; index < len; index++) {
9826 dest->set(dest_pos+index, get(pos+index), mode); 9826 dest->set(dest_pos+index, get(pos+index), mode);
9827 } 9827 }
9828 } 9828 }
9829 9829
9830 Object* BoilerplateDescription::name(int index) const {
9831 // get() already checks for out of bounds access, but we do not want to allow
9832 // access to the last element, if it is the number of properties.
9833 DCHECK_NE(size(), index);
9834 return get(2 * index);
9835 }
9836
9837 Object* BoilerplateDescription::value(int index) const {
9838 return get(2 * index + 1);
9839 }
9840
9841 int BoilerplateDescription::size() const {
9842 DCHECK_EQ(0, (length() - (this->has_number_of_properties() ? 1 : 0)) % 2);
9843 // Rounding is intended.
9844 return length() / 2;
9845 }
9846
9847 int BoilerplateDescription::backing_store_size() const {
9848 if (has_number_of_properties()) {
9849 // If present, the last entry contains the number of properties.
9850 return Smi::cast(this->get(length() - 1))->value();
9851 }
9852 // If the number is not given explicitly, we assume there are no
9853 // properties with computed names.
9854 return size();
9855 }
9856
9857 void BoilerplateDescription::set_backing_store_size(Isolate* isolate,
9858 int backing_store_size) {
9859 DCHECK(has_number_of_properties());
9860 DCHECK_NE(size(), backing_store_size);
9861 Handle<Object> backing_store_size_obj =
9862 isolate->factory()->NewNumberFromInt(backing_store_size);
9863 set(length() - 1, *backing_store_size_obj);
9864 }
9865
9866 bool BoilerplateDescription::has_number_of_properties() const {
9867 return length() % 2 != 0;
9868 }
9830 9869
9831 #ifdef DEBUG 9870 #ifdef DEBUG
9832 bool FixedArray::IsEqualTo(FixedArray* other) { 9871 bool FixedArray::IsEqualTo(FixedArray* other) {
9833 if (length() != other->length()) return false; 9872 if (length() != other->length()) return false;
9834 for (int i = 0 ; i < length(); ++i) { 9873 for (int i = 0 ; i < length(); ++i) {
9835 if (get(i) != other->get(i)) return false; 9874 if (get(i) != other->get(i)) return false;
9836 } 9875 }
9837 return true; 9876 return true;
9838 } 9877 }
9839 #endif 9878 #endif
(...skipping 10076 matching lines...) Expand 10 before | Expand all | Expand 10 after
19916 // depend on this. 19955 // depend on this.
19917 return DICTIONARY_ELEMENTS; 19956 return DICTIONARY_ELEMENTS;
19918 } 19957 }
19919 DCHECK_LE(kind, LAST_ELEMENTS_KIND); 19958 DCHECK_LE(kind, LAST_ELEMENTS_KIND);
19920 return kind; 19959 return kind;
19921 } 19960 }
19922 } 19961 }
19923 19962
19924 } // namespace internal 19963 } // namespace internal
19925 } // namespace v8 19964 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698