LCOV - code coverage report
Current view: top level - src/objects - api-callbacks.h (source / functions) Hit Total Coverage
Test: app.info Lines: 2 2 100.0 %
Date: 2019-03-21 Functions: 2 2 100.0 %

          Line data    Source code
       1             : // Copyright 2018 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_API_CALLBACKS_H_
       6             : #define V8_OBJECTS_API_CALLBACKS_H_
       7             : 
       8             : #include "src/objects/struct.h"
       9             : 
      10             : // Has to be the last include (doesn't have include guards):
      11             : #include "src/objects/object-macros.h"
      12             : 
      13             : namespace v8 {
      14             : namespace internal {
      15             : 
      16             : // An accessor must have a getter, but can have no setter.
      17             : //
      18             : // When setting a property, V8 searches accessors in prototypes.
      19             : // If an accessor was found and it does not have a setter,
      20             : // the request is ignored.
      21             : //
      22             : // If the accessor in the prototype has the READ_ONLY property attribute, then
      23             : // a new value is added to the derived object when the property is set.
      24             : // This shadows the accessor in the prototype.
      25             : class AccessorInfo : public Struct {
      26             :  public:
      27             :   DECL_ACCESSORS(name, Name)
      28             :   DECL_INT_ACCESSORS(flags)
      29             :   DECL_ACCESSORS(expected_receiver_type, Object)
      30             :   // This directly points at a foreign C function to be used from the runtime.
      31             :   DECL_ACCESSORS(getter, Object)
      32             :   inline bool has_getter();
      33             :   DECL_ACCESSORS(setter, Object)
      34             :   inline bool has_setter();
      35             :   // This either points at the same as above, or a trampoline in case we are
      36             :   // running with the simulator. Use these entries from generated code.
      37             :   DECL_ACCESSORS(js_getter, Object)
      38             :   DECL_ACCESSORS(data, Object)
      39             : 
      40             :   static Address redirect(Address address, AccessorComponent component);
      41             :   Address redirected_getter() const;
      42             : 
      43             :   // Dispatched behavior.
      44             :   DECL_PRINTER(AccessorInfo)
      45             : 
      46             :   DECL_BOOLEAN_ACCESSORS(all_can_read)
      47             :   DECL_BOOLEAN_ACCESSORS(all_can_write)
      48             :   DECL_BOOLEAN_ACCESSORS(is_special_data_property)
      49             :   DECL_BOOLEAN_ACCESSORS(replace_on_access)
      50             :   DECL_BOOLEAN_ACCESSORS(is_sloppy)
      51             : 
      52             :   inline SideEffectType getter_side_effect_type() const;
      53             :   inline void set_getter_side_effect_type(SideEffectType type);
      54             : 
      55             :   inline SideEffectType setter_side_effect_type() const;
      56             :   inline void set_setter_side_effect_type(SideEffectType type);
      57             : 
      58             :   // The property attributes used when an API object template is instantiated
      59             :   // for the first time. Changing of this value afterwards does not affect
      60             :   // the actual attributes of a property.
      61             :   inline PropertyAttributes initial_property_attributes() const;
      62             :   inline void set_initial_property_attributes(PropertyAttributes attributes);
      63             : 
      64             :   // Checks whether the given receiver is compatible with this accessor.
      65             :   static bool IsCompatibleReceiverMap(Handle<AccessorInfo> info,
      66             :                                       Handle<Map> map);
      67             :   inline bool IsCompatibleReceiver(Object receiver);
      68             : 
      69             :   DECL_CAST(AccessorInfo)
      70             : 
      71             :   // Dispatched behavior.
      72             :   DECL_VERIFIER(AccessorInfo)
      73             : 
      74             :   // Append all descriptors to the array that are not already there.
      75             :   // Return number added.
      76             :   static int AppendUnique(Isolate* isolate, Handle<Object> descriptors,
      77             :                           Handle<FixedArray> array, int valid_descriptors);
      78             : 
      79             :   // Layout description.
      80             :   DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
      81             :                                 TORQUE_GENERATED_ACCESSOR_INFO_FIELDS)
      82             : 
      83             :  private:
      84             :   inline bool HasExpectedReceiverType();
      85             : 
      86             : // Bit positions in |flags|.
      87             : #define ACCESSOR_INFO_FLAGS_BIT_FIELDS(V, _)                           \
      88             :   V(AllCanReadBit, bool, 1, _)                                         \
      89             :   V(AllCanWriteBit, bool, 1, _)                                        \
      90             :   V(IsSpecialDataPropertyBit, bool, 1, _)                              \
      91             :   V(IsSloppyBit, bool, 1, _)                                           \
      92             :   V(ReplaceOnAccessBit, bool, 1, _)                                    \
      93             :   V(GetterSideEffectTypeBits, SideEffectType, 2, _)                    \
      94             :   /* We could save a bit from setter side-effect type, if necessary */ \
      95             :   V(SetterSideEffectTypeBits, SideEffectType, 2, _)                    \
      96             :   V(InitialAttributesBits, PropertyAttributes, 3, _)
      97             : 
      98             :   DEFINE_BIT_FIELDS(ACCESSOR_INFO_FLAGS_BIT_FIELDS)
      99             : #undef ACCESSOR_INFO_FLAGS_BIT_FIELDS
     100             : 
     101        1848 :   OBJECT_CONSTRUCTORS(AccessorInfo, Struct);
     102             : };
     103             : 
     104             : class AccessCheckInfo : public Struct {
     105             :  public:
     106             :   DECL_ACCESSORS(callback, Object)
     107             :   DECL_ACCESSORS(named_interceptor, Object)
     108             :   DECL_ACCESSORS(indexed_interceptor, Object)
     109             :   DECL_ACCESSORS(data, Object)
     110             : 
     111             :   DECL_CAST(AccessCheckInfo)
     112             : 
     113             :   // Dispatched behavior.
     114             :   DECL_PRINTER(AccessCheckInfo)
     115             :   DECL_VERIFIER(AccessCheckInfo)
     116             : 
     117             :   static AccessCheckInfo Get(Isolate* isolate, Handle<JSObject> receiver);
     118             : 
     119             :   DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
     120             :                                 TORQUE_GENERATED_ACCESS_CHECK_INFO_FIELDS)
     121             : 
     122             :   OBJECT_CONSTRUCTORS(AccessCheckInfo, Struct);
     123             : };
     124             : 
     125             : class InterceptorInfo : public Struct {
     126             :  public:
     127             :   DECL_ACCESSORS(getter, Object)
     128             :   DECL_ACCESSORS(setter, Object)
     129             :   DECL_ACCESSORS(query, Object)
     130             :   DECL_ACCESSORS(descriptor, Object)
     131             :   DECL_ACCESSORS(deleter, Object)
     132             :   DECL_ACCESSORS(enumerator, Object)
     133             :   DECL_ACCESSORS(definer, Object)
     134             :   DECL_ACCESSORS(data, Object)
     135             :   DECL_BOOLEAN_ACCESSORS(can_intercept_symbols)
     136             :   DECL_BOOLEAN_ACCESSORS(all_can_read)
     137             :   DECL_BOOLEAN_ACCESSORS(non_masking)
     138             :   DECL_BOOLEAN_ACCESSORS(is_named)
     139             :   DECL_BOOLEAN_ACCESSORS(has_no_side_effect)
     140             : 
     141             :   inline int flags() const;
     142             :   inline void set_flags(int flags);
     143             : 
     144             :   DECL_CAST(InterceptorInfo)
     145             : 
     146             :   // Dispatched behavior.
     147             :   DECL_PRINTER(InterceptorInfo)
     148             :   DECL_VERIFIER(InterceptorInfo)
     149             : 
     150             :   DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
     151             :                                 TORQUE_GENERATED_INTERCEPTOR_INFO_FIELDS)
     152             : 
     153             :   static const int kCanInterceptSymbolsBit = 0;
     154             :   static const int kAllCanReadBit = 1;
     155             :   static const int kNonMasking = 2;
     156             :   static const int kNamed = 3;
     157             :   static const int kHasNoSideEffect = 4;
     158             : 
     159         112 :   OBJECT_CONSTRUCTORS(InterceptorInfo, Struct);
     160             : };
     161             : 
     162             : class CallHandlerInfo : public Tuple3 {
     163             :  public:
     164             :   DECL_ACCESSORS(callback, Object)
     165             :   DECL_ACCESSORS(js_callback, Object)
     166             :   DECL_ACCESSORS(data, Object)
     167             : 
     168             :   DECL_CAST(CallHandlerInfo)
     169             : 
     170             :   inline bool IsSideEffectFreeCallHandlerInfo() const;
     171             :   inline bool IsSideEffectCallHandlerInfo() const;
     172             :   inline void SetNextCallHasNoSideEffect();
     173             :   // Returns whether or not the next call can be side effect free.
     174             :   // Calling this will change the state back to having a side effect.
     175             :   inline bool NextCallHasNoSideEffect();
     176             : 
     177             :   // Dispatched behavior.
     178             :   DECL_PRINTER(CallHandlerInfo)
     179             :   DECL_VERIFIER(CallHandlerInfo)
     180             : 
     181             :   Address redirected_callback() const;
     182             : 
     183             :   static const int kCallbackOffset = kValue1Offset;
     184             :   static const int kJsCallbackOffset = kValue2Offset;
     185             :   static const int kDataOffset = kValue3Offset;
     186             : 
     187             :   OBJECT_CONSTRUCTORS(CallHandlerInfo, Tuple3);
     188             : };
     189             : 
     190             : }  // namespace internal
     191             : }  // namespace v8
     192             : 
     193             : #include "src/objects/object-macros-undef.h"
     194             : 
     195             : #endif  // V8_OBJECTS_API_CALLBACKS_H_

Generated by: LCOV version 1.10