#include <stdlib.h>
#include <initializer_list>
#include <utility>
#include "src/base/logging.h"
#include "src/execution/execution.h"
#include "src/heap/factory-inl.h"
#include "src/objects/field-type.h"
#include "src/objects/heap-number-inl.h"
#include "src/objects/internal-index.h"
#include "src/objects/map-updater.h"
#include "src/objects/objects-inl.h"
#include "src/objects/property-details.h"
#include "src/objects/property.h"
#include "src/objects/struct-inl.h"
#include "src/objects/transitions.h"
#include "src/utils/ostreams.h"
#include "test/cctest/cctest.h"
namespace v8 {
namespace internal {
namespace compiler {
namespace test_field_type_tracking {
const bool IS_PROTO_TRANS_ISSUE_FIXED = …;
const bool IS_ACCESSOR_FIELD_SUPPORTED = …;
const int kPropCount = …;
enum ChangeAlertMechanism { … };
static Handle<AccessorPair> CreateAccessorPair(bool with_getter,
bool with_setter) { … }
static void CheckMigrationTarget(Isolate* isolate, Tagged<Map> old_map,
Tagged<Map> new_map) { … }
class Expectations { … };
namespace {
Handle<Map> ReconfigureProperty(Isolate* isolate, Handle<Map> map,
InternalIndex modify_index,
PropertyKind new_kind,
PropertyAttributes new_attributes,
Representation new_representation,
Handle<FieldType> new_field_type) { … }
}
TEST(ReconfigureAccessorToNonExistingDataField) { … }
TEST(ReconfigureAccessorToNonExistingDataFieldHeavy) { … }
namespace {
struct CRFTData { … };
Handle<Code> CreateDummyOptimizedCode(Isolate* isolate) { … }
static void CheckCodeObjectForDeopt(const CRFTData& from,
const CRFTData& expected,
DirectHandle<Code> code_field_type,
DirectHandle<Code> code_field_repr,
Handle<Code> code_field_const,
bool expected_deopt) { … }
void TestGeneralizeField(int detach_property_at_index, int property_index,
const CRFTData& from, const CRFTData& to,
const CRFTData& expected,
ChangeAlertMechanism expected_alert) { … }
void TestGeneralizeField(const CRFTData& from, const CRFTData& to,
const CRFTData& expected,
ChangeAlertMechanism expected_alert) { … }
}
TEST(GeneralizeSmiFieldToDouble) { … }
TEST(GeneralizeSmiFieldToTagged) { … }
TEST(GeneralizeDoubleFieldToTagged) { … }
TEST(GeneralizeHeapObjectFieldToTagged) { … }
TEST(GeneralizeHeapObjectFieldToHeapObject) { … }
TEST(GeneralizeNoneFieldToSmi) { … }
TEST(GeneralizeNoneFieldToDouble) { … }
TEST(GeneralizeNoneFieldToHeapObject) { … }
TEST(GeneralizeNoneFieldToTagged) { … }
TEST(GeneralizeFieldWithAccessorProperties) { … }
namespace {
void TestReconfigureDataFieldAttribute_GeneralizeField(
const CRFTData& from, const CRFTData& to, const CRFTData& expected,
ChangeAlertMechanism expected_alert) { … }
}
TEST(ReconfigureDataFieldAttribute_GeneralizeSmiFieldToDouble) { … }
TEST(ReconfigureDataFieldAttribute_GeneralizeSmiFieldToTagged) { … }
TEST(ReconfigureDataFieldAttribute_GeneralizeDoubleFieldToTagged) { … }
TEST(ReconfigureDataFieldAttribute_GeneralizeHeapObjFieldToHeapObj) { … }
TEST(ReconfigureDataFieldAttribute_GeneralizeHeapObjectFieldToTagged) { … }
struct CheckDeprecated { … };
struct CheckSameMap { … };
struct CheckUnrelated { … };
struct CheckNormalize { … };
template <typename TestConfig, typename Checker>
static void TestReconfigureProperty_CustomPropertyAfterTargetMap(
TestConfig* config, Checker* checker) { … }
TEST(ReconfigureDataFieldAttribute_SameDataConstantAfterTargetMap) { … }
TEST(ReconfigureDataFieldAttribute_DataConstantToDataFieldAfterTargetMap) { … }
TEST(ReconfigureDataFieldAttribute_DataConstantToAccConstantAfterTargetMap) { … }
TEST(ReconfigureDataFieldAttribute_SameAccessorConstantAfterTargetMap) { … }
TEST(ReconfigureDataFieldAttribute_AccConstantToAccFieldAfterTargetMap) { … }
TEST(ReconfigureDataFieldAttribute_AccConstantToDataFieldAfterTargetMap) { … }
namespace {
static void TestReconfigureElementsKind_GeneralizeFieldInPlace(
const CRFTData& from, const CRFTData& to, const CRFTData& expected) { … }
}
TEST(ReconfigureElementsKind_GeneralizeSmiFieldToDouble) { … }
TEST(ReconfigureElementsKind_GeneralizeSmiFieldToTagged) { … }
TEST(ReconfigureElementsKind_GeneralizeDoubleFieldToTagged) { … }
TEST(ReconfigureElementsKind_GeneralizeHeapObjFieldToHeapObj) { … }
TEST(ReconfigureElementsKind_GeneralizeHeapObjectFieldToTagged) { … }
TEST(ReconfigurePropertySplitMapTransitionsOverflow) { … }
enum class UpdateDirectionCheck { … };
template <typename TestConfig>
static void TestGeneralizeFieldWithSpecialTransition(
TestConfig* config, const CRFTData& from, const CRFTData& to,
const CRFTData& expected, ChangeAlertMechanism expected_alert,
UpdateDirectionCheck direction = UpdateDirectionCheck::kFwd) { … }
template <typename TestConfig>
void TestMultipleElementsKindTransitions(Isolate* isolate, TestConfig* config,
UpdateDirectionCheck direction) { … }
TEST(ElementsKindTransitionFromMapOwningDescriptor) { … }
TEST(ElementsKindTransitionFromMapNotOwningDescriptor) { … }
template <typename TestConfig>
void TestMultiplePrototypeTransitions(Isolate* isolate, TestConfig* config) { … }
TEST(PrototypeTransitionFromMapOwningDescriptor) { … }
TEST(PrototypeTransitionFromMapNotOwningDescriptor) { … }
template <typename TestConfig>
static void TestGeneralizeFieldWithSpecialTransitionLegacy(
TestConfig* config, const CRFTData& from, const CRFTData& to,
const CRFTData& expected, ChangeAlertMechanism expected_alert) { … }
TEST(ElementsKindTransitionFromMapOwningDescriptorLegacy) { … }
TEST(ElementsKindTransitionFromMapNotOwningDescriptorLegacy) { … }
TEST(PrototypeTransitionFromMapOwningDescriptorLegacy) { … }
TEST(PrototypeTransitionFromMapNotOwningDescriptorLegacy) { … }
struct TransitionToDataFieldOperator { … };
struct TransitionToDataConstantOperator { … };
struct TransitionToAccessorConstantOperator { … };
struct ReconfigureAsDataPropertyOperator { … };
struct ReconfigureAsAccessorPropertyOperator { … };
struct FieldGeneralizationChecker { … };
struct SameMapChecker { … };
struct PropertyKindReconfigurationChecker { … };
template <typename TransitionOp1, typename TransitionOp2, typename Checker>
static void TestTransitionTo(TransitionOp1* transition_op1,
TransitionOp2* transition_op2, Checker* checker) { … }
TEST(TransitionDataFieldToDataField) { … }
TEST(TransitionDataConstantToSameDataConstant) { … }
TEST(TransitionDataConstantToAnotherDataConstant) { … }
TEST(TransitionDataConstantToDataField) { … }
TEST(TransitionAccessorConstantToSameAccessorConstant) { … }
TEST(HoleyHeapNumber) { … }
namespace {
template <class... Args>
MaybeHandle<Object> Call(Isolate* isolate, Handle<JSFunction> function,
Args... args) { … }
void TestStoreToConstantField(const char* store_func_source,
Handle<Object> value1, Handle<Object> value2,
Representation expected_rep,
PropertyConstness expected_constness,
int store_repetitions) { … }
void TestStoreToConstantField_PlusMinusZero(const char* store_func_source,
int store_repetitions) { … }
void TestStoreToConstantField_NaN(const char* store_func_source,
int store_repetitions) { … }
}
TEST(StoreToConstantField_PlusMinusZero) { … }
TEST(StoreToConstantField_ObjectDefineProperty) { … }
TEST(StoreToConstantField_ReflectSet) { … }
TEST(StoreToConstantField_StoreIC) { … }
TEST(NormalizeToMigrationTarget) { … }
TEST(RepresentationPredicatesAreInSync) { … }
#define CHECK_SAME …
TEST(CheckFitsRepresentationPredicate) { … }
#undef CHECK_SAME
}
}
}
}