2011-07-28 17:21:22 +00:00
|
|
|
// Copyright 2011 the V8 project authors. All rights reserved.
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
// met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above
|
|
|
|
// copyright notice, this list of conditions and the following
|
|
|
|
// disclaimer in the documentation and/or other materials provided
|
|
|
|
// with the distribution.
|
|
|
|
// * Neither the name of Google Inc. nor the names of its
|
|
|
|
// contributors may be used to endorse or promote products derived
|
|
|
|
// from this software without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
2019-05-24 13:51:59 +00:00
|
|
|
#include "src/init/v8.h"
|
2014-06-20 08:40:11 +00:00
|
|
|
#include "test/cctest/cctest.h"
|
2011-07-28 17:21:22 +00:00
|
|
|
|
2017-05-18 07:29:45 +00:00
|
|
|
#include "src/builtins/builtins-constructor.h"
|
2015-07-31 11:07:50 +00:00
|
|
|
#include "src/debug/debug.h"
|
2019-05-22 07:55:37 +00:00
|
|
|
#include "src/execution/execution.h"
|
2019-05-22 12:44:24 +00:00
|
|
|
#include "src/handles/global-handles.h"
|
2018-04-09 19:11:22 +00:00
|
|
|
#include "src/heap/factory.h"
|
2017-02-23 11:46:29 +00:00
|
|
|
#include "src/heap/spaces.h"
|
2018-05-17 12:28:56 +00:00
|
|
|
#include "src/objects/hash-table-inl.h"
|
2019-05-23 08:51:46 +00:00
|
|
|
#include "src/objects/objects-inl.h"
|
2019-05-24 13:51:59 +00:00
|
|
|
#include "src/roots/roots.h"
|
2016-05-20 13:30:22 +00:00
|
|
|
#include "test/cctest/heap/heap-utils.h"
|
2011-07-28 17:21:22 +00:00
|
|
|
|
2017-08-11 11:22:28 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
2011-07-28 17:21:22 +00:00
|
|
|
|
2014-04-04 20:41:57 +00:00
|
|
|
namespace {
|
2011-10-26 12:23:40 +00:00
|
|
|
|
2014-04-04 20:41:57 +00:00
|
|
|
|
|
|
|
template<typename HashMap>
|
|
|
|
static void TestHashMap(Handle<HashMap> table) {
|
2013-09-19 09:17:13 +00:00
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
2013-06-04 10:30:05 +00:00
|
|
|
Factory* factory = isolate->factory();
|
2014-04-04 20:41:57 +00:00
|
|
|
|
2013-06-04 10:30:05 +00:00
|
|
|
Handle<JSObject> a = factory->NewJSArray(7);
|
|
|
|
Handle<JSObject> b = factory->NewJSArray(11);
|
2014-04-04 20:41:57 +00:00
|
|
|
table = HashMap::Put(table, a, b);
|
2017-02-07 14:20:02 +00:00
|
|
|
CHECK_EQ(1, table->NumberOfElements());
|
2014-04-29 14:09:14 +00:00
|
|
|
CHECK_EQ(table->Lookup(a), *b);
|
2014-06-03 00:53:16 +00:00
|
|
|
// When the key does not exist in the map, Lookup returns the hole.
|
2018-07-04 09:10:05 +00:00
|
|
|
ReadOnlyRoots roots(CcTest::heap());
|
|
|
|
CHECK_EQ(table->Lookup(b), roots.the_hole_value());
|
2011-07-28 17:21:22 +00:00
|
|
|
|
|
|
|
// Keys still have to be valid after objects were moved.
|
2016-09-07 10:02:58 +00:00
|
|
|
CcTest::CollectGarbage(NEW_SPACE);
|
2017-02-07 14:20:02 +00:00
|
|
|
CHECK_EQ(1, table->NumberOfElements());
|
2014-04-29 14:09:14 +00:00
|
|
|
CHECK_EQ(table->Lookup(a), *b);
|
2018-07-04 09:10:05 +00:00
|
|
|
CHECK_EQ(table->Lookup(b), roots.the_hole_value());
|
2011-07-28 17:21:22 +00:00
|
|
|
|
|
|
|
// Keys that are overwritten should not change number of elements.
|
2014-04-04 20:41:57 +00:00
|
|
|
table = HashMap::Put(table, a, factory->NewJSArray(13));
|
2017-02-07 14:20:02 +00:00
|
|
|
CHECK_EQ(1, table->NumberOfElements());
|
2014-04-29 14:09:14 +00:00
|
|
|
CHECK_NE(table->Lookup(a), *b);
|
2011-07-28 17:21:22 +00:00
|
|
|
|
2014-06-03 00:53:16 +00:00
|
|
|
// Keys that have been removed are mapped to the hole.
|
|
|
|
bool was_present = false;
|
2018-07-12 11:04:18 +00:00
|
|
|
table = HashMap::Remove(isolate, table, a, &was_present);
|
2014-06-03 00:53:16 +00:00
|
|
|
CHECK(was_present);
|
2017-02-07 14:20:02 +00:00
|
|
|
CHECK_EQ(0, table->NumberOfElements());
|
2018-07-04 09:10:05 +00:00
|
|
|
CHECK_EQ(table->Lookup(a), roots.the_hole_value());
|
2011-07-28 17:21:22 +00:00
|
|
|
|
2011-10-26 12:23:40 +00:00
|
|
|
// Keys should map back to their respective values and also should get
|
|
|
|
// an identity hash code generated.
|
2011-07-28 17:21:22 +00:00
|
|
|
for (int i = 0; i < 100; i++) {
|
2013-08-30 13:42:16 +00:00
|
|
|
Handle<JSReceiver> key = factory->NewJSArray(7);
|
2013-06-04 10:30:05 +00:00
|
|
|
Handle<JSObject> value = factory->NewJSArray(11);
|
2014-04-04 20:41:57 +00:00
|
|
|
table = HashMap::Put(table, key, value);
|
2011-07-28 17:21:22 +00:00
|
|
|
CHECK_EQ(table->NumberOfElements(), i + 1);
|
2019-10-16 12:24:54 +00:00
|
|
|
CHECK(table->FindEntry(isolate, key).is_found());
|
2014-04-29 14:09:14 +00:00
|
|
|
CHECK_EQ(table->Lookup(key), *value);
|
2018-10-09 14:32:31 +00:00
|
|
|
CHECK(key->GetIdentityHash().IsSmi());
|
2011-10-26 12:23:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Keys never added to the map which already have an identity hash
|
|
|
|
// code should not be found.
|
|
|
|
for (int i = 0; i < 100; i++) {
|
2013-08-30 13:42:16 +00:00
|
|
|
Handle<JSReceiver> key = factory->NewJSArray(7);
|
2017-08-21 23:05:53 +00:00
|
|
|
CHECK(key->GetOrCreateIdentityHash(isolate).IsSmi());
|
2019-10-16 12:24:54 +00:00
|
|
|
CHECK(table->FindEntry(isolate, key).is_not_found());
|
2018-07-04 09:10:05 +00:00
|
|
|
CHECK_EQ(table->Lookup(key), roots.the_hole_value());
|
2018-10-09 14:32:31 +00:00
|
|
|
CHECK(key->GetIdentityHash().IsSmi());
|
2011-07-28 17:21:22 +00:00
|
|
|
}
|
|
|
|
|
2011-10-26 12:23:40 +00:00
|
|
|
// Keys that don't have an identity hash should not be found and also
|
|
|
|
// should not get an identity hash code generated.
|
|
|
|
for (int i = 0; i < 100; i++) {
|
2013-08-30 13:42:16 +00:00
|
|
|
Handle<JSReceiver> key = factory->NewJSArray(7);
|
2018-07-04 09:10:05 +00:00
|
|
|
CHECK_EQ(table->Lookup(key), roots.the_hole_value());
|
2018-12-25 00:19:47 +00:00
|
|
|
Object identity_hash = key->GetIdentityHash();
|
2018-07-04 09:10:05 +00:00
|
|
|
CHECK_EQ(roots.undefined_value(), identity_hash);
|
2011-07-28 17:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
2011-10-26 12:23:40 +00:00
|
|
|
|
|
|
|
|
2014-04-04 20:41:57 +00:00
|
|
|
TEST(HashMap) {
|
|
|
|
LocalContext context;
|
|
|
|
v8::HandleScope scope(context->GetIsolate());
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
2014-04-25 13:06:21 +00:00
|
|
|
TestHashMap(ObjectHashTable::New(isolate, 23));
|
2014-04-04 20:41:57 +00:00
|
|
|
}
|
|
|
|
|
2016-06-28 13:32:18 +00:00
|
|
|
template <typename HashSet>
|
|
|
|
static void TestHashSet(Handle<HashSet> table) {
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
Factory* factory = isolate->factory();
|
|
|
|
|
|
|
|
Handle<JSObject> a = factory->NewJSArray(7);
|
|
|
|
Handle<JSObject> b = factory->NewJSArray(11);
|
2018-07-12 11:04:18 +00:00
|
|
|
table = HashSet::Add(isolate, table, a);
|
2017-02-07 14:20:02 +00:00
|
|
|
CHECK_EQ(1, table->NumberOfElements());
|
2016-06-28 13:32:18 +00:00
|
|
|
CHECK(table->Has(isolate, a));
|
|
|
|
CHECK(!table->Has(isolate, b));
|
|
|
|
|
|
|
|
// Keys still have to be valid after objects were moved.
|
2016-09-07 10:02:58 +00:00
|
|
|
CcTest::CollectGarbage(NEW_SPACE);
|
2017-02-07 14:20:02 +00:00
|
|
|
CHECK_EQ(1, table->NumberOfElements());
|
2016-06-28 13:32:18 +00:00
|
|
|
CHECK(table->Has(isolate, a));
|
|
|
|
CHECK(!table->Has(isolate, b));
|
|
|
|
|
|
|
|
// Keys that are overwritten should not change number of elements.
|
2018-07-12 11:04:18 +00:00
|
|
|
table = HashSet::Add(isolate, table, a);
|
2017-02-07 14:20:02 +00:00
|
|
|
CHECK_EQ(1, table->NumberOfElements());
|
2016-06-28 13:32:18 +00:00
|
|
|
CHECK(table->Has(isolate, a));
|
|
|
|
CHECK(!table->Has(isolate, b));
|
|
|
|
|
|
|
|
// Keys that have been removed are mapped to the hole.
|
|
|
|
// TODO(cbruni): not implemented yet.
|
|
|
|
// bool was_present = false;
|
|
|
|
// table = HashSet::Remove(table, a, &was_present);
|
|
|
|
// CHECK(was_present);
|
2017-02-07 14:20:02 +00:00
|
|
|
// CHECK_EQ(0, table->NumberOfElements());
|
2016-06-28 13:32:18 +00:00
|
|
|
// CHECK(!table->Has(a));
|
|
|
|
// CHECK(!table->Has(b));
|
|
|
|
|
|
|
|
// Keys should map back to their respective values and also should get
|
|
|
|
// an identity hash code generated.
|
|
|
|
for (int i = 0; i < 100; i++) {
|
|
|
|
Handle<JSReceiver> key = factory->NewJSArray(7);
|
2018-07-12 11:04:18 +00:00
|
|
|
table = HashSet::Add(isolate, table, key);
|
2016-06-28 13:32:18 +00:00
|
|
|
CHECK_EQ(table->NumberOfElements(), i + 2);
|
|
|
|
CHECK(table->Has(isolate, key));
|
2018-10-09 14:32:31 +00:00
|
|
|
CHECK(key->GetIdentityHash().IsSmi());
|
2016-06-28 13:32:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Keys never added to the map which already have an identity hash
|
|
|
|
// code should not be found.
|
|
|
|
for (int i = 0; i < 100; i++) {
|
|
|
|
Handle<JSReceiver> key = factory->NewJSArray(7);
|
2017-08-21 23:05:53 +00:00
|
|
|
CHECK(key->GetOrCreateIdentityHash(isolate).IsSmi());
|
2016-06-28 13:32:18 +00:00
|
|
|
CHECK(!table->Has(isolate, key));
|
2018-10-09 14:32:31 +00:00
|
|
|
CHECK(key->GetIdentityHash().IsSmi());
|
2016-06-28 13:32:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Keys that don't have an identity hash should not be found and also
|
|
|
|
// should not get an identity hash code generated.
|
|
|
|
for (int i = 0; i < 100; i++) {
|
|
|
|
Handle<JSReceiver> key = factory->NewJSArray(7);
|
|
|
|
CHECK(!table->Has(isolate, key));
|
2018-12-25 00:19:47 +00:00
|
|
|
Object identity_hash = key->GetIdentityHash();
|
2018-07-04 09:10:05 +00:00
|
|
|
CHECK_EQ(ReadOnlyRoots(CcTest::heap()).undefined_value(), identity_hash);
|
2016-06-28 13:32:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(HashSet) {
|
|
|
|
LocalContext context;
|
|
|
|
v8::HandleScope scope(context->GetIsolate());
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
TestHashSet(ObjectHashSet::New(isolate, 23));
|
|
|
|
}
|
2014-04-04 20:41:57 +00:00
|
|
|
|
2013-09-12 11:03:27 +00:00
|
|
|
class ObjectHashTableTest: public ObjectHashTable {
|
|
|
|
public:
|
2018-11-22 23:55:32 +00:00
|
|
|
explicit ObjectHashTableTest(ObjectHashTable o) : ObjectHashTable(o) {}
|
|
|
|
|
2019-10-16 12:24:54 +00:00
|
|
|
void insert(InternalIndex entry, int key, int value) {
|
2013-09-12 11:03:27 +00:00
|
|
|
set(EntryToIndex(entry), Smi::FromInt(key));
|
|
|
|
set(EntryToIndex(entry) + 1, Smi::FromInt(value));
|
|
|
|
}
|
|
|
|
|
|
|
|
int lookup(int key) {
|
2018-07-17 15:08:58 +00:00
|
|
|
Handle<Object> key_obj(Smi::FromInt(key), CcTest::i_isolate());
|
2017-07-10 12:58:27 +00:00
|
|
|
return Smi::ToInt(Lookup(key_obj));
|
2013-09-12 11:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int capacity() {
|
|
|
|
return Capacity();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
TEST(HashTableRehash) {
|
|
|
|
LocalContext context;
|
2013-09-19 09:17:13 +00:00
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
2013-09-12 11:03:27 +00:00
|
|
|
v8::HandleScope scope(context->GetIsolate());
|
|
|
|
// Test almost filled table.
|
|
|
|
{
|
2014-04-25 13:06:21 +00:00
|
|
|
Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 100);
|
2018-11-22 23:55:32 +00:00
|
|
|
ObjectHashTableTest t(*table);
|
2013-09-12 11:03:27 +00:00
|
|
|
int capacity = t.capacity();
|
|
|
|
for (int i = 0; i < capacity - 1; i++) {
|
2019-10-16 12:24:54 +00:00
|
|
|
t.insert(InternalIndex(i), i * i, i);
|
2013-09-12 11:03:27 +00:00
|
|
|
}
|
2020-07-09 07:32:19 +00:00
|
|
|
t.Rehash(isolate);
|
2013-09-12 11:03:27 +00:00
|
|
|
for (int i = 0; i < capacity - 1; i++) {
|
|
|
|
CHECK_EQ(i, t.lookup(i * i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Test half-filled table.
|
|
|
|
{
|
2014-04-25 13:06:21 +00:00
|
|
|
Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 100);
|
2018-11-22 23:55:32 +00:00
|
|
|
ObjectHashTableTest t(*table);
|
2013-09-12 11:03:27 +00:00
|
|
|
int capacity = t.capacity();
|
|
|
|
for (int i = 0; i < capacity / 2; i++) {
|
2019-10-16 12:24:54 +00:00
|
|
|
t.insert(InternalIndex(i), i * i, i);
|
2013-09-12 11:03:27 +00:00
|
|
|
}
|
2020-07-09 07:32:19 +00:00
|
|
|
t.Rehash(isolate);
|
2013-09-12 11:03:27 +00:00
|
|
|
for (int i = 0; i < capacity / 2; i++) {
|
|
|
|
CHECK_EQ(i, t.lookup(i * i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-26 12:23:40 +00:00
|
|
|
#ifdef DEBUG
|
2014-04-04 20:41:57 +00:00
|
|
|
template<class HashSet>
|
|
|
|
static void TestHashSetCausesGC(Handle<HashSet> table) {
|
2013-09-19 09:17:13 +00:00
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
2013-06-04 10:30:05 +00:00
|
|
|
Factory* factory = isolate->factory();
|
2014-04-04 20:41:57 +00:00
|
|
|
|
2013-06-04 10:30:05 +00:00
|
|
|
Handle<JSObject> key = factory->NewJSArray(0);
|
2011-10-26 12:23:40 +00:00
|
|
|
|
|
|
|
// Simulate a full heap so that generating an identity hash code
|
|
|
|
// in subsequent calls will request GC.
|
2016-05-20 13:30:22 +00:00
|
|
|
heap::SimulateFullSpace(CcTest::heap()->new_space());
|
|
|
|
heap::SimulateFullSpace(CcTest::heap()->old_space());
|
2011-10-26 12:23:40 +00:00
|
|
|
|
|
|
|
// Calling Contains() should not cause GC ever.
|
2013-11-05 11:47:11 +00:00
|
|
|
int gc_count = isolate->heap()->gc_count();
|
2014-04-29 14:16:38 +00:00
|
|
|
CHECK(!table->Contains(key));
|
2013-11-05 11:47:11 +00:00
|
|
|
CHECK(gc_count == isolate->heap()->gc_count());
|
2011-10-26 12:23:40 +00:00
|
|
|
|
2013-11-05 11:47:11 +00:00
|
|
|
// Calling Remove() will not cause GC in this case.
|
2014-05-21 12:31:31 +00:00
|
|
|
bool was_present = false;
|
|
|
|
table = HashSet::Remove(table, key, &was_present);
|
|
|
|
CHECK(!was_present);
|
2013-11-05 11:47:11 +00:00
|
|
|
CHECK(gc_count == isolate->heap()->gc_count());
|
2011-10-26 12:23:40 +00:00
|
|
|
|
2013-11-05 11:47:11 +00:00
|
|
|
// Calling Add() should cause GC.
|
2014-04-04 20:41:57 +00:00
|
|
|
table = HashSet::Add(table, key);
|
2013-11-05 11:47:11 +00:00
|
|
|
CHECK(gc_count < isolate->heap()->gc_count());
|
2011-10-26 12:23:40 +00:00
|
|
|
}
|
2014-04-04 20:41:57 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2017-08-21 01:58:40 +00:00
|
|
|
template <class HashMap>
|
|
|
|
static void TestHashMapDoesNotCauseGC(Handle<HashMap> table) {
|
2013-09-19 09:17:13 +00:00
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
2013-06-04 10:30:05 +00:00
|
|
|
Factory* factory = isolate->factory();
|
2014-04-04 20:41:57 +00:00
|
|
|
|
2013-06-04 10:30:05 +00:00
|
|
|
Handle<JSObject> key = factory->NewJSArray(0);
|
2011-10-26 12:23:40 +00:00
|
|
|
|
2017-08-21 01:58:40 +00:00
|
|
|
// Even though we simulate a full heap, generating an identity hash
|
|
|
|
// code in subsequent calls will not request GC.
|
2020-07-02 23:40:05 +00:00
|
|
|
if (!FLAG_single_generation) {
|
|
|
|
heap::SimulateFullSpace(CcTest::heap()->new_space());
|
|
|
|
}
|
2016-05-20 13:30:22 +00:00
|
|
|
heap::SimulateFullSpace(CcTest::heap()->old_space());
|
2011-10-26 12:23:40 +00:00
|
|
|
|
|
|
|
// Calling Lookup() should not cause GC ever.
|
2016-06-14 10:08:44 +00:00
|
|
|
CHECK(table->Lookup(key).IsTheHole(isolate));
|
2011-10-26 12:23:40 +00:00
|
|
|
|
|
|
|
// Calling Put() should request GC by returning a failure.
|
2013-11-05 11:47:11 +00:00
|
|
|
int gc_count = isolate->heap()->gc_count();
|
2014-04-04 20:41:57 +00:00
|
|
|
HashMap::Put(table, key, key);
|
2017-08-21 01:58:40 +00:00
|
|
|
CHECK(gc_count == isolate->heap()->gc_count());
|
2011-10-26 12:23:40 +00:00
|
|
|
}
|
2014-04-04 20:41:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
TEST(ObjectHashTableCausesGC) {
|
|
|
|
i::FLAG_stress_compaction = false;
|
2020-09-03 10:33:46 +00:00
|
|
|
// For SimulateFullSpace in TestHashMapDoesNotCauseGC.
|
|
|
|
i::FLAG_stress_concurrent_allocation = false;
|
2014-04-04 20:41:57 +00:00
|
|
|
LocalContext context;
|
|
|
|
v8::HandleScope scope(context->GetIsolate());
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
2017-08-21 01:58:40 +00:00
|
|
|
TestHashMapDoesNotCauseGC(ObjectHashTable::New(isolate, 1));
|
2014-04-04 20:41:57 +00:00
|
|
|
}
|
2011-10-26 12:23:40 +00:00
|
|
|
#endif
|
2014-04-04 20:41:57 +00:00
|
|
|
|
2017-05-18 07:29:45 +00:00
|
|
|
TEST(MaximumClonedShallowObjectProperties) {
|
|
|
|
// Assert that a NameDictionary with kMaximumClonedShallowObjectProperties is
|
|
|
|
// not in large-object space.
|
|
|
|
const int max_capacity = NameDictionary::ComputeCapacity(
|
|
|
|
ConstructorBuiltins::kMaximumClonedShallowObjectProperties);
|
2019-10-16 12:24:54 +00:00
|
|
|
const InternalIndex max_literal_entry(max_capacity /
|
|
|
|
NameDictionary::kEntrySize);
|
2017-05-18 07:29:45 +00:00
|
|
|
const int max_literal_index = NameDictionary::EntryToIndex(max_literal_entry);
|
|
|
|
CHECK_LE(NameDictionary::OffsetOfElementAt(max_literal_index),
|
|
|
|
kMaxRegularHeapObjectSize);
|
|
|
|
}
|
|
|
|
|
2015-09-30 13:46:56 +00:00
|
|
|
} // namespace
|
2017-08-11 11:22:28 +00:00
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|