Commit e9c93223 authored by Marja Hölttä's avatar Marja Hölttä Committed by Commit Bot

[objects.h splitting] Move JSCollection + related classes.

BUG=v8:5402,v8:7109

Change-Id: Ifee03125d8894181acffc7ed9c6bda44e3939d2d
Reviewed-on: https://chromium-review.googlesource.com/803336
Commit-Queue: Marja Hölttä <marja@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49792}
parent 56ca9a5a
......@@ -1817,6 +1817,8 @@ v8_source_set("v8_base") {
"src/objects/intl-objects.h",
"src/objects/js-array-inl.h",
"src/objects/js-array.h",
"src/objects/js-collection-inl.h",
"src/objects/js-collection.h",
"src/objects/js-regexp-inl.h",
"src/objects/js-regexp.h",
"src/objects/literal-objects-inl.h",
......
......@@ -11,6 +11,7 @@
#include "src/detachable-vector.h"
#include "src/factory.h"
#include "src/isolate.h"
#include "src/objects/js-collection.h"
namespace v8 {
......
......@@ -26,6 +26,10 @@ namespace internal {
class Callable;
class CallInterfaceDescriptor;
class Isolate;
class JSCollection;
class JSWeakCollection;
class JSWeakMap;
class JSWeakSet;
class Factory;
class Zone;
......
......@@ -29,7 +29,11 @@ class ConstantElementsPair;
class CoverageInfo;
class DebugInfo;
class FreshlyAllocatedBigInt;
class JSMap;
class JSMapIterator;
class JSModuleNamespace;
class JSSet;
class JSSetIterator;
class NewFunctionArgs;
struct SourceRange;
class PreParsedScopeData;
......
......@@ -20,6 +20,7 @@ class BigInt;
class BytecodeArray;
class JSArrayBuffer;
class JSRegExp;
class JSWeakCollection;
#define TYPED_VISITOR_ID_LIST(V) \
V(AllocationSite) \
......
......@@ -38,6 +38,7 @@
#include "src/objects/hash-table-inl.h"
#include "src/objects/hash-table.h"
#include "src/objects/js-array-inl.h"
#include "src/objects/js-collection-inl.h"
#include "src/objects/js-regexp-inl.h"
#include "src/objects/literal-objects.h"
#include "src/objects/module-inl.h"
......@@ -97,14 +98,10 @@ TYPE_CHECKER(JSDate, JS_DATE_TYPE)
TYPE_CHECKER(JSError, JS_ERROR_TYPE)
TYPE_CHECKER(JSFunction, JS_FUNCTION_TYPE)
TYPE_CHECKER(JSGlobalObject, JS_GLOBAL_OBJECT_TYPE)
TYPE_CHECKER(JSMap, JS_MAP_TYPE)
TYPE_CHECKER(JSMessageObject, JS_MESSAGE_OBJECT_TYPE)
TYPE_CHECKER(JSPromise, JS_PROMISE_TYPE)
TYPE_CHECKER(JSSet, JS_SET_TYPE)
TYPE_CHECKER(JSStringIterator, JS_STRING_ITERATOR_TYPE)
TYPE_CHECKER(JSValue, JS_VALUE_TYPE)
TYPE_CHECKER(JSWeakMap, JS_WEAK_MAP_TYPE)
TYPE_CHECKER(JSWeakSet, JS_WEAK_SET_TYPE)
TYPE_CHECKER(MutableHeapNumber, MUTABLE_HEAP_NUMBER_TYPE)
TYPE_CHECKER(Oddball, ODDBALL_TYPE)
TYPE_CHECKER(PreParsedScopeData, TUPLE2_TYPE)
......@@ -567,20 +564,13 @@ CAST_ACCESSOR(JSFunction)
CAST_ACCESSOR(JSGeneratorObject)
CAST_ACCESSOR(JSGlobalObject)
CAST_ACCESSOR(JSGlobalProxy)
CAST_ACCESSOR(JSMap)
CAST_ACCESSOR(JSMapIterator)
CAST_ACCESSOR(JSMessageObject)
CAST_ACCESSOR(JSObject)
CAST_ACCESSOR(JSPromise)
CAST_ACCESSOR(JSProxy)
CAST_ACCESSOR(JSReceiver)
CAST_ACCESSOR(JSSet)
CAST_ACCESSOR(JSSetIterator)
CAST_ACCESSOR(JSStringIterator)
CAST_ACCESSOR(JSValue)
CAST_ACCESSOR(JSWeakCollection)
CAST_ACCESSOR(JSWeakMap)
CAST_ACCESSOR(JSWeakSet)
CAST_ACCESSOR(LayoutDescriptor)
CAST_ACCESSOR(NameDictionary)
CAST_ACCESSOR(NormalizedMapCache)
......@@ -2718,19 +2708,10 @@ ACCESSORS(JSProxy, handler, Object, kHandlerOffset)
bool JSProxy::IsRevoked() const { return !handler()->IsJSReceiver(); }
ACCESSORS(JSCollection, table, Object, kTableOffset)
ACCESSORS(JSCollectionIterator, table, Object, kTableOffset)
ACCESSORS(JSCollectionIterator, index, Object, kIndexOffset)
ACCESSORS(JSWeakCollection, table, Object, kTableOffset)
ACCESSORS(JSWeakCollection, next, Object, kNextOffset)
Address Foreign::foreign_address() {
return AddressFrom<Address>(READ_INTPTR_FIELD(this, kForeignAddressOffset));
}
void Foreign::set_foreign_address(Address value) {
WRITE_INTPTR_FIELD(this, kForeignAddressOffset, OffsetFrom(value));
}
......@@ -3542,15 +3523,6 @@ Object* OrderedHashTableIterator<Derived, TableType>::CurrentKey() {
return key;
}
Object* JSMapIterator::CurrentValue() {
OrderedHashMap* table(OrderedHashMap::cast(this->table()));
int index = Smi::ToInt(this->index());
Object* value = table->ValueAt(index);
DCHECK(!value->IsTheHole(table->GetIsolate()));
return value;
}
// Predictably converts HeapObject* or Address to uint32 by calculating
// offset of the address in respective MemoryChunk.
static inline uint32_t ObjectAddressForHashing(void* object) {
......
......@@ -4426,58 +4426,6 @@ class JSProxy: public JSReceiver {
DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy);
};
class JSCollection : public JSObject {
public:
// [table]: the backing hash table
DECL_ACCESSORS(table, Object)
static const int kTableOffset = JSObject::kHeaderSize;
static const int kSize = kTableOffset + kPointerSize;
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSCollection);
};
// The JSSet describes EcmaScript Harmony sets
// TODO(marja): When moving JSSet out of objects.h, move JSSetIterator (from
// objects/hash-table.h) into the same file.
class JSSet : public JSCollection {
public:
DECL_CAST(JSSet)
static void Initialize(Handle<JSSet> set, Isolate* isolate);
static void Clear(Handle<JSSet> set);
// Dispatched behavior.
DECL_PRINTER(JSSet)
DECL_VERIFIER(JSSet)
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSSet);
};
// The JSMap describes EcmaScript Harmony maps
// TODO(marja): When moving JSMap out of objects.h, move JSMapIterator (from
// objects/hash-table.h) into the same file.
class JSMap : public JSCollection {
public:
DECL_CAST(JSMap)
static void Initialize(Handle<JSMap> map, Isolate* isolate);
static void Clear(Handle<JSMap> map);
// Dispatched behavior.
DECL_PRINTER(JSMap)
DECL_VERIFIER(JSMap)
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSMap);
};
// The [Async-from-Sync Iterator] object
// (proposal-async-iteration/#sec-async-from-sync-iterator-objects)
// An object which wraps an ordinary Iterator and converts it to behave
......@@ -4527,76 +4475,6 @@ class JSStringIterator : public JSObject {
DISALLOW_IMPLICIT_CONSTRUCTORS(JSStringIterator);
};
// Base class for both JSWeakMap and JSWeakSet
class JSWeakCollection: public JSObject {
public:
DECL_CAST(JSWeakCollection)
// [table]: the backing hash table mapping keys to values.
DECL_ACCESSORS(table, Object)
// [next]: linked list of encountered weak maps during GC.
DECL_ACCESSORS(next, Object)
static void Initialize(Handle<JSWeakCollection> collection, Isolate* isolate);
static void Set(Handle<JSWeakCollection> collection, Handle<Object> key,
Handle<Object> value, int32_t hash);
static bool Delete(Handle<JSWeakCollection> collection, Handle<Object> key,
int32_t hash);
static Handle<JSArray> GetEntries(Handle<JSWeakCollection> holder,
int max_entries);
static const int kTableOffset = JSObject::kHeaderSize;
static const int kNextOffset = kTableOffset + kPointerSize;
static const int kSize = kNextOffset + kPointerSize;
// Visiting policy defines whether the table and next collection fields
// should be visited or not.
enum BodyVisitingPolicy { kIgnoreWeakness, kRespectWeakness };
// Iterates the function object according to the visiting policy.
template <BodyVisitingPolicy>
class BodyDescriptorImpl;
// Visit the whole object.
typedef BodyDescriptorImpl<kIgnoreWeakness> BodyDescriptor;
// Don't visit table and next collection fields.
typedef BodyDescriptorImpl<kRespectWeakness> BodyDescriptorWeak;
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSWeakCollection);
};
// The JSWeakMap describes EcmaScript Harmony weak maps
class JSWeakMap: public JSWeakCollection {
public:
DECL_CAST(JSWeakMap)
// Dispatched behavior.
DECL_PRINTER(JSWeakMap)
DECL_VERIFIER(JSWeakMap)
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSWeakMap);
};
// The JSWeakSet describes EcmaScript Harmony weak sets
class JSWeakSet: public JSWeakCollection {
public:
DECL_CAST(JSWeakSet)
// Dispatched behavior.
DECL_PRINTER(JSWeakSet)
DECL_VERIFIER(JSWeakSet)
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSWeakSet);
};
// Foreign describes objects pointing from JavaScript to C structures.
class Foreign: public HeapObject {
public:
......
......@@ -895,37 +895,6 @@ class OrderedHashTableIterator : public JSCollectionIterator {
DISALLOW_IMPLICIT_CONSTRUCTORS(OrderedHashTableIterator);
};
class JSSetIterator
: public OrderedHashTableIterator<JSSetIterator, OrderedHashSet> {
public:
// Dispatched behavior.
DECL_PRINTER(JSSetIterator)
DECL_VERIFIER(JSSetIterator)
DECL_CAST(JSSetIterator)
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSSetIterator);
};
class JSMapIterator
: public OrderedHashTableIterator<JSMapIterator, OrderedHashMap> {
public:
// Dispatched behavior.
DECL_PRINTER(JSMapIterator)
DECL_VERIFIER(JSMapIterator)
DECL_CAST(JSMapIterator)
// Returns the current value of the iterator. This should only be called when
// |HasMore| returns true.
inline Object* CurrentValue();
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSMapIterator);
};
} // namespace internal
} // namespace v8
......
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_OBJECTS_JS_COLLECTION_INL_H_
#define V8_OBJECTS_JS_COLLECTION_INL_H_
#include "src/objects/js-collection.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
namespace v8 {
namespace internal {
ACCESSORS(JSCollection, table, Object, kTableOffset)
ACCESSORS(JSCollectionIterator, table, Object, kTableOffset)
ACCESSORS(JSCollectionIterator, index, Object, kIndexOffset)
ACCESSORS(JSWeakCollection, table, Object, kTableOffset)
ACCESSORS(JSWeakCollection, next, Object, kNextOffset)
TYPE_CHECKER(JSMap, JS_MAP_TYPE)
TYPE_CHECKER(JSSet, JS_SET_TYPE)
TYPE_CHECKER(JSWeakMap, JS_WEAK_MAP_TYPE)
TYPE_CHECKER(JSWeakSet, JS_WEAK_SET_TYPE)
CAST_ACCESSOR(JSSet)
CAST_ACCESSOR(JSSetIterator)
CAST_ACCESSOR(JSMap)
CAST_ACCESSOR(JSMapIterator)
CAST_ACCESSOR(JSWeakCollection)
CAST_ACCESSOR(JSWeakMap)
CAST_ACCESSOR(JSWeakSet)
Object* JSMapIterator::CurrentValue() {
OrderedHashMap* table(OrderedHashMap::cast(this->table()));
int index = Smi::ToInt(this->index());
Object* value = table->ValueAt(index);
DCHECK(!value->IsTheHole(table->GetIsolate()));
return value;
}
} // namespace internal
} // namespace v8
#include "src/objects/object-macros-undef.h"
#endif // V8_OBJECTS_JS_COLLECTION_INL_H_
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_OBJECTS_JS_COLLECTION_H_
#define V8_OBJECTS_JS_COLLECTION_H_
#include "src/objects.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
namespace v8 {
namespace internal {
class JSCollection : public JSObject {
public:
// [table]: the backing hash table
DECL_ACCESSORS(table, Object)
static const int kTableOffset = JSObject::kHeaderSize;
static const int kSize = kTableOffset + kPointerSize;
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSCollection);
};
// The JSSet describes EcmaScript Harmony sets
class JSSet : public JSCollection {
public:
DECL_CAST(JSSet)
static void Initialize(Handle<JSSet> set, Isolate* isolate);
static void Clear(Handle<JSSet> set);
// Dispatched behavior.
DECL_PRINTER(JSSet)
DECL_VERIFIER(JSSet)
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSSet);
};
class JSSetIterator
: public OrderedHashTableIterator<JSSetIterator, OrderedHashSet> {
public:
// Dispatched behavior.
DECL_PRINTER(JSSetIterator)
DECL_VERIFIER(JSSetIterator)
DECL_CAST(JSSetIterator)
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSSetIterator);
};
// The JSMap describes EcmaScript Harmony maps
class JSMap : public JSCollection {
public:
DECL_CAST(JSMap)
static void Initialize(Handle<JSMap> map, Isolate* isolate);
static void Clear(Handle<JSMap> map);
// Dispatched behavior.
DECL_PRINTER(JSMap)
DECL_VERIFIER(JSMap)
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSMap);
};
class JSMapIterator
: public OrderedHashTableIterator<JSMapIterator, OrderedHashMap> {
public:
// Dispatched behavior.
DECL_PRINTER(JSMapIterator)
DECL_VERIFIER(JSMapIterator)
DECL_CAST(JSMapIterator)
// Returns the current value of the iterator. This should only be called when
// |HasMore| returns true.
inline Object* CurrentValue();
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSMapIterator);
};
// Base class for both JSWeakMap and JSWeakSet
class JSWeakCollection : public JSObject {
public:
DECL_CAST(JSWeakCollection)
// [table]: the backing hash table mapping keys to values.
DECL_ACCESSORS(table, Object)
// [next]: linked list of encountered weak maps during GC.
DECL_ACCESSORS(next, Object)
static void Initialize(Handle<JSWeakCollection> collection, Isolate* isolate);
static void Set(Handle<JSWeakCollection> collection, Handle<Object> key,
Handle<Object> value, int32_t hash);
static bool Delete(Handle<JSWeakCollection> collection, Handle<Object> key,
int32_t hash);
static Handle<JSArray> GetEntries(Handle<JSWeakCollection> holder,
int max_entries);
static const int kTableOffset = JSObject::kHeaderSize;
static const int kNextOffset = kTableOffset + kPointerSize;
static const int kSize = kNextOffset + kPointerSize;
// Visiting policy defines whether the table and next collection fields
// should be visited or not.
enum BodyVisitingPolicy { kIgnoreWeakness, kRespectWeakness };
// Iterates the function object according to the visiting policy.
template <BodyVisitingPolicy>
class BodyDescriptorImpl;
// Visit the whole object.
typedef BodyDescriptorImpl<kIgnoreWeakness> BodyDescriptor;
// Don't visit table and next collection fields.
typedef BodyDescriptorImpl<kRespectWeakness> BodyDescriptorWeak;
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSWeakCollection);
};
// The JSWeakMap describes EcmaScript Harmony weak maps
class JSWeakMap : public JSWeakCollection {
public:
DECL_CAST(JSWeakMap)
// Dispatched behavior.
DECL_PRINTER(JSWeakMap)
DECL_VERIFIER(JSWeakMap)
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSWeakMap);
};
// The JSWeakSet describes EcmaScript Harmony weak sets
class JSWeakSet : public JSWeakCollection {
public:
DECL_CAST(JSWeakSet)
// Dispatched behavior.
DECL_PRINTER(JSWeakSet)
DECL_VERIFIER(JSWeakSet)
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSWeakSet);
};
} // namespace internal
} // namespace v8
#include "src/objects/object-macros-undef.h"
#endif // V8_OBJECTS_JS_COLLECTION_H_
......@@ -27,6 +27,8 @@ class HeapIterator;
class HeapProfiler;
class HeapSnapshot;
class JSArrayBuffer;
class JSCollection;
class JSWeakCollection;
class SnapshotFiller;
class HeapGraphEdge BASE_EMBEDDED {
......
......@@ -1175,6 +1175,8 @@
'objects/intl-objects.h',
'objects/js-array.h',
'objects/js-array-inl.h',
'objects/js-collection.h',
'objects/js-collection-inl.h',
'objects/js-regexp.h',
'objects/js-regexp-inl.h',
'objects/literal-objects.cc',
......
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