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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 93eacb292fdafd938cd1c141d6514d05724c98ea..ded60d3b217c56004788fae4d21591aadecf4de6 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -9827,6 +9827,36 @@ void FixedArray::CopyTo(int pos, FixedArray* dest, int dest_pos, int len) {
}
}
+int BoilerplateDescription::number_of_all_properties() const {
+ if (has_number_of_properties()) {
+ // If present, the last entry contains the number of properties.
+ return Smi::cast(this->get(length() - 1))->value();
+ }
+ // If the number is not given explicitly, we assume there are no
+ // properties with computed names.
+ return size();
+}
+
+int BoilerplateDescription::size() const {
+ DCHECK_EQ(0, (length() - (this->has_number_of_properties() ? 1 : 0)) % 2);
+ // Rounding is intended.
+ return length() / 2;
+}
+
+Object* BoilerplateDescription::name(int index) const {
+ // get() already checks for out of bounds access, but we do not want to allow
+ // access to the last element, if it is the number of properties.
+ DCHECK_NE(size(), index);
+ return get(2 * index);
+}
+
+Object* BoilerplateDescription::value(int index) const {
+ return get(2 * index + 1);
+}
+
+bool BoilerplateDescription::has_number_of_properties() const {
+ return length() % 2 != 0;
+}
#ifdef DEBUG
bool FixedArray::IsEqualTo(FixedArray* other) {
« 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