// 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_JS_OBJECTS_H_ #define V8_OBJECTS_JS_OBJECTS_H_ #include <optional> #include "src/common/globals.h" #include "src/handles/handles.h" #include "src/objects/embedder-data-slot.h" // TODO(jkummerow): Consider forward-declaring instead. #include "src/objects/internal-index.h" #include "src/objects/objects.h" #include "src/objects/property-array.h" // Has to be the last include (doesn't have include guards): #include "src/objects/object-macros.h" namespace v8::internal { // Enum for functions that offer a second mode that does not cause allocations. // Used in conjunction with LookupIterator and unboxed double fields. enum class AllocationPolicy { … }; enum InstanceType : uint16_t; class JSGlobalObject; class JSGlobalProxy; class LookupIterator; class PropertyDescriptor; class PropertyKey; class NativeContext; class IsCompiledScope; class SwissNameDictionary; class ElementsAccessor; class Undefined; class Null; #include "torque-generated/src/objects/js-objects-tq.inc" // JSReceiver includes types on which properties can be defined, i.e., // JSObject and JSProxy. class JSReceiver : public TorqueGeneratedJSReceiver<JSReceiver, HeapObject> { … }; // The JSObject describes real heap allocated JavaScript objects with // properties. // Note that the map of JSObject changes during execution to enable inline // caching. class JSObject : public TorqueGeneratedJSObject<JSObject, JSReceiver> { … }; // A JSObject created through the public api which wraps an external pointer. // See v8::External. class JSExternalObject : public TorqueGeneratedJSExternalObject<JSExternalObject, JSObject> { … }; // An abstract superclass for JSObjects that may contain EmbedderDataSlots. class JSObjectWithEmbedderSlots : public TorqueGeneratedJSObjectWithEmbedderSlots<JSObjectWithEmbedderSlots, JSObject> { … }; // An abstract superclass for JSObjects that may contain EmbedderDataSlots and // are used as API wrapper objects. class JSAPIObjectWithEmbedderSlots : public TorqueGeneratedJSAPIObjectWithEmbedderSlots< JSAPIObjectWithEmbedderSlots, JSObject> { … }; // An abstract superclass for JSObjects that may have elements while having an // empty fixed array as elements backing store. It doesn't carry any // functionality but allows function classes to be identified in the type // system. class JSCustomElementsObject : public TorqueGeneratedJSCustomElementsObject<JSCustomElementsObject, JSObject> { … }; // An abstract superclass for JSObjects that require non-standard element // access. It doesn't carry any functionality but allows function classes to be // identified in the type system. // These may also contain EmbedderDataSlots, but can't currently inherit from // JSAPIObjectWithEmbedderSlots due to instance_type constraints. class JSSpecialObject : public TorqueGeneratedJSSpecialObject<JSSpecialObject, JSCustomElementsObject> { … }; // Helper union that doesn't actually exist as type. Use by value. class JSApiWrapper { … }; // JSAccessorPropertyDescriptor is just a JSObject with a specific initial // map. This initial map adds in-object properties for "get", "set", // "enumerable" and "configurable" properties, as assigned by the // FromPropertyDescriptor function for regular accessor properties. class JSAccessorPropertyDescriptor : public JSObject { … }; // JSDataPropertyDescriptor is just a JSObject with a specific initial map. // This initial map adds in-object properties for "value", "writable", // "enumerable" and "configurable" properties, as assigned by the // FromPropertyDescriptor function for regular data properties. class JSDataPropertyDescriptor : public JSObject { … }; // JSIteratorResult is just a JSObject with a specific initial map. // This initial map adds in-object properties for "done" and "value", // as specified by ES6 section 25.1.1.3 The IteratorResult Interface. class JSIteratorResult : public JSObject { … }; // JSGlobalProxy's prototype must be a JSGlobalObject or null, // and the prototype is hidden. JSGlobalProxy always delegates // property accesses to its prototype if the prototype is not null. // // A JSGlobalProxy can be reinitialized which will preserve its identity. // // Accessing a JSGlobalProxy requires security check. class JSGlobalProxy : public TorqueGeneratedJSGlobalProxy<JSGlobalProxy, JSSpecialObject> { … }; // JavaScript global object. class JSGlobalObject : public TorqueGeneratedJSGlobalObject<JSGlobalObject, JSSpecialObject> { … }; // Representation for JS Wrapper objects, String, Number, Boolean, etc. class JSPrimitiveWrapper : public TorqueGeneratedJSPrimitiveWrapper<JSPrimitiveWrapper, JSCustomElementsObject> { … }; class DateCache; // Representation for JS date objects. class JSDate : public TorqueGeneratedJSDate<JSDate, JSObject> { … }; // Representation of message objects used for error reporting through // the API. The messages are formatted in JavaScript so this object is // a real JavaScript object. The information used for formatting the // error messages are not directly accessible from JavaScript to // prevent leaking information to user code called during error // formatting. class JSMessageObject : public TorqueGeneratedJSMessageObject<JSMessageObject, JSObject> { … }; // The [Async-from-Sync Iterator] object // (proposal-async-iteration/#sec-async-from-sync-iterator-objects) // An object which wraps an ordinary Iterator and converts it to behave // according to the Async Iterator protocol. // (See https://tc39.github.io/proposal-async-iteration/#sec-iteration) class JSAsyncFromSyncIterator : public TorqueGeneratedJSAsyncFromSyncIterator<JSAsyncFromSyncIterator, JSObject> { … }; class JSStringIterator : public TorqueGeneratedJSStringIterator<JSStringIterator, JSObject> { … }; // The valid iterator wrapper is the wrapper object created by // Iterator.from(obj), which attempts to wrap iterator-like objects into an // actual iterator with %Iterator.prototype%. class JSValidIteratorWrapper : public TorqueGeneratedJSValidIteratorWrapper<JSValidIteratorWrapper, JSObject> { … }; // JSPromiseWithResolversResult is just a JSObject with a specific initial map. // This initial map adds in-object properties for "promise", "resolve", and // "reject", in that order. class JSPromiseWithResolversResult : public JSObject { … }; } // namespace v8::internal #include "src/objects/object-macros-undef.h" #endif // V8_OBJECTS_JS_OBJECTS_H_