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

Side by Side Diff: src/objects.cc

Issue 2632503003: [runtime] Allocate space for computed property names (Closed)
Patch Set: Fix typo. 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
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 int BoilerplateDescription::number_of_all_properties() const {
9831 if (has_number_of_properties()) {
9832 // If present, the last entry contains the number of properties.
9833 return Smi::cast(this->get(length() - 1))->value();
9834 }
9835 // If the number is not given explicitly, we assume there are no
9836 // properties with computed names.
9837 return size();
9838 }
9839
9840 int BoilerplateDescription::size() const {
9841 DCHECK_EQ(0, (length() - (this->has_number_of_properties() ? 1 : 0)) % 2);
9842 // Rounding is intended.
9843 return length() / 2;
9844 }
9845
9846 Object* BoilerplateDescription::name(int index) const {
9847 // get() already checks for out of bounds access, but we do not want to allow
9848 // access to the last element, if it is the number of properties.
9849 DCHECK_NE(size(), index);
9850 return get(2 * index);
9851 }
9852
9853 Object* BoilerplateDescription::value(int index) const {
9854 return get(2 * index + 1);
9855 }
9856
9857 bool BoilerplateDescription::has_number_of_properties() const {
9858 return length() % 2 != 0;
9859 }
9830 9860
9831 #ifdef DEBUG 9861 #ifdef DEBUG
9832 bool FixedArray::IsEqualTo(FixedArray* other) { 9862 bool FixedArray::IsEqualTo(FixedArray* other) {
9833 if (length() != other->length()) return false; 9863 if (length() != other->length()) return false;
9834 for (int i = 0 ; i < length(); ++i) { 9864 for (int i = 0 ; i < length(); ++i) {
9835 if (get(i) != other->get(i)) return false; 9865 if (get(i) != other->get(i)) return false;
9836 } 9866 }
9837 return true; 9867 return true;
9838 } 9868 }
9839 #endif 9869 #endif
(...skipping 10076 matching lines...) Expand 10 before | Expand all | Expand 10 after
19916 // depend on this. 19946 // depend on this.
19917 return DICTIONARY_ELEMENTS; 19947 return DICTIONARY_ELEMENTS;
19918 } 19948 }
19919 DCHECK_LE(kind, LAST_ELEMENTS_KIND); 19949 DCHECK_LE(kind, LAST_ELEMENTS_KIND);
19920 return kind; 19950 return kind;
19921 } 19951 }
19922 } 19952 }
19923 19953
19924 } // namespace internal 19954 } // namespace internal
19925 } // namespace v8 19955 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | src/runtime/runtime-literals.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698