• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 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_DATA_HANDLER_H_
6 #define V8_OBJECTS_DATA_HANDLER_H_
7 
8 #include "src/objects/struct.h"
9 #include "torque-generated/field-offsets.h"
10 
11 // Has to be the last include (doesn't have include guards):
12 #include "src/objects/object-macros.h"
13 
14 namespace v8 {
15 namespace internal {
16 
17 #include "torque-generated/src/objects/data-handler-tq.inc"
18 
19 // DataHandler is a base class for load and store handlers that can't be
20 // encoded in one Smi. Kind of a handler can be deduced from instance type.
21 class DataHandler : public Struct {
22  public:
23   // [smi_handler]: A Smi which encodes a handler or Code object (we still
24   // use code handlers for accessing lexical environment variables, but soon
25   // only smi handlers will remain). See LoadHandler and StoreHandler for
26   // details about encoding.
27   DECL_ACCESSORS(smi_handler, Object)
28 
29   // [validity_cell]: A validity Cell that guards prototype chain modifications.
30   DECL_ACCESSORS(validity_cell, Object)
31 
32   // Returns number of optional data fields available in the object.
33   inline int data_field_count() const;
34 
35   // [data1-3]: These are optional general-purpose fields whose content and
36   // presence depends on the handler kind.
37   DECL_ACCESSORS(data1, MaybeObject)
38   DECL_ACCESSORS(data2, MaybeObject)
39   DECL_ACCESSORS(data3, MaybeObject)
40 
41   DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
42                                 TORQUE_GENERATED_DATA_HANDLER_FIELDS)
43 
44   static const int kSizeWithData0 = kData1Offset;
45   static const int kSizeWithData1 = kData2Offset;
46   static const int kSizeWithData2 = kData3Offset;
47   static const int kSizeWithData3 = kHeaderSize;
48 
49   DECL_CAST(DataHandler)
50 
51   DECL_VERIFIER(DataHandler)
52 
53   class BodyDescriptor;
54 
55   OBJECT_CONSTRUCTORS(DataHandler, Struct);
56 };
57 
58 }  // namespace internal
59 }  // namespace v8
60 
61 #include "src/objects/object-macros-undef.h"
62 
63 #endif  // V8_OBJECTS_DATA_HANDLER_H_
64