5 #ifndef V8_OBJECTS_API_CALLBACKS_INL_H_ 6 #define V8_OBJECTS_API_CALLBACKS_INL_H_ 8 #include "src/objects/api-callbacks.h" 10 #include "src/heap/heap-inl.h" 11 #include "src/heap/heap-write-barrier.h" 12 #include "src/objects/name.h" 13 #include "src/objects/templates.h" 16 #include "src/objects/object-macros.h" 21 CAST_ACCESSOR(AccessorInfo)
22 CAST_ACCESSOR(AccessCheckInfo)
23 CAST_ACCESSOR(InterceptorInfo)
24 CAST_ACCESSOR(CallHandlerInfo)
26 ACCESSORS2(AccessorInfo, name, Name, kNameOffset)
27 SMI_ACCESSORS(AccessorInfo, flags, kFlagsOffset)
28 ACCESSORS(AccessorInfo, expected_receiver_type, Object,
29 kExpectedReceiverTypeOffset)
31 ACCESSORS_CHECKED2(AccessorInfo, getter, Object, kGetterOffset,
true,
32 Foreign::IsNormalized(value))
33 ACCESSORS_CHECKED2(AccessorInfo, setter, Object, kSetterOffset,
true,
34 Foreign::IsNormalized(value));
35 ACCESSORS(AccessorInfo, js_getter, Object, kJsGetterOffset)
36 ACCESSORS(AccessorInfo, data, Object, kDataOffset)
38 bool AccessorInfo::has_getter() {
39 bool result = getter() != Smi::kZero;
41 getter() != Smi::kZero &&
42 Foreign::cast(getter())->foreign_address() != kNullAddress);
46 bool AccessorInfo::has_setter() {
47 bool result = setter() != Smi::kZero;
49 setter() != Smi::kZero &&
50 Foreign::cast(setter())->foreign_address() != kNullAddress);
54 BIT_FIELD_ACCESSORS(AccessorInfo, flags, all_can_read,
55 AccessorInfo::AllCanReadBit)
56 BIT_FIELD_ACCESSORS(AccessorInfo, flags, all_can_write,
57 AccessorInfo::AllCanWriteBit)
58 BIT_FIELD_ACCESSORS(AccessorInfo, flags, is_special_data_property,
59 AccessorInfo::IsSpecialDataPropertyBit)
60 BIT_FIELD_ACCESSORS(AccessorInfo, flags, replace_on_access,
61 AccessorInfo::ReplaceOnAccessBit)
62 BIT_FIELD_ACCESSORS(AccessorInfo, flags, is_sloppy, AccessorInfo::IsSloppyBit)
63 BIT_FIELD_ACCESSORS(AccessorInfo, flags, getter_side_effect_type,
64 AccessorInfo::GetterSideEffectTypeBits)
67 return SetterSideEffectTypeBits::decode(flags());
70 void AccessorInfo::set_setter_side_effect_type(
SideEffectType value) {
75 CHECK_NE(value, SideEffectType::kHasNoSideEffect);
76 set_flags(SetterSideEffectTypeBits::update(flags(), value));
79 BIT_FIELD_ACCESSORS(AccessorInfo, flags, initial_property_attributes,
80 AccessorInfo::InitialAttributesBits)
82 bool AccessorInfo::IsCompatibleReceiver(Object* receiver) {
83 if (!HasExpectedReceiverType())
return true;
84 if (!receiver->IsJSObject())
return false;
85 return FunctionTemplateInfo::cast(expected_receiver_type())
86 ->IsTemplateFor(JSObject::cast(receiver)->map());
89 bool AccessorInfo::HasExpectedReceiverType() {
90 return expected_receiver_type()->IsFunctionTemplateInfo();
93 ACCESSORS(AccessCheckInfo, callback, Object, kCallbackOffset)
94 ACCESSORS(AccessCheckInfo, named_interceptor, Object, kNamedInterceptorOffset)
95 ACCESSORS(AccessCheckInfo, indexed_interceptor, Object,
96 kIndexedInterceptorOffset)
97 ACCESSORS(AccessCheckInfo, data, Object, kDataOffset)
99 ACCESSORS(InterceptorInfo, getter, Object, kGetterOffset)
100 ACCESSORS(InterceptorInfo, setter, Object, kSetterOffset)
101 ACCESSORS(InterceptorInfo, query, Object, kQueryOffset)
102 ACCESSORS(InterceptorInfo, descriptor, Object, kDescriptorOffset)
103 ACCESSORS(InterceptorInfo, deleter, Object, kDeleterOffset)
104 ACCESSORS(InterceptorInfo, enumerator, Object, kEnumeratorOffset)
105 ACCESSORS(InterceptorInfo, definer, Object, kDefinerOffset)
106 ACCESSORS(InterceptorInfo, data, Object, kDataOffset)
107 SMI_ACCESSORS(InterceptorInfo, flags, kFlagsOffset)
108 BOOL_ACCESSORS(InterceptorInfo, flags, can_intercept_symbols,
109 kCanInterceptSymbolsBit)
110 BOOL_ACCESSORS(InterceptorInfo, flags, all_can_read, kAllCanReadBit)
111 BOOL_ACCESSORS(InterceptorInfo, flags, non_masking,
kNonMasking)
112 BOOL_ACCESSORS(InterceptorInfo, flags, is_named, kNamed)
113 BOOL_ACCESSORS(InterceptorInfo, flags, has_no_side_effect, kHasNoSideEffect)
115 ACCESSORS(CallHandlerInfo, callback, Object, kCallbackOffset)
116 ACCESSORS(CallHandlerInfo, js_callback, Object, kJsCallbackOffset)
117 ACCESSORS(CallHandlerInfo, data, Object, kDataOffset)
119 bool CallHandlerInfo::IsSideEffectFreeCallHandlerInfo()
const {
120 ReadOnlyRoots roots = GetReadOnlyRoots();
121 DCHECK(map() == roots.side_effect_call_handler_info_map() ||
122 map() == roots.side_effect_free_call_handler_info_map() ||
123 map() == roots.next_call_side_effect_free_call_handler_info_map());
124 return map() == roots.side_effect_free_call_handler_info_map();
127 bool CallHandlerInfo::IsSideEffectCallHandlerInfo()
const {
128 ReadOnlyRoots roots = GetReadOnlyRoots();
129 DCHECK(map() == roots.side_effect_call_handler_info_map() ||
130 map() == roots.side_effect_free_call_handler_info_map() ||
131 map() == roots.next_call_side_effect_free_call_handler_info_map());
132 return map() == roots.side_effect_call_handler_info_map();
135 void CallHandlerInfo::SetNextCallHasNoSideEffect() {
137 GetReadOnlyRoots().next_call_side_effect_free_call_handler_info_map());
140 bool CallHandlerInfo::NextCallHasNoSideEffect() {
141 ReadOnlyRoots roots = GetReadOnlyRoots();
142 if (map() == roots.next_call_side_effect_free_call_handler_info_map()) {
143 set_map(roots.side_effect_call_handler_info_map());
152 #include "src/objects/object-macros-undef.h" 154 #endif // V8_OBJECTS_API_CALLBACKS_INL_H_