data-handler.h 2.08 KB
Newer Older
1 2 3 4
// 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.

5 6
#ifndef V8_OBJECTS_DATA_HANDLER_H_
#define V8_OBJECTS_DATA_HANDLER_H_
7

8
#include "src/objects/struct.h"
9 10 11 12 13 14 15 16 17

// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"

namespace v8 {
namespace internal {

// DataHandler is a base class for load and store handlers that can't be
// encoded in one Smi. Kind of a handler can be deduced from instance type.
18
class DataHandler : public Struct {
19 20 21 22 23 24 25 26 27 28
 public:
  // [smi_handler]: A Smi which encodes a handler or Code object (we still
  // use code handlers for accessing lexical environment variables, but soon
  // only smi handlers will remain). See LoadHandler and StoreHandler for
  // details about encoding.
  DECL_ACCESSORS(smi_handler, Object)

  // [validity_cell]: A validity Cell that guards prototype chain modifications.
  DECL_ACCESSORS(validity_cell, Object)

29 30 31
  // Returns number of optional data fields available in the object.
  inline int data_field_count() const;

32
  // [data1-3]: These are optional general-purpose fields whose content and
33
  // presence depends on the handler kind.
34 35 36
  DECL_ACCESSORS(data1, MaybeObject)
  DECL_ACCESSORS(data2, MaybeObject)
  DECL_ACCESSORS(data3, MaybeObject)
37 38

// Layout description.
39 40 41 42 43 44 45 46 47
#define DATA_HANDLER_FIELDS(V)        \
  V(kSmiHandlerOffset, kTaggedSize)   \
  V(kValidityCellOffset, kTaggedSize) \
  V(kSizeWithData0, 0)                \
  V(kData1Offset, kTaggedSize)        \
  V(kSizeWithData1, 0)                \
  V(kData2Offset, kTaggedSize)        \
  V(kSizeWithData2, 0)                \
  V(kData3Offset, kTaggedSize)        \
48
  V(kSizeWithData3, 0)
49 50 51 52

  DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, DATA_HANDLER_FIELDS)
#undef DATA_HANDLER_FIELDS

53
  DECL_CAST(DataHandler)
54 55

  DECL_VERIFIER(DataHandler)
56 57

  class BodyDescriptor;
58

59
  OBJECT_CONSTRUCTORS(DataHandler, Struct);
60 61 62 63 64 65 66
};

}  // namespace internal
}  // namespace v8

#include "src/objects/object-macros-undef.h"

67
#endif  // V8_OBJECTS_DATA_HANDLER_H_