• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_OBJECTS_PROPERTY_H_
6 #define V8_OBJECTS_PROPERTY_H_
7 
8 #include <iosfwd>
9 
10 #include "src/common/globals.h"
11 #include "src/handles/handles.h"
12 #include "src/handles/maybe-handles.h"
13 #include "src/objects/name.h"
14 #include "src/objects/objects.h"
15 #include "src/objects/property-details.h"
16 
17 namespace v8 {
18 namespace internal {
19 
20 // Abstraction for elements in instance-descriptor arrays.
21 //
22 // Each descriptor has a key, property attributes, property type,
23 // property index (in the actual instance-descriptor array) and
24 // optionally a piece of data.
25 class V8_EXPORT_PRIVATE Descriptor final {
26  public:
27   Descriptor();
28 
GetKey()29   Handle<Name> GetKey() const { return key_; }
GetValue()30   MaybeObjectHandle GetValue() const { return value_; }
GetDetails()31   PropertyDetails GetDetails() const { return details_; }
32 
SetSortedKeyIndex(int index)33   void SetSortedKeyIndex(int index) { details_ = details_.set_pointer(index); }
34 
35   static Descriptor DataField(Isolate* isolate, Handle<Name> key,
36                               int field_index, PropertyAttributes attributes,
37                               Representation representation);
38 
39   static Descriptor DataField(Handle<Name> key, int field_index,
40                               PropertyAttributes attributes,
41                               PropertyConstness constness,
42                               Representation representation,
43                               const MaybeObjectHandle& wrapped_field_type);
44 
45   static Descriptor DataConstant(Handle<Name> key, Handle<Object> value,
46                                  PropertyAttributes attributes);
47 
48   static Descriptor DataConstant(Isolate* isolate, Handle<Name> key,
49                                  int field_index, Handle<Object> value,
50                                  PropertyAttributes attributes);
51 
52   static Descriptor AccessorConstant(Handle<Name> key, Handle<Object> foreign,
53                                      PropertyAttributes attributes);
54 
55  private:
56   Handle<Name> key_;
57   MaybeObjectHandle value_;
58   PropertyDetails details_;
59 
60  protected:
61   Descriptor(Handle<Name> key, const MaybeObjectHandle& value,
62              PropertyDetails details);
63 
64   Descriptor(Handle<Name> key, const MaybeObjectHandle& value,
65              PropertyKind kind, PropertyAttributes attributes,
66              PropertyLocation location, PropertyConstness constness,
67              Representation representation, int field_index);
68 
69   friend class MapUpdater;
70 };
71 
72 }  // namespace internal
73 }  // namespace v8
74 
75 #endif  // V8_OBJECTS_PROPERTY_H_
76