Commit 3ecb047a authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[runtime] Decrease the maximum number of descriptors.

This ensures that MigrateFastToFast does not overflow the length of the
property array.

Bug: chromium:789393
Change-Id: I77adc319c1c8c469ea482bad35ead8661d535192
Reviewed-on: https://chromium-review.googlesource.com/824167
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50086}
parent db46a309
...@@ -1939,6 +1939,7 @@ class PropertyArray : public HeapObject { ...@@ -1939,6 +1939,7 @@ class PropertyArray : public HeapObject {
static const int kLengthFieldSize = 10; static const int kLengthFieldSize = 10;
class LengthField : public BitField<int, 0, kLengthFieldSize> {}; class LengthField : public BitField<int, 0, kLengthFieldSize> {};
static const int kMaxLength = LengthField::kMax;
class HashField : public BitField<int, kLengthFieldSize, class HashField : public BitField<int, kLengthFieldSize,
kSmiValueSize - kLengthFieldSize - 1> {}; kSmiValueSize - kLengthFieldSize - 1> {};
...@@ -2643,6 +2644,8 @@ class JSObject: public JSReceiver { ...@@ -2643,6 +2644,8 @@ class JSObject: public JSReceiver {
// its size by more than the 1 entry necessary, so sequentially adding fields // its size by more than the 1 entry necessary, so sequentially adding fields
// to the same object requires fewer allocations and copies. // to the same object requires fewer allocations and copies.
static const int kFieldsAdded = 3; static const int kFieldsAdded = 3;
STATIC_ASSERT(kMaxNumberOfDescriptors + kFieldsAdded <=
PropertyArray::kMaxLength);
// Layout description. // Layout description.
static const int kElementsOffset = JSReceiver::kHeaderSize; static const int kElementsOffset = JSReceiver::kHeaderSize;
......
...@@ -197,10 +197,10 @@ class Representation { ...@@ -197,10 +197,10 @@ class Representation {
static const int kDescriptorIndexBitCount = 10; static const int kDescriptorIndexBitCount = 10;
// The maximum number of descriptors we want in a descriptor array (should // The maximum number of descriptors we want in a descriptor array. It should
// fit in a page). // fit in a page and also the following should hold:
static const int kMaxNumberOfDescriptors = // kMaxNumberOfDescriptors + kFieldsAdded <= PropertyArray::kMaxLength.
(1 << kDescriptorIndexBitCount) - 2; static const int kMaxNumberOfDescriptors = (1 << kDescriptorIndexBitCount) - 4;
static const int kInvalidEnumCacheSentinel = static const int kInvalidEnumCacheSentinel =
(1 << kDescriptorIndexBitCount) - 1; (1 << kDescriptorIndexBitCount) - 1;
......
...@@ -12,7 +12,7 @@ function EnsureDictionaryMode(obj, properties=1500) { ...@@ -12,7 +12,7 @@ function EnsureDictionaryMode(obj, properties=1500) {
} }
function EnsureAlmostDictionaryMode(obj) { function EnsureAlmostDictionaryMode(obj) {
for (let i = 0; i < 1022; i++) { for (let i = 0; i < 1020; i++) {
obj["x" + i] = 0; obj["x" + i] = 0;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment