#ifndef V8_IC_HANDLER_CONFIGURATION_H_
#define V8_IC_HANDLER_CONFIGURATION_H_
#include "src/common/globals.h"
#include "src/handles/maybe-handles.h"
#include "src/heap/heap.h"
#include "src/objects/data-handler.h"
#include "src/objects/elements-kind.h"
#include "src/objects/field-index.h"
#include "src/objects/objects.h"
#include "src/utils/utils.h"
#include "src/objects/object-macros.h"
namespace v8 {
namespace internal {
class JSProxy;
enum class WasmValueType {
kI8,
kI16,
kI32,
kU32,
kI64,
kF32,
kF64,
kS128,
kRef,
kRefNull,
kNumTypes
};
V8_OBJECT class LoadHandler final : public DataHandler {
public:
DECL_PRINTER(LoadHandler)
DECL_VERIFIER(LoadHandler)
enum class Kind {
kElement,
kElementWithTransition,
kIndexedString,
kNormal,
kGlobal,
kField,
kConstantFromPrototype,
kAccessorFromPrototype,
kNativeDataProperty,
kApiGetter,
kInterceptor,
kSlow,
kProxy,
kNonExistent,
kModuleExport,
kGeneric,
};
using KindBits = base::BitField<Kind, 0, 4>;
using DoAccessCheckOnLookupStartObjectBits = KindBits::Next<bool, 1>;
using LookupOnLookupStartObjectBits =
DoAccessCheckOnLookupStartObjectBits::Next<bool, 1>;
using DescriptorBits =
LookupOnLookupStartObjectBits::Next<unsigned, kDescriptorIndexBitCount>;
static_assert(DescriptorBits::kLastUsedBit < kSmiValueSize);
using IsWasmStructBits = LookupOnLookupStartObjectBits::Next<bool, 1>;
using IsInobjectBits = IsWasmStructBits::Next<bool, 1>;
using IsDoubleBits = IsInobjectBits::Next<bool, 1>;
using FieldIndexBits =
IsDoubleBits::Next<unsigned, kDescriptorIndexBitCount + 1>;
static_assert(FieldIndexBits::kLastUsedBit < kSmiValueSize);
using WasmFieldTypeBits = IsWasmStructBits::Next<WasmValueType, 4>;
using WasmFieldOffsetBits = WasmFieldTypeBits::Next<unsigned, 20>;
static_assert(WasmFieldOffsetBits::kLastUsedBit < kSmiValueSize);
using AllowOutOfBoundsBits = LookupOnLookupStartObjectBits::Next<bool, 1>;
using IsWasmArrayBits = AllowOutOfBoundsBits::Next<bool, 1>;
using IsJsArrayBits = IsWasmArrayBits::Next<bool, 1>;
using AllowHandlingHole = IsJsArrayBits::Next<bool, 1>;
using ElementsKindBits = AllowHandlingHole::Next<ElementsKind, 8>;
static_assert(ElementsKindBits::kLastUsedBit < kSmiValueSize);
using WasmArrayTypeBits = IsWasmArrayBits::Next<WasmValueType, 4>;
static_assert(WasmArrayTypeBits::kLastUsedBit < kSmiValueSize);
using ExportsIndexBits = LookupOnLookupStartObjectBits::Next<
unsigned,
kSmiValueSize - LookupOnLookupStartObjectBits::kLastUsedBit - 1>;
static_assert(ExportsIndexBits::kLastUsedBit < kSmiValueSize);
static inline Kind GetHandlerKind(Tagged<Smi> smi_handler);
static inline Handle<Smi> LoadNormal(Isolate* isolate);
static inline Handle<Smi> LoadGlobal(Isolate* isolate);
static inline Tagged<Smi> LoadInterceptor();
static Handle<LoadHandler> LoadInterceptorHolderIsLookupStartupObject(
Isolate* isolate, DirectHandle<Map> lookup_start_object_map,
DirectHandle<InterceptorInfo> interceptor_info);
static inline Handle<Smi> LoadSlow(Isolate* isolate);
static inline Handle<Smi> LoadGeneric(Isolate* isolate);
static inline Tagged<Smi> LoadGeneric();
static inline Handle<Smi> LoadField(Isolate* isolate, FieldIndex field_index);
static inline Handle<Smi> LoadConstantFromPrototype(Isolate* isolate);
static inline DirectHandle<Smi> LoadAccessorFromPrototype(Isolate* isolate);
static inline Handle<Smi> LoadProxy(Isolate* isolate);
static inline Handle<Smi> LoadNativeDataProperty(Isolate* isolate,
int descriptor);
static inline Handle<Smi> LoadApiGetter(Isolate* isolate);
static inline Handle<Smi> LoadModuleExport(Isolate* isolate, int index);
static inline DirectHandle<Smi> LoadWasmStructField(Isolate* isolate,
WasmValueType type,
int offset);
static inline DirectHandle<Smi> LoadWasmArrayElement(Isolate* isolate,
WasmValueType type);
static Handle<LoadHandler> LoadFromPrototype(
Isolate* isolate, DirectHandle<Map> receiver_map,
DirectHandle<JSReceiver> holder, Tagged<Smi> smi_handler,
MaybeObjectDirectHandle maybe_data1 = MaybeObjectDirectHandle(),
MaybeObjectDirectHandle maybe_data2 = MaybeObjectDirectHandle());
static inline Handle<Smi> LoadNonExistent(Isolate* isolate);
static Handle<Object> LoadNonExistent(
Isolate* isolate, DirectHandle<Map> lookup_start_object_map);
static inline Handle<Smi> LoadElement(Isolate* isolate,
ElementsKind elements_kind,
bool is_js_array,
KeyedAccessLoadMode load_mode);
static inline Handle<Smi> TransitionAndLoadElement(
Isolate* isolate, ElementsKind kind_after_transition,
KeyedAccessLoadMode load_mode);
static inline Handle<Smi> LoadIndexedString(Isolate* isolate,
KeyedAccessLoadMode load_mode);
static KeyedAccessLoadMode GetKeyedAccessLoadMode(
Tagged<MaybeObject> handler);
static bool CanHandleHolderNotLookupStart(Tagged<Object> handler);
#if defined(OBJECT_PRINT)
static void PrintHandler(Tagged<Object> handler, std::ostream& os);
#endif
} V8_OBJECT_END;
V8_OBJECT class StoreHandler final : public DataHandler {
public:
DECL_PRINTER(StoreHandler)
DECL_VERIFIER(StoreHandler)
enum class Kind {
kField,
kConstField,
kAccessorFromPrototype,
kNativeDataProperty,
kSharedStructField,
kApiSetter,
kGlobalProxy,
kNormal,
kInterceptor,
kSlow,
kProxy,
kGeneric,
kKindsNumber
};
using KindBits = base::BitField<Kind, 0, 4>;
using DoAccessCheckOnLookupStartObjectBits = KindBits::Next<bool, 1>;
using LookupOnLookupStartObjectBits =
DoAccessCheckOnLookupStartObjectBits::Next<bool, 1>;
using DescriptorBits =
LookupOnLookupStartObjectBits::Next<unsigned, kDescriptorIndexBitCount>;
using KeyedAccessStoreModeBits =
LookupOnLookupStartObjectBits::Next<KeyedAccessStoreMode, 2>;
using IsInobjectBits = DescriptorBits::Next<bool, 1>;
using RepresentationBits = IsInobjectBits::Next<Representation::Kind, 3>;
using FieldIndexBits =
RepresentationBits::Next<unsigned, kDescriptorIndexBitCount + 1>;
static_assert(FieldIndexBits::kLastUsedBit < kSmiValueSize);
static inline Handle<Smi> StoreField(Isolate* isolate, int descriptor,
FieldIndex field_index,
PropertyConstness constness,
Representation representation);
static inline Handle<Smi> StoreSharedStructField(
Isolate* isolate, int descriptor, FieldIndex field_index,
Representation representation);
static MaybeObjectHandle StoreOwnTransition(Isolate* isolate,
Handle<Map> transition_map);
static MaybeObjectHandle StoreTransition(Isolate* isolate,
Handle<Map> transition_map);
static inline Handle<Smi> StoreNativeDataProperty(Isolate* isolate,
int descriptor);
static inline DirectHandle<Smi> StoreAccessorFromPrototype(Isolate* isolate);
static inline DirectHandle<Smi> StoreApiSetter(Isolate* isolate);
static Handle<Object> StoreThroughPrototype(
Isolate* isolate, DirectHandle<Map> receiver_map,
DirectHandle<JSReceiver> holder, Tagged<Smi> smi_handler,
MaybeObjectDirectHandle maybe_data1 = MaybeObjectDirectHandle(),
MaybeObjectDirectHandle maybe_data2 = MaybeObjectDirectHandle());
static Handle<Object> StoreElementTransition(
Isolate* isolate, DirectHandle<Map> receiver_map,
DirectHandle<Map> transition, KeyedAccessStoreMode store_mode,
MaybeDirectHandle<UnionOf<Smi, Cell>> prev_validity_cell =
kNullMaybeHandle);
static Handle<Object> StoreProxy(Isolate* isolate,
DirectHandle<Map> receiver_map,
Handle<JSProxy> proxy,
DirectHandle<JSReceiver> receiver);
static MaybeObjectHandle StoreGlobal(Handle<PropertyCell> cell);
static inline DirectHandle<Smi> StoreGlobalProxy(Isolate* isolate);
static inline Handle<Smi> StoreNormal(Isolate* isolate);
static inline Tagged<Smi> StoreInterceptor();
static Handle<StoreHandler> StoreInterceptorHolderIsReceiver(
Isolate* isolate, DirectHandle<Map> holder_map,
DirectHandle<InterceptorInfo> interceptor_info);
static inline Handle<Code> StoreSloppyArgumentsBuiltin(
Isolate* isolate, KeyedAccessStoreMode mode);
static inline Handle<Code> StoreFastElementBuiltin(Isolate* isolate,
KeyedAccessStoreMode mode);
static inline DirectHandle<Code> ElementsTransitionAndStoreBuiltin(
Isolate* isolate, KeyedAccessStoreMode mode);
static inline Tagged<Smi> StoreSlow(
KeyedAccessStoreMode store_mode = KeyedAccessStoreMode::kInBounds);
static inline Handle<Smi> StoreSlow(
Isolate* isolate,
KeyedAccessStoreMode store_mode = KeyedAccessStoreMode::kInBounds);
static inline Handle<Smi> StoreGeneric(Isolate* isolate);
static inline Tagged<Smi> StoreGeneric();
static inline Handle<Smi> StoreProxy(Isolate* isolate);
static inline Tagged<Smi> StoreProxy();
static KeyedAccessStoreMode GetKeyedAccessStoreMode(
Tagged<MaybeObject> handler);
#if defined(OBJECT_PRINT)
static void PrintHandler(Tagged<Object> handler, std::ostream& os);
#endif
private:
static inline Handle<Smi> StoreField(Isolate* isolate, Kind kind,
int descriptor, FieldIndex field_index,
Representation representation);
} V8_OBJECT_END;
inline const char* WasmValueType2String(WasmValueType type);
std::ostream& operator<<(std::ostream& os, WasmValueType type);
}
}
#include "src/objects/object-macros-undef.h"
#endif