Commit 7271e7c5 authored by Seth Brenith's avatar Seth Brenith Committed by Commit Bot

[torque] Improve field types for PrototypeInfo

This is a partial reland of https://crrev.com/c/v8/v8/+/2199640 . It
includes removing an unused field.

Change-Id: Iffc56a2bee751758dcba5c1ec162dcf9258db62d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2216303Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: Seth Brenith <seth.brenith@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#68021}
parent a688b8b1
......@@ -20,9 +20,7 @@
namespace v8 {
namespace internal {
OBJECT_CONSTRUCTORS_IMPL(PrototypeInfo, Struct)
CAST_ACCESSOR(PrototypeInfo)
TQ_OBJECT_CONSTRUCTORS_IMPL(PrototypeInfo)
Map PrototypeInfo::ObjectCreateMap() {
return Map::cast(object_create_map()->GetHeapObjectAssumeWeak());
......@@ -39,14 +37,8 @@ bool PrototypeInfo::HasObjectCreateMap() {
return cache->IsWeak();
}
ACCESSORS(PrototypeInfo, module_namespace, Object, kJsModuleNamespaceOffset)
ACCESSORS(PrototypeInfo, prototype_users, Object, kPrototypeUsersOffset)
ACCESSORS(PrototypeInfo, prototype_chain_enum_cache, Object,
kPrototypeChainEnumCacheOffset)
WEAK_ACCESSORS(PrototypeInfo, object_create_map, kObjectCreateMapOffset)
SMI_ACCESSORS(PrototypeInfo, registry_slot, kRegistrySlotOffset)
SMI_ACCESSORS(PrototypeInfo, bit_field, kBitFieldOffset)
BOOL_ACCESSORS(PrototypeInfo, bit_field, should_be_fast_map, kShouldBeFastBit)
BOOL_ACCESSORS(PrototypeInfo, bit_field, should_be_fast_map,
ShouldBeFastBit::kShift)
void PrototypeUsers::MarkSlotEmpty(WeakArrayList array, int index) {
DCHECK_GT(index, 0);
......
......@@ -8,6 +8,7 @@
#include "src/objects/fixed-array.h"
#include "src/objects/objects.h"
#include "src/objects/struct.h"
#include "torque-generated/bit-fields-tq.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
......@@ -16,57 +17,29 @@ namespace v8 {
namespace internal {
// Container for metadata stored on each prototype map.
class PrototypeInfo : public Struct {
class PrototypeInfo
: public TorqueGeneratedPrototypeInfo<PrototypeInfo, Struct> {
public:
static const int UNREGISTERED = -1;
// [module_namespace]: A backpointer to JSModuleNamespace from its
// PrototypeInfo (or undefined). This field is only used for JSModuleNamespace
// maps. TODO(jkummerow): Figure out if there's a way to store the namespace
// pointer elsewhere to save memory.
DECL_ACCESSORS(module_namespace, Object)
// [prototype_users]: WeakArrayList containing weak references to maps using
// this prototype, or Smi(0) if uninitialized.
DECL_ACCESSORS(prototype_users, Object)
DECL_ACCESSORS(prototype_chain_enum_cache, Object)
// [object_create_map]: A field caching the map for Object.create(prototype).
static inline void SetObjectCreateMap(Handle<PrototypeInfo> info,
Handle<Map> map);
inline Map ObjectCreateMap();
inline bool HasObjectCreateMap();
// [registry_slot]: Slot in prototype's user registry where this user
// is stored. Returns UNREGISTERED if this prototype has not been registered.
inline int registry_slot() const;
inline void set_registry_slot(int slot);
// [bit_field]
inline int bit_field() const;
inline void set_bit_field(int bit_field);
DECL_BOOLEAN_ACCESSORS(should_be_fast_map)
DECL_CAST(PrototypeInfo)
// Dispatched behavior.
DECL_PRINTER(PrototypeInfo)
DECL_VERIFIER(PrototypeInfo)
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
TORQUE_GENERATED_PROTOTYPE_INFO_FIELDS)
// Bit field usage.
static const int kShouldBeFastBit = 0;
DEFINE_TORQUE_GENERATED_PROTOTYPE_INFO_FLAGS()
class BodyDescriptor;
private:
DECL_ACCESSORS(object_create_map, MaybeObject)
OBJECT_CONSTRUCTORS(PrototypeInfo, Struct);
TQ_OBJECT_CONSTRUCTORS(PrototypeInfo)
};
// A growing array with an additional API for marking slots "empty". When adding
......
......@@ -2,14 +2,32 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
bitfield struct PrototypeInfoFlags extends uint31 {
should_be_fast: bool: 1 bit;
}
@generateCppClass
extern class PrototypeInfo extends Struct {
js_module_namespace: JSModuleNamespace|Undefined;
// [module_namespace]: A backpointer to JSModuleNamespace from its
// PrototypeInfo (or undefined). This field is only used for JSModuleNamespace
// maps. TODO(jkummerow): Figure out if there's a way to store the namespace
// pointer elsewhere to save memory.
module_namespace: JSModuleNamespace|Undefined;
// [prototype_users]: WeakArrayList containing weak references to maps using
// this prototype, or Smi(0) if uninitialized.
prototype_users: WeakArrayList|Zero;
prototype_chain_enum_cache: FixedArray|Object|Undefined;
prototype_chain_enum_cache: FixedArray|Zero|Undefined;
// [registry_slot]: Slot in prototype's user registry where this user
// is stored. Returns UNREGISTERED if this prototype has not been registered.
registry_slot: Smi;
validity_cell: Object;
// [object_create_map]: A field caching the map for Object.create(prototype).
object_create_map: Weak<Map>|Undefined;
bit_field: Smi;
bit_field: SmiTagged<PrototypeInfoFlags>;
}
extern macro PrototypeInfoMapConstant(): Map;
......
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