[objects.h splitting] Move classes related to api callbacks.

BUG=v8:5402,v8:7570

Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
Change-Id: I56beb15109a3557ba514e8d17880b1a37a109031
Reviewed-on: https://chromium-review.googlesource.com/1032552
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52908}
This commit is contained in:
Marja Hölttä 2018-04-30 15:27:37 +02:00 committed by Commit Bot
parent 23d38099da
commit a9db2c74b5
34 changed files with 359 additions and 283 deletions

View File

@ -2012,6 +2012,8 @@ v8_source_set("v8_base") {
"src/objects-printer.cc",
"src/objects.cc",
"src/objects.h",
"src/objects/api-callbacks-inl.h",
"src/objects/api-callbacks.h",
"src/objects/arguments-inl.h",
"src/objects/arguments.h",
"src/objects/bigint.cc",

View File

@ -12,6 +12,7 @@
#include "src/heap/factory.h"
#include "src/isolate-inl.h"
#include "src/messages.h"
#include "src/objects/api-callbacks.h"
#include "src/property-details.h"
#include "src/prototype.h"

View File

@ -7,6 +7,7 @@
#include "src/api-arguments.h"
#include "src/objects/api-callbacks.h"
#include "src/tracing/trace-event.h"
#include "src/vm-state-inl.h"

View File

@ -8,6 +8,7 @@
#include "src/isolate-inl.h"
#include "src/lookup.h"
#include "src/messages.h"
#include "src/objects/api-callbacks.h"
#include "src/objects/templates.h"
namespace v8 {

View File

@ -49,6 +49,7 @@
#include "src/json-stringifier.h"
#include "src/messages.h"
#include "src/objects-inl.h"
#include "src/objects/api-callbacks.h"
#include "src/objects/templates.h"
#include "src/parsing/parser.h"
#include "src/parsing/scanner-character-streams.h"

View File

@ -17,6 +17,7 @@
#include "src/ic/ic.h"
#include "src/ic/stub-cache.h"
#include "src/isolate.h"
#include "src/objects/api-callbacks.h"
#include "src/objects/regexp-match-info.h"
#include "src/regexp/jsregexp.h"
#include "src/regexp/regexp-macro-assembler.h"

View File

@ -16,6 +16,7 @@
#include "src/ic/ic.h"
#include "src/ic/stub-cache.h"
#include "src/isolate.h"
#include "src/objects/api-callbacks.h"
#include "src/objects/regexp-match-info.h"
#include "src/regexp/jsregexp.h"
#include "src/regexp/regexp-macro-assembler.h"

View File

@ -19,6 +19,7 @@
#include "src/extensions/trigger-failure-extension.h"
#include "src/heap/heap.h"
#include "src/isolate-inl.h"
#include "src/objects/api-callbacks.h"
#include "src/objects/js-regexp.h"
#include "src/objects/templates.h"
#include "src/snapshot/natives.h"

View File

@ -9,6 +9,7 @@
#include "src/counters.h"
#include "src/messages.h"
#include "src/objects-inl.h"
#include "src/objects/api-callbacks.h"
#include "src/property-descriptor.h"
#include "src/string-builder.h"

View File

@ -6,6 +6,7 @@
#include "src/builtins/builtins.h"
#include "src/code-stub-assembler.h"
#include "src/frame-constants.h"
#include "src/objects/api-callbacks.h"
#include "src/objects/descriptor-array.h"
namespace v8 {

View File

@ -10,6 +10,7 @@
#include "src/counters.h"
#include "src/lookup.h"
#include "src/objects-inl.h"
#include "src/objects/api-callbacks.h"
#include "src/string-builder.h"
namespace v8 {

View File

@ -7,6 +7,7 @@
#include "src/code-factory.h"
#include "src/frames-inl.h"
#include "src/frames.h"
#include "src/objects/api-callbacks.h"
namespace v8 {
namespace internal {

View File

@ -16,6 +16,7 @@
#include "src/interpreter/bytecode-array-iterator.h"
#include "src/interpreter/bytecodes.h"
#include "src/isolate-inl.h"
#include "src/objects/api-callbacks.h"
#include "src/snapshot/snapshot.h"
namespace v8 {

View File

@ -15,6 +15,7 @@
#include "src/interpreter/interpreter.h"
#include "src/isolate-inl.h"
#include "src/macro-assembler.h"
#include "src/objects/api-callbacks.h"
#include "src/objects/bigint.h"
#include "src/objects/debug-objects-inl.h"
#include "src/objects/frame-array-inl.h"

View File

@ -27,6 +27,7 @@ class BreakPoint;
class BreakPointInfo;
class CallableTask;
class CallbackTask;
class CallHandlerInfo;
class ConstantElementsPair;
class CoverageInfo;
class DebugInfo;

View File

@ -23,6 +23,7 @@
#include "src/log.h"
#include "src/msan.h"
#include "src/objects-inl.h"
#include "src/objects/api-callbacks-inl.h"
#include "src/objects/descriptor-array.h"
#include "src/objects/literal-objects.h"
#include "src/objects/scope-info.h"

View File

@ -15,6 +15,7 @@
#include "src/ic/ic.h"
#include "src/ic/stub-cache.h"
#include "src/isolate.h"
#include "src/objects/api-callbacks.h"
#include "src/regexp/jsregexp.h"
#include "src/regexp/regexp-macro-assembler.h"
#include "src/runtime/runtime.h"

View File

@ -20,6 +20,7 @@
#include "src/ic/stub-cache.h"
#include "src/isolate-inl.h"
#include "src/macro-assembler.h"
#include "src/objects/api-callbacks.h"
#include "src/prototype.h"
#include "src/runtime-profiler.h"
#include "src/runtime/runtime-utils.h"

View File

@ -10,6 +10,7 @@
#include "src/identity-map.h"
#include "src/isolate-inl.h"
#include "src/objects-inl.h"
#include "src/objects/api-callbacks.h"
#include "src/property-descriptor.h"
#include "src/prototype.h"

View File

@ -22,6 +22,7 @@
#include "src/libsampler/sampler.h"
#include "src/log-inl.h"
#include "src/macro-assembler.h"
#include "src/objects/api-callbacks.h"
#include "src/perf-jit.h"
#include "src/profiler/profiler-listener.h"
#include "src/profiler/tick-sample.h"

View File

@ -14,6 +14,7 @@
#include "src/ic/ic.h"
#include "src/ic/stub-cache.h"
#include "src/isolate.h"
#include "src/objects/api-callbacks.h"
#include "src/regexp/jsregexp.h"
#include "src/regexp/regexp-macro-assembler.h"
#include "src/runtime/runtime.h"

View File

@ -13,6 +13,7 @@
#include "src/ic/ic.h"
#include "src/ic/stub-cache.h"
#include "src/isolate.h"
#include "src/objects/api-callbacks.h"
#include "src/regexp/jsregexp.h"
#include "src/regexp/regexp-macro-assembler.h"
#include "src/runtime/runtime.h"

View File

@ -81,7 +81,6 @@ TYPE_CHECKER(BigInt, BIGINT_TYPE)
TYPE_CHECKER(BoilerplateDescription, BOILERPLATE_DESCRIPTION_TYPE)
TYPE_CHECKER(BreakPoint, TUPLE2_TYPE)
TYPE_CHECKER(BreakPointInfo, TUPLE2_TYPE)
TYPE_CHECKER(CallHandlerInfo, CALL_HANDLER_INFO_TYPE)
TYPE_CHECKER(Cell, CELL_TYPE)
TYPE_CHECKER(ConstantElementsPair, TUPLE2_TYPE)
TYPE_CHECKER(CoverageInfo, FIXED_ARRAY_TYPE)
@ -564,15 +563,12 @@ bool Object::IsMinusZero() const {
// ------------------------------------
// Cast operations
CAST_ACCESSOR(AccessCheckInfo)
CAST_ACCESSOR(AccessorInfo)
CAST_ACCESSOR(AccessorPair)
CAST_ACCESSOR(AllocationMemento)
CAST_ACCESSOR(AllocationSite)
CAST_ACCESSOR(AsyncGeneratorRequest)
CAST_ACCESSOR(BigInt)
CAST_ACCESSOR(BoilerplateDescription)
CAST_ACCESSOR(CallHandlerInfo)
CAST_ACCESSOR(Cell)
CAST_ACCESSOR(ConstantElementsPair)
CAST_ACCESSOR(ContextExtension)
@ -582,7 +578,6 @@ CAST_ACCESSOR(FeedbackCell)
CAST_ACCESSOR(Foreign)
CAST_ACCESSOR(GlobalDictionary)
CAST_ACCESSOR(HeapObject)
CAST_ACCESSOR(InterceptorInfo)
CAST_ACCESSOR(JSAsyncFromSyncIterator)
CAST_ACCESSOR(JSAsyncGeneratorObject)
CAST_ACCESSOR(JSBoundFunction)
@ -2294,33 +2289,6 @@ ACCESSORS(JSGlobalObject, global_proxy, JSObject, kGlobalProxyOffset)
ACCESSORS(JSGlobalProxy, native_context, Object, kNativeContextOffset)
ACCESSORS(AccessorInfo, name, Name, kNameOffset)
SMI_ACCESSORS(AccessorInfo, flags, kFlagsOffset)
ACCESSORS(AccessorInfo, expected_receiver_type, Object,
kExpectedReceiverTypeOffset)
ACCESSORS_CHECKED2(AccessorInfo, getter, Object, kGetterOffset, true,
Foreign::IsNormalized(value))
ACCESSORS_CHECKED2(AccessorInfo, setter, Object, kSetterOffset, true,
Foreign::IsNormalized(value));
ACCESSORS(AccessorInfo, js_getter, Object, kJsGetterOffset)
ACCESSORS(AccessorInfo, data, Object, kDataOffset)
bool AccessorInfo::has_getter() {
bool result = getter() != Smi::kZero;
DCHECK_EQ(result,
getter() != Smi::kZero &&
Foreign::cast(getter())->foreign_address() != kNullAddress);
return result;
}
bool AccessorInfo::has_setter() {
bool result = setter() != Smi::kZero;
DCHECK_EQ(result,
setter() != Smi::kZero &&
Foreign::cast(setter())->foreign_address() != kNullAddress);
return result;
}
ACCESSORS(AsyncGeneratorRequest, next, Object, kNextOffset)
SMI_ACCESSORS(AsyncGeneratorRequest, resume_mode, kResumeModeOffset)
@ -2371,38 +2339,6 @@ ACCESSORS(TemplateObjectDescription, cooked_strings, FixedArray,
ACCESSORS(AccessorPair, getter, Object, kGetterOffset)
ACCESSORS(AccessorPair, setter, Object, kSetterOffset)
ACCESSORS(AccessCheckInfo, callback, Object, kCallbackOffset)
ACCESSORS(AccessCheckInfo, named_interceptor, Object, kNamedInterceptorOffset)
ACCESSORS(AccessCheckInfo, indexed_interceptor, Object,
kIndexedInterceptorOffset)
ACCESSORS(AccessCheckInfo, data, Object, kDataOffset)
ACCESSORS(InterceptorInfo, getter, Object, kGetterOffset)
ACCESSORS(InterceptorInfo, setter, Object, kSetterOffset)
ACCESSORS(InterceptorInfo, query, Object, kQueryOffset)
ACCESSORS(InterceptorInfo, descriptor, Object, kDescriptorOffset)
ACCESSORS(InterceptorInfo, deleter, Object, kDeleterOffset)
ACCESSORS(InterceptorInfo, enumerator, Object, kEnumeratorOffset)
ACCESSORS(InterceptorInfo, definer, Object, kDefinerOffset)
ACCESSORS(InterceptorInfo, data, Object, kDataOffset)
SMI_ACCESSORS(InterceptorInfo, flags, kFlagsOffset)
BOOL_ACCESSORS(InterceptorInfo, flags, can_intercept_symbols,
kCanInterceptSymbolsBit)
BOOL_ACCESSORS(InterceptorInfo, flags, all_can_read, kAllCanReadBit)
BOOL_ACCESSORS(InterceptorInfo, flags, non_masking, kNonMasking)
BOOL_ACCESSORS(InterceptorInfo, flags, is_named, kNamed)
BOOL_ACCESSORS(InterceptorInfo, flags, has_no_side_effect, kHasNoSideEffect)
ACCESSORS(CallHandlerInfo, callback, Object, kCallbackOffset)
ACCESSORS(CallHandlerInfo, js_callback, Object, kJsCallbackOffset)
ACCESSORS(CallHandlerInfo, data, Object, kDataOffset)
bool CallHandlerInfo::IsSideEffectFreeCallHandlerInfo() const {
DCHECK(map() == GetHeap()->side_effect_call_handler_info_map() ||
map() == GetHeap()->side_effect_free_call_handler_info_map());
return map() == GetHeap()->side_effect_free_call_handler_info_map();
}
ACCESSORS(AllocationSite, transition_info_or_boilerplate, Object,
kTransitionInfoOrBoilerplateOffset)
@ -3085,33 +3021,6 @@ inline int JSGlobalProxy::SizeWithEmbedderFields(int embedder_field_count) {
return kSize + embedder_field_count * kPointerSize;
}
BIT_FIELD_ACCESSORS(AccessorInfo, flags, all_can_read,
AccessorInfo::AllCanReadBit)
BIT_FIELD_ACCESSORS(AccessorInfo, flags, all_can_write,
AccessorInfo::AllCanWriteBit)
BIT_FIELD_ACCESSORS(AccessorInfo, flags, is_special_data_property,
AccessorInfo::IsSpecialDataPropertyBit)
BIT_FIELD_ACCESSORS(AccessorInfo, flags, replace_on_access,
AccessorInfo::ReplaceOnAccessBit)
BIT_FIELD_ACCESSORS(AccessorInfo, flags, is_sloppy, AccessorInfo::IsSloppyBit)
BIT_FIELD_ACCESSORS(AccessorInfo, flags, has_no_side_effect,
AccessorInfo::HasNoSideEffectBit)
BIT_FIELD_ACCESSORS(AccessorInfo, flags, initial_property_attributes,
AccessorInfo::InitialAttributesBits)
bool AccessorInfo::IsCompatibleReceiver(Object* receiver) {
if (!HasExpectedReceiverType()) return true;
if (!receiver->IsJSObject()) return false;
return FunctionTemplateInfo::cast(expected_receiver_type())
->IsTemplateFor(JSObject::cast(receiver)->map());
}
bool AccessorInfo::HasExpectedReceiverType() {
return expected_receiver_type()->IsFunctionTemplateInfo();
}
Object* AccessorPair::get(AccessorComponent component) {
return component == ACCESSOR_GETTER ? getter() : setter();
}

View File

@ -53,6 +53,7 @@
#include "src/map-updater.h"
#include "src/messages.h"
#include "src/objects-body-descriptors-inl.h"
#include "src/objects/api-callbacks.h"
#include "src/objects/bigint.h"
#include "src/objects/code-inl.h"
#include "src/objects/compilation-cache-inl.h"

View File

@ -953,6 +953,7 @@ bool ComparisonResultToBool(Operation op, ComparisonResult result);
class AbstractCode;
class AccessorPair;
class AccessCheckInfo;
class AllocationSite;
class ByteArray;
class Cell;
@ -4445,100 +4446,6 @@ class Foreign: public HeapObject {
DISALLOW_IMPLICIT_CONSTRUCTORS(Foreign);
};
// An accessor must have a getter, but can have no setter.
//
// When setting a property, V8 searches accessors in prototypes.
// If an accessor was found and it does not have a setter,
// the request is ignored.
//
// If the accessor in the prototype has the READ_ONLY property attribute, then
// a new value is added to the derived object when the property is set.
// This shadows the accessor in the prototype.
class AccessorInfo: public Struct {
public:
DECL_ACCESSORS(name, Name)
DECL_INT_ACCESSORS(flags)
DECL_ACCESSORS(expected_receiver_type, Object)
// This directly points at a foreign C function to be used from the runtime.
DECL_ACCESSORS(getter, Object)
inline bool has_getter();
DECL_ACCESSORS(setter, Object)
inline bool has_setter();
// This either points at the same as above, or a trampoline in case we are
// running with the simulator. Use these entries from generated code.
DECL_ACCESSORS(js_getter, Object)
DECL_ACCESSORS(data, Object)
static Address redirect(Isolate* isolate, Address address,
AccessorComponent component);
Address redirected_getter() const;
// Dispatched behavior.
DECL_PRINTER(AccessorInfo)
DECL_BOOLEAN_ACCESSORS(all_can_read)
DECL_BOOLEAN_ACCESSORS(all_can_write)
DECL_BOOLEAN_ACCESSORS(is_special_data_property)
DECL_BOOLEAN_ACCESSORS(replace_on_access)
DECL_BOOLEAN_ACCESSORS(is_sloppy)
DECL_BOOLEAN_ACCESSORS(has_no_side_effect)
// The property attributes used when an API object template is instantiated
// for the first time. Changing of this value afterwards does not affect
// the actual attributes of a property.
inline PropertyAttributes initial_property_attributes() const;
inline void set_initial_property_attributes(PropertyAttributes attributes);
// Checks whether the given receiver is compatible with this accessor.
static bool IsCompatibleReceiverMap(Isolate* isolate,
Handle<AccessorInfo> info,
Handle<Map> map);
inline bool IsCompatibleReceiver(Object* receiver);
DECL_CAST(AccessorInfo)
// Dispatched behavior.
DECL_VERIFIER(AccessorInfo)
// Append all descriptors to the array that are not already there.
// Return number added.
static int AppendUnique(Handle<Object> descriptors,
Handle<FixedArray> array,
int valid_descriptors);
// Layout description.
#define ACCESSOR_INFO_FIELDS(V) \
V(kNameOffset, kPointerSize) \
V(kFlagsOffset, kPointerSize) \
V(kExpectedReceiverTypeOffset, kPointerSize) \
V(kSetterOffset, kPointerSize) \
V(kGetterOffset, kPointerSize) \
V(kJsGetterOffset, kPointerSize) \
V(kDataOffset, kPointerSize) \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, ACCESSOR_INFO_FIELDS)
#undef ACCESSOR_INFO_FIELDS
private:
inline bool HasExpectedReceiverType();
// Bit positions in |flags|.
#define ACCESSOR_INFO_FLAGS_BIT_FIELDS(V, _) \
V(AllCanReadBit, bool, 1, _) \
V(AllCanWriteBit, bool, 1, _) \
V(IsSpecialDataPropertyBit, bool, 1, _) \
V(IsSloppyBit, bool, 1, _) \
V(ReplaceOnAccessBit, bool, 1, _) \
V(HasNoSideEffectBit, bool, 1, _) \
V(InitialAttributesBits, PropertyAttributes, 3, _)
DEFINE_BIT_FIELDS(ACCESSOR_INFO_FLAGS_BIT_FIELDS)
#undef ACCESSOR_INFO_FLAGS_BIT_FIELDS
DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorInfo);
};
// Support for JavaScript accessors: A pair of a getter and a setter. Each
// accessor can either be
// * a JavaScript function or proxy: a real accessor
@ -4588,104 +4495,6 @@ class AccessorPair: public Struct {
DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorPair);
};
class AccessCheckInfo: public Struct {
public:
DECL_ACCESSORS(callback, Object)
DECL_ACCESSORS(named_interceptor, Object)
DECL_ACCESSORS(indexed_interceptor, Object)
DECL_ACCESSORS(data, Object)
DECL_CAST(AccessCheckInfo)
// Dispatched behavior.
DECL_PRINTER(AccessCheckInfo)
DECL_VERIFIER(AccessCheckInfo)
static AccessCheckInfo* Get(Isolate* isolate, Handle<JSObject> receiver);
static const int kCallbackOffset = HeapObject::kHeaderSize;
static const int kNamedInterceptorOffset = kCallbackOffset + kPointerSize;
static const int kIndexedInterceptorOffset =
kNamedInterceptorOffset + kPointerSize;
static const int kDataOffset = kIndexedInterceptorOffset + kPointerSize;
static const int kSize = kDataOffset + kPointerSize;
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(AccessCheckInfo);
};
class InterceptorInfo: public Struct {
public:
DECL_ACCESSORS(getter, Object)
DECL_ACCESSORS(setter, Object)
DECL_ACCESSORS(query, Object)
DECL_ACCESSORS(descriptor, Object)
DECL_ACCESSORS(deleter, Object)
DECL_ACCESSORS(enumerator, Object)
DECL_ACCESSORS(definer, Object)
DECL_ACCESSORS(data, Object)
DECL_BOOLEAN_ACCESSORS(can_intercept_symbols)
DECL_BOOLEAN_ACCESSORS(all_can_read)
DECL_BOOLEAN_ACCESSORS(non_masking)
DECL_BOOLEAN_ACCESSORS(is_named)
DECL_BOOLEAN_ACCESSORS(has_no_side_effect)
inline int flags() const;
inline void set_flags(int flags);
DECL_CAST(InterceptorInfo)
// Dispatched behavior.
DECL_PRINTER(InterceptorInfo)
DECL_VERIFIER(InterceptorInfo)
static const int kGetterOffset = HeapObject::kHeaderSize;
static const int kSetterOffset = kGetterOffset + kPointerSize;
static const int kQueryOffset = kSetterOffset + kPointerSize;
static const int kDescriptorOffset = kQueryOffset + kPointerSize;
static const int kDeleterOffset = kDescriptorOffset + kPointerSize;
static const int kEnumeratorOffset = kDeleterOffset + kPointerSize;
static const int kDefinerOffset = kEnumeratorOffset + kPointerSize;
static const int kDataOffset = kDefinerOffset + kPointerSize;
static const int kFlagsOffset = kDataOffset + kPointerSize;
static const int kSize = kFlagsOffset + kPointerSize;
static const int kCanInterceptSymbolsBit = 0;
static const int kAllCanReadBit = 1;
static const int kNonMasking = 2;
static const int kNamed = 3;
static const int kHasNoSideEffect = 4;
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(InterceptorInfo);
};
class CallHandlerInfo : public Tuple3 {
public:
DECL_ACCESSORS(callback, Object)
DECL_ACCESSORS(js_callback, Object)
DECL_ACCESSORS(data, Object)
DECL_CAST(CallHandlerInfo)
inline bool IsSideEffectFreeCallHandlerInfo() const;
// Dispatched behavior.
DECL_PRINTER(CallHandlerInfo)
DECL_VERIFIER(CallHandlerInfo)
Address redirected_callback() const;
static const int kCallbackOffset = kValue1Offset;
static const int kJsCallbackOffset = kValue2Offset;
static const int kDataOffset = kValue3Offset;
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(CallHandlerInfo);
};
class StackFrameInfo : public Struct {
public:
DECL_INT_ACCESSORS(line_number)

View File

@ -0,0 +1,117 @@
// Copyright 2018 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.
#ifndef V8_OBJECTS_API_CALLBACKS_INL_H_
#define V8_OBJECTS_API_CALLBACKS_INL_H_
#include "src/objects/api-callbacks.h"
#include "src/heap/heap-inl.h"
#include "src/objects/name.h"
#include "src/objects/templates.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
namespace v8 {
namespace internal {
CAST_ACCESSOR(AccessorInfo)
CAST_ACCESSOR(AccessCheckInfo)
CAST_ACCESSOR(InterceptorInfo)
CAST_ACCESSOR(CallHandlerInfo)
TYPE_CHECKER(CallHandlerInfo, CALL_HANDLER_INFO_TYPE)
ACCESSORS(AccessorInfo, name, Name, kNameOffset)
SMI_ACCESSORS(AccessorInfo, flags, kFlagsOffset)
ACCESSORS(AccessorInfo, expected_receiver_type, Object,
kExpectedReceiverTypeOffset)
ACCESSORS_CHECKED2(AccessorInfo, getter, Object, kGetterOffset, true,
Foreign::IsNormalized(value))
ACCESSORS_CHECKED2(AccessorInfo, setter, Object, kSetterOffset, true,
Foreign::IsNormalized(value));
ACCESSORS(AccessorInfo, js_getter, Object, kJsGetterOffset)
ACCESSORS(AccessorInfo, data, Object, kDataOffset)
bool AccessorInfo::has_getter() {
bool result = getter() != Smi::kZero;
DCHECK_EQ(result,
getter() != Smi::kZero &&
Foreign::cast(getter())->foreign_address() != kNullAddress);
return result;
}
bool AccessorInfo::has_setter() {
bool result = setter() != Smi::kZero;
DCHECK_EQ(result,
setter() != Smi::kZero &&
Foreign::cast(setter())->foreign_address() != kNullAddress);
return result;
}
BIT_FIELD_ACCESSORS(AccessorInfo, flags, all_can_read,
AccessorInfo::AllCanReadBit)
BIT_FIELD_ACCESSORS(AccessorInfo, flags, all_can_write,
AccessorInfo::AllCanWriteBit)
BIT_FIELD_ACCESSORS(AccessorInfo, flags, is_special_data_property,
AccessorInfo::IsSpecialDataPropertyBit)
BIT_FIELD_ACCESSORS(AccessorInfo, flags, replace_on_access,
AccessorInfo::ReplaceOnAccessBit)
BIT_FIELD_ACCESSORS(AccessorInfo, flags, is_sloppy, AccessorInfo::IsSloppyBit)
BIT_FIELD_ACCESSORS(AccessorInfo, flags, has_no_side_effect,
AccessorInfo::HasNoSideEffectBit)
BIT_FIELD_ACCESSORS(AccessorInfo, flags, initial_property_attributes,
AccessorInfo::InitialAttributesBits)
bool AccessorInfo::IsCompatibleReceiver(Object* receiver) {
if (!HasExpectedReceiverType()) return true;
if (!receiver->IsJSObject()) return false;
return FunctionTemplateInfo::cast(expected_receiver_type())
->IsTemplateFor(JSObject::cast(receiver)->map());
}
bool AccessorInfo::HasExpectedReceiverType() {
return expected_receiver_type()->IsFunctionTemplateInfo();
}
ACCESSORS(AccessCheckInfo, callback, Object, kCallbackOffset)
ACCESSORS(AccessCheckInfo, named_interceptor, Object, kNamedInterceptorOffset)
ACCESSORS(AccessCheckInfo, indexed_interceptor, Object,
kIndexedInterceptorOffset)
ACCESSORS(AccessCheckInfo, data, Object, kDataOffset)
ACCESSORS(InterceptorInfo, getter, Object, kGetterOffset)
ACCESSORS(InterceptorInfo, setter, Object, kSetterOffset)
ACCESSORS(InterceptorInfo, query, Object, kQueryOffset)
ACCESSORS(InterceptorInfo, descriptor, Object, kDescriptorOffset)
ACCESSORS(InterceptorInfo, deleter, Object, kDeleterOffset)
ACCESSORS(InterceptorInfo, enumerator, Object, kEnumeratorOffset)
ACCESSORS(InterceptorInfo, definer, Object, kDefinerOffset)
ACCESSORS(InterceptorInfo, data, Object, kDataOffset)
SMI_ACCESSORS(InterceptorInfo, flags, kFlagsOffset)
BOOL_ACCESSORS(InterceptorInfo, flags, can_intercept_symbols,
kCanInterceptSymbolsBit)
BOOL_ACCESSORS(InterceptorInfo, flags, all_can_read, kAllCanReadBit)
BOOL_ACCESSORS(InterceptorInfo, flags, non_masking, kNonMasking)
BOOL_ACCESSORS(InterceptorInfo, flags, is_named, kNamed)
BOOL_ACCESSORS(InterceptorInfo, flags, has_no_side_effect, kHasNoSideEffect)
ACCESSORS(CallHandlerInfo, callback, Object, kCallbackOffset)
ACCESSORS(CallHandlerInfo, js_callback, Object, kJsCallbackOffset)
ACCESSORS(CallHandlerInfo, data, Object, kDataOffset)
bool CallHandlerInfo::IsSideEffectFreeCallHandlerInfo() const {
DCHECK(map() == GetHeap()->side_effect_call_handler_info_map() ||
map() == GetHeap()->side_effect_free_call_handler_info_map());
return map() == GetHeap()->side_effect_free_call_handler_info_map();
}
} // namespace internal
} // namespace v8
#include "src/objects/object-macros-undef.h"
#endif // V8_OBJECTS_API_CALLBACKS_INL_H_

210
src/objects/api-callbacks.h Normal file
View File

@ -0,0 +1,210 @@
// Copyright 2018 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.
#ifndef V8_OBJECTS_API_CALLBACKS_H_
#define V8_OBJECTS_API_CALLBACKS_H_
#include "src/objects.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
namespace v8 {
namespace internal {
// An accessor must have a getter, but can have no setter.
//
// When setting a property, V8 searches accessors in prototypes.
// If an accessor was found and it does not have a setter,
// the request is ignored.
//
// If the accessor in the prototype has the READ_ONLY property attribute, then
// a new value is added to the derived object when the property is set.
// This shadows the accessor in the prototype.
class AccessorInfo : public Struct {
public:
DECL_ACCESSORS(name, Name)
DECL_INT_ACCESSORS(flags)
DECL_ACCESSORS(expected_receiver_type, Object)
// This directly points at a foreign C function to be used from the runtime.
DECL_ACCESSORS(getter, Object)
inline bool has_getter();
DECL_ACCESSORS(setter, Object)
inline bool has_setter();
// This either points at the same as above, or a trampoline in case we are
// running with the simulator. Use these entries from generated code.
DECL_ACCESSORS(js_getter, Object)
DECL_ACCESSORS(data, Object)
static Address redirect(Isolate* isolate, Address address,
AccessorComponent component);
Address redirected_getter() const;
// Dispatched behavior.
DECL_PRINTER(AccessorInfo)
DECL_BOOLEAN_ACCESSORS(all_can_read)
DECL_BOOLEAN_ACCESSORS(all_can_write)
DECL_BOOLEAN_ACCESSORS(is_special_data_property)
DECL_BOOLEAN_ACCESSORS(replace_on_access)
DECL_BOOLEAN_ACCESSORS(is_sloppy)
DECL_BOOLEAN_ACCESSORS(has_no_side_effect)
// The property attributes used when an API object template is instantiated
// for the first time. Changing of this value afterwards does not affect
// the actual attributes of a property.
inline PropertyAttributes initial_property_attributes() const;
inline void set_initial_property_attributes(PropertyAttributes attributes);
// Checks whether the given receiver is compatible with this accessor.
static bool IsCompatibleReceiverMap(Isolate* isolate,
Handle<AccessorInfo> info,
Handle<Map> map);
inline bool IsCompatibleReceiver(Object* receiver);
DECL_CAST(AccessorInfo)
// Dispatched behavior.
DECL_VERIFIER(AccessorInfo)
// Append all descriptors to the array that are not already there.
// Return number added.
static int AppendUnique(Handle<Object> descriptors, Handle<FixedArray> array,
int valid_descriptors);
// Layout description.
#define ACCESSOR_INFO_FIELDS(V) \
V(kNameOffset, kPointerSize) \
V(kFlagsOffset, kPointerSize) \
V(kExpectedReceiverTypeOffset, kPointerSize) \
V(kSetterOffset, kPointerSize) \
V(kGetterOffset, kPointerSize) \
V(kJsGetterOffset, kPointerSize) \
V(kDataOffset, kPointerSize) \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, ACCESSOR_INFO_FIELDS)
#undef ACCESSOR_INFO_FIELDS
private:
inline bool HasExpectedReceiverType();
// Bit positions in |flags|.
#define ACCESSOR_INFO_FLAGS_BIT_FIELDS(V, _) \
V(AllCanReadBit, bool, 1, _) \
V(AllCanWriteBit, bool, 1, _) \
V(IsSpecialDataPropertyBit, bool, 1, _) \
V(IsSloppyBit, bool, 1, _) \
V(ReplaceOnAccessBit, bool, 1, _) \
V(HasNoSideEffectBit, bool, 1, _) \
V(InitialAttributesBits, PropertyAttributes, 3, _)
DEFINE_BIT_FIELDS(ACCESSOR_INFO_FLAGS_BIT_FIELDS)
#undef ACCESSOR_INFO_FLAGS_BIT_FIELDS
DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorInfo);
};
class AccessCheckInfo : public Struct {
public:
DECL_ACCESSORS(callback, Object)
DECL_ACCESSORS(named_interceptor, Object)
DECL_ACCESSORS(indexed_interceptor, Object)
DECL_ACCESSORS(data, Object)
DECL_CAST(AccessCheckInfo)
// Dispatched behavior.
DECL_PRINTER(AccessCheckInfo)
DECL_VERIFIER(AccessCheckInfo)
static AccessCheckInfo* Get(Isolate* isolate, Handle<JSObject> receiver);
static const int kCallbackOffset = HeapObject::kHeaderSize;
static const int kNamedInterceptorOffset = kCallbackOffset + kPointerSize;
static const int kIndexedInterceptorOffset =
kNamedInterceptorOffset + kPointerSize;
static const int kDataOffset = kIndexedInterceptorOffset + kPointerSize;
static const int kSize = kDataOffset + kPointerSize;
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(AccessCheckInfo);
};
class InterceptorInfo : public Struct {
public:
DECL_ACCESSORS(getter, Object)
DECL_ACCESSORS(setter, Object)
DECL_ACCESSORS(query, Object)
DECL_ACCESSORS(descriptor, Object)
DECL_ACCESSORS(deleter, Object)
DECL_ACCESSORS(enumerator, Object)
DECL_ACCESSORS(definer, Object)
DECL_ACCESSORS(data, Object)
DECL_BOOLEAN_ACCESSORS(can_intercept_symbols)
DECL_BOOLEAN_ACCESSORS(all_can_read)
DECL_BOOLEAN_ACCESSORS(non_masking)
DECL_BOOLEAN_ACCESSORS(is_named)
DECL_BOOLEAN_ACCESSORS(has_no_side_effect)
inline int flags() const;
inline void set_flags(int flags);
DECL_CAST(InterceptorInfo)
// Dispatched behavior.
DECL_PRINTER(InterceptorInfo)
DECL_VERIFIER(InterceptorInfo)
static const int kGetterOffset = HeapObject::kHeaderSize;
static const int kSetterOffset = kGetterOffset + kPointerSize;
static const int kQueryOffset = kSetterOffset + kPointerSize;
static const int kDescriptorOffset = kQueryOffset + kPointerSize;
static const int kDeleterOffset = kDescriptorOffset + kPointerSize;
static const int kEnumeratorOffset = kDeleterOffset + kPointerSize;
static const int kDefinerOffset = kEnumeratorOffset + kPointerSize;
static const int kDataOffset = kDefinerOffset + kPointerSize;
static const int kFlagsOffset = kDataOffset + kPointerSize;
static const int kSize = kFlagsOffset + kPointerSize;
static const int kCanInterceptSymbolsBit = 0;
static const int kAllCanReadBit = 1;
static const int kNonMasking = 2;
static const int kNamed = 3;
static const int kHasNoSideEffect = 4;
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(InterceptorInfo);
};
class CallHandlerInfo : public Tuple3 {
public:
DECL_ACCESSORS(callback, Object)
DECL_ACCESSORS(js_callback, Object)
DECL_ACCESSORS(data, Object)
DECL_CAST(CallHandlerInfo)
inline bool IsSideEffectFreeCallHandlerInfo() const;
// Dispatched behavior.
DECL_PRINTER(CallHandlerInfo)
DECL_VERIFIER(CallHandlerInfo)
Address redirected_callback() const;
static const int kCallbackOffset = kValue1Offset;
static const int kJsCallbackOffset = kValue2Offset;
static const int kDataOffset = kValue3Offset;
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(CallHandlerInfo);
};
} // namespace internal
} // namespace v8
#include "src/objects/object-macros-undef.h"
#endif // V8_OBJECTS_API_CALLBACKS_H_

View File

@ -9,6 +9,7 @@
#include "src/field-type.h"
#include "src/objects-inl.h"
#include "src/objects/api-callbacks-inl.h"
#include "src/objects/descriptor-array.h"
#include "src/objects/shared-function-info.h"
#include "src/objects/templates-inl.h"

View File

@ -14,6 +14,7 @@
#include "src/layout-descriptor.h"
#include "src/objects-body-descriptors.h"
#include "src/objects-inl.h"
#include "src/objects/api-callbacks.h"
#include "src/profiler/allocation-tracker.h"
#include "src/profiler/heap-profiler.h"
#include "src/profiler/heap-snapshot-generator-inl.h"

View File

@ -6,6 +6,7 @@
#include "src/assembler-inl.h"
#include "src/isolate.h"
#include "src/objects/api-callbacks.h"
#include "src/objects/hash-table.h"
#include "src/objects/maybe-object.h"
#include "src/objects/string.h"

View File

@ -15,6 +15,7 @@
namespace v8 {
namespace internal {
class CallHandlerInfo;
class Isolate;
class ExternalReferenceEncoder {

View File

@ -16,6 +16,7 @@
#include "src/ic/stub-cache.h"
#include "src/isolate.h"
#include "src/objects-inl.h"
#include "src/objects/api-callbacks.h"
#include "src/objects/regexp-match-info.h"
#include "src/regexp/jsregexp.h"
#include "src/regexp/regexp-macro-assembler.h"

View File

@ -31,6 +31,7 @@
#include "src/accessors.h"
#include "src/api.h"
#include "src/objects-inl.h"
#include "src/objects/api-callbacks.h"
#include "src/property.h"
#include "test/cctest/heap/heap-tester.h"
#include "test/cctest/heap/heap-utils.h"

View File

@ -20,6 +20,7 @@
#include "src/layout-descriptor.h"
#include "src/macro-assembler.h"
#include "src/objects-inl.h"
#include "src/objects/api-callbacks.h"
#include "src/property.h"
#include "test/cctest/cctest.h"
#include "test/cctest/heap/heap-utils.h"