Commit b51cddc1 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[ptr-compr] Isolatify LookupIterator implementation and friends

Tbr: verwaest@chromium.org
Bug: v8:9353
Change-Id: I8164e2235ca43e203410277b86e6f166010c11d6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1687673Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62597}
parent ad9ead76
......@@ -603,8 +603,8 @@ void ArrayLiteral::BuildBoilerplateDescription(Isolate* isolate) {
boilerplate_value = handle(Smi::kZero, isolate);
}
kind = GetMoreGeneralElementsKind(kind,
boilerplate_value->OptimalElementsKind());
kind = GetMoreGeneralElementsKind(
kind, boilerplate_value->OptimalElementsKind(isolate));
fixed_array->set(array_index, *boilerplate_value);
}
......
......@@ -306,7 +306,7 @@ Handle<AccessorInfo> Accessors::MakeStringLengthInfo(Isolate* isolate) {
static Handle<Object> GetFunctionPrototype(Isolate* isolate,
Handle<JSFunction> function) {
if (!function->has_prototype()) {
Handle<Object> proto = isolate->factory()->NewFunctionPrototype(function);
Handle<JSObject> proto = isolate->factory()->NewFunctionPrototype(function);
JSFunction::SetPrototype(function, proto);
}
return Handle<Object>(function->prototype(), isolate);
......
......@@ -499,7 +499,7 @@ Handle<Object> JsonParser<Char>::BuildJsonObject(
Representation expected_representation = details.representation();
if (!value->FitsRepresentation(expected_representation)) {
Representation representation = value->OptimalRepresentation();
Representation representation = value->OptimalRepresentation(isolate());
representation = representation.generalize(expected_representation);
if (!expected_representation.CanBeInPlaceChangedTo(representation)) {
map = ParentOfDescriptorOwner(isolate_, map, target, descriptor);
......
......@@ -29,12 +29,14 @@ CAST_ACCESSOR(JSArgumentsObject)
SMI_ACCESSORS(AliasedArgumentsEntry, aliased_context_slot,
kAliasedContextSlotOffset)
Context SloppyArgumentsElements::context() {
return Context::cast(get(kContextIndex));
DEF_GETTER(SloppyArgumentsElements, context, Context) {
return TaggedField<Context>::load(isolate, *this,
OffsetOfElementAt(kContextIndex));
}
FixedArray SloppyArgumentsElements::arguments() {
return FixedArray::cast(get(kArgumentsIndex));
DEF_GETTER(SloppyArgumentsElements, arguments, FixedArray) {
return TaggedField<FixedArray>::load(isolate, *this,
OffsetOfElementAt(kArgumentsIndex));
}
void SloppyArgumentsElements::set_arguments(FixedArray arguments) {
......
......@@ -102,8 +102,8 @@ class SloppyArgumentsElements : public FixedArray {
static const int kArgumentsIndex = 1;
static const uint32_t kParameterMapStart = 2;
inline Context context();
inline FixedArray arguments();
DECL_GETTER(context, Context)
DECL_GETTER(arguments, FixedArray)
inline void set_arguments(FixedArray arguments);
inline uint32_t parameter_map_length();
inline Object get_mapped_entry(uint32_t entry);
......
......@@ -98,15 +98,27 @@ RootIndex GlobalDictionaryShape::GetMapRootIndex() {
return RootIndex::kGlobalDictionaryMap;
}
Name NameDictionary::NameAt(int entry) { return Name::cast(KeyAt(entry)); }
Name NameDictionary::NameAt(int entry) {
Isolate* isolate = GetIsolateForPtrCompr(*this);
return NameAt(isolate, entry);
}
Name NameDictionary::NameAt(Isolate* isolate, int entry) {
return Name::cast(KeyAt(isolate, entry));
}
RootIndex NameDictionaryShape::GetMapRootIndex() {
return RootIndex::kNameDictionaryMap;
}
PropertyCell GlobalDictionary::CellAt(int entry) {
DCHECK(KeyAt(entry).IsPropertyCell());
return PropertyCell::cast(KeyAt(entry));
Isolate* isolate = GetIsolateForPtrCompr(*this);
return CellAt(isolate, entry);
}
PropertyCell GlobalDictionary::CellAt(Isolate* isolate, int entry) {
DCHECK(KeyAt(isolate, entry).IsPropertyCell(isolate));
return PropertyCell::cast(KeyAt(isolate, entry));
}
bool GlobalDictionaryShape::IsLive(ReadOnlyRoots roots, Object k) {
......@@ -118,8 +130,23 @@ bool GlobalDictionaryShape::IsKey(ReadOnlyRoots roots, Object k) {
return IsLive(roots, k) && !PropertyCell::cast(k).value().IsTheHole(roots);
}
Name GlobalDictionary::NameAt(int entry) { return CellAt(entry).name(); }
Object GlobalDictionary::ValueAt(int entry) { return CellAt(entry).value(); }
Name GlobalDictionary::NameAt(int entry) {
Isolate* isolate = GetIsolateForPtrCompr(*this);
return NameAt(isolate, entry);
}
Name GlobalDictionary::NameAt(Isolate* isolate, int entry) {
return CellAt(isolate, entry).name(isolate);
}
Object GlobalDictionary::ValueAt(int entry) {
Isolate* isolate = GetIsolateForPtrCompr(*this);
return ValueAt(isolate, entry);
}
Object GlobalDictionary::ValueAt(Isolate* isolate, int entry) {
return CellAt(isolate, entry).value(isolate);
}
void GlobalDictionary::SetEntry(Isolate* isolate, int entry, Object key,
Object value, PropertyDetails details) {
......
......@@ -212,6 +212,8 @@ class V8_EXPORT_PRIVATE NameDictionary
static const int kInitialCapacity = 2;
inline Name NameAt(int entry);
inline Name NameAt(Isolate* isolate, int entry);
inline void set_hash(int hash);
inline int hash() const;
......@@ -250,10 +252,13 @@ class V8_EXPORT_PRIVATE GlobalDictionary
DECL_CAST(GlobalDictionary)
inline Object ValueAt(int entry);
inline Object ValueAt(Isolate* isolate, int entry);
inline PropertyCell CellAt(int entry);
inline PropertyCell CellAt(Isolate* isolate, int entry);
inline void SetEntry(Isolate* isolate, int entry, Object key, Object value,
PropertyDetails details);
inline Name NameAt(int entry);
inline Name NameAt(Isolate* isolate, int entry);
inline void ValueAtPut(int entry, Object value);
OBJECT_CONSTRUCTORS(
......
......@@ -241,17 +241,16 @@ void JSObject::initialize_elements() {
set_elements(elements, SKIP_WRITE_BARRIER);
}
InterceptorInfo JSObject::GetIndexedInterceptor() {
return map().GetIndexedInterceptor();
DEF_GETTER(JSObject, GetIndexedInterceptor, InterceptorInfo) {
return map(isolate).GetIndexedInterceptor(isolate);
}
InterceptorInfo JSObject::GetNamedInterceptor() {
return map().GetNamedInterceptor();
DEF_GETTER(JSObject, GetNamedInterceptor, InterceptorInfo) {
return map(isolate).GetNamedInterceptor(isolate);
}
int JSObject::GetHeaderSize() const { return GetHeaderSize(map()); }
int JSObject::GetHeaderSize(const Map map) {
// static
int JSObject::GetHeaderSize(Map map) {
// Check for the most common kind of JavaScript object before
// falling into the generic switch. This speeds up the internal
// field operations considerably on average.
......@@ -262,7 +261,7 @@ int JSObject::GetHeaderSize(const Map map) {
}
// static
int JSObject::GetEmbedderFieldsStartOffset(const Map map) {
int JSObject::GetEmbedderFieldsStartOffset(Map map) {
// Embedder fields are located after the object header.
return GetHeaderSize(map);
}
......@@ -272,7 +271,7 @@ int JSObject::GetEmbedderFieldsStartOffset() {
}
// static
int JSObject::GetEmbedderFieldCount(const Map map) {
int JSObject::GetEmbedderFieldCount(Map map) {
int instance_size = map.instance_size();
if (instance_size == kVariableSizeSentinel) return 0;
// Embedder fields are located after the object header, whereas in-object
......@@ -626,7 +625,7 @@ void JSFunction::set_context(HeapObject value) {
WRITE_BARRIER(*this, kContextOffset, value);
}
ACCESSORS_CHECKED(JSFunction, prototype_or_initial_map, Object,
ACCESSORS_CHECKED(JSFunction, prototype_or_initial_map, HeapObject,
kPrototypeOrInitialMapOffset, map().has_prototype_slot())
DEF_GETTER(JSFunction, has_prototype_slot, bool) {
......
......@@ -4597,22 +4597,22 @@ static ElementsKind BestFittingFastElementsKind(JSObject object) {
void JSObject::AddDataElement(Handle<JSObject> object, uint32_t index,
Handle<Object> value,
PropertyAttributes attributes) {
DCHECK(object->map().is_extensible());
Isolate* isolate = object->GetIsolate();
DCHECK(object->map(isolate).is_extensible());
uint32_t old_length = 0;
uint32_t new_capacity = 0;
if (object->IsJSArray()) {
if (object->IsJSArray(isolate)) {
CHECK(JSArray::cast(*object).length().ToArrayLength(&old_length));
}
ElementsKind kind = object->GetElementsKind();
FixedArrayBase elements = object->elements();
ElementsKind kind = object->GetElementsKind(isolate);
FixedArrayBase elements = object->elements(isolate);
ElementsKind dictionary_kind = DICTIONARY_ELEMENTS;
if (IsSloppyArgumentsElementsKind(kind)) {
elements = SloppyArgumentsElements::cast(elements).arguments();
elements = SloppyArgumentsElements::cast(elements).arguments(isolate);
dictionary_kind = SLOW_SLOPPY_ARGUMENTS_ELEMENTS;
} else if (IsStringWrapperElementsKind(kind)) {
dictionary_kind = SLOW_STRING_WRAPPER_ELEMENTS;
......@@ -4620,7 +4620,7 @@ void JSObject::AddDataElement(Handle<JSObject> object, uint32_t index,
if (attributes != NONE) {
kind = dictionary_kind;
} else if (elements.IsNumberDictionary()) {
} else if (elements.IsNumberDictionary(isolate)) {
kind = ShouldConvertToFastElements(
*object, NumberDictionary::cast(elements), index, &new_capacity)
? BestFittingFastElementsKind(*object)
......@@ -4631,8 +4631,9 @@ void JSObject::AddDataElement(Handle<JSObject> object, uint32_t index,
kind = dictionary_kind;
}
ElementsKind to = value->OptimalElementsKind();
if (IsHoleyElementsKind(kind) || !object->IsJSArray() || index > old_length) {
ElementsKind to = value->OptimalElementsKind(isolate);
if (IsHoleyElementsKind(kind) || !object->IsJSArray(isolate) ||
index > old_length) {
to = GetHoleyElementsKind(to);
kind = GetHoleyElementsKind(kind);
}
......@@ -4640,7 +4641,7 @@ void JSObject::AddDataElement(Handle<JSObject> object, uint32_t index,
ElementsAccessor* accessor = ElementsAccessor::ForKind(to);
accessor->Add(object, index, value, attributes, new_capacity);
if (object->IsJSArray() && index >= old_length) {
if (object->IsJSArray(isolate) && index >= old_length) {
Handle<Object> new_length =
isolate->factory()->NewNumberFromUint(index + 1);
JSArray::cast(*object).set_length(*new_length);
......
......@@ -479,8 +479,8 @@ class JSObject : public JSReceiver {
int old_index, int new_index);
// Retrieve interceptors.
inline InterceptorInfo GetNamedInterceptor();
inline InterceptorInfo GetIndexedInterceptor();
DECL_GETTER(GetNamedInterceptor, InterceptorInfo)
DECL_GETTER(GetIndexedInterceptor, InterceptorInfo)
// Used from JSReceiver.
V8_WARN_UNUSED_RESULT static Maybe<PropertyAttributes>
......@@ -566,13 +566,12 @@ class JSObject : public JSReceiver {
// JSFunction objects.
static int GetHeaderSize(InstanceType instance_type,
bool function_has_prototype_slot = false);
static inline int GetHeaderSize(const Map map);
inline int GetHeaderSize() const;
static inline int GetHeaderSize(Map map);
static inline int GetEmbedderFieldsStartOffset(const Map map);
static inline int GetEmbedderFieldsStartOffset(Map map);
inline int GetEmbedderFieldsStartOffset();
static inline int GetEmbedderFieldCount(const Map map);
static inline int GetEmbedderFieldCount(Map map);
inline int GetEmbedderFieldCount() const;
inline int GetEmbedderFieldOffset(int index);
inline Object GetEmbedderField(int index);
......@@ -962,7 +961,7 @@ class JSBoundFunction : public JSObject {
class JSFunction : public JSObject {
public:
// [prototype_or_initial_map]:
DECL_ACCESSORS(prototype_or_initial_map, Object)
DECL_ACCESSORS(prototype_or_initial_map, HeapObject)
// [shared]: The information about the function that
// can be shared by instances.
......
......@@ -31,7 +31,7 @@ LookupIterator::LookupIterator(Handle<Object> receiver, Handle<Name> name,
LookupIterator::LookupIterator(Isolate* isolate, Handle<Object> receiver,
Handle<Name> name, Handle<JSReceiver> holder,
Configuration configuration)
: configuration_(ComputeConfiguration(configuration, name)),
: configuration_(ComputeConfiguration(isolate, configuration, name)),
interceptor_state_(InterceptorState::kUninitialized),
property_details_(PropertyDetails::Empty()),
isolate_(isolate),
......@@ -90,7 +90,7 @@ Handle<Name> LookupIterator::GetName() {
}
bool LookupIterator::is_dictionary_holder() const {
return !holder_->HasFastProperties();
return !holder_->HasFastProperties(isolate_);
}
Handle<Map> LookupIterator::transition_map() const {
......@@ -111,23 +111,23 @@ Handle<T> LookupIterator::GetHolder() const {
bool LookupIterator::ExtendingNonExtensible(Handle<JSReceiver> receiver) {
DCHECK(receiver.is_identical_to(GetStoreTarget<JSReceiver>()));
return !receiver->map().is_extensible() &&
(IsElement() || !name_->IsPrivate());
return !receiver->map(isolate_).is_extensible() &&
(IsElement() || !name_->IsPrivate(isolate_));
}
bool LookupIterator::IsCacheableTransition() {
DCHECK_EQ(TRANSITION, state_);
return transition_->IsPropertyCell() ||
return transition_->IsPropertyCell(isolate_) ||
(transition_map()->is_dictionary_map() &&
!GetStoreTarget<JSReceiver>()->HasFastProperties()) ||
transition_map()->GetBackPointer().IsMap();
!GetStoreTarget<JSReceiver>()->HasFastProperties(isolate_)) ||
transition_map()->GetBackPointer(isolate_).IsMap(isolate_);
}
void LookupIterator::UpdateProtector() {
if (IsElement()) return;
// This list must be kept in sync with
// CodeStubAssembler::CheckForAssociatedProtector!
ReadOnlyRoots roots(heap());
ReadOnlyRoots roots(isolate_);
if (*name_ == roots.is_concat_spreadable_symbol() ||
*name_ == roots.constructor_string() || *name_ == roots.next_string() ||
*name_ == roots.species_symbol() || *name_ == roots.iterator_symbol() ||
......@@ -139,52 +139,59 @@ void LookupIterator::UpdateProtector() {
int LookupIterator::descriptor_number() const {
DCHECK(!IsElement());
DCHECK(has_property_);
DCHECK(holder_->HasFastProperties());
DCHECK(holder_->HasFastProperties(isolate_));
return number_;
}
int LookupIterator::dictionary_entry() const {
DCHECK(!IsElement());
DCHECK(has_property_);
DCHECK(!holder_->HasFastProperties());
DCHECK(!holder_->HasFastProperties(isolate_));
return number_;
}
// static
LookupIterator::Configuration LookupIterator::ComputeConfiguration(
Configuration configuration, Handle<Name> name) {
return name->IsPrivate() ? OWN_SKIP_INTERCEPTOR : configuration;
Isolate* isolate, Configuration configuration, Handle<Name> name) {
return name->IsPrivate(isolate) ? OWN_SKIP_INTERCEPTOR : configuration;
}
// static
Handle<JSReceiver> LookupIterator::GetRoot(Isolate* isolate,
Handle<Object> receiver,
uint32_t index) {
if (receiver->IsJSReceiver()) return Handle<JSReceiver>::cast(receiver);
if (receiver->IsJSReceiver(isolate))
return Handle<JSReceiver>::cast(receiver);
return GetRootForNonJSReceiver(isolate, receiver, index);
}
template <class T>
Handle<T> LookupIterator::GetStoreTarget() const {
DCHECK(receiver_->IsJSReceiver());
if (receiver_->IsJSGlobalProxy()) {
HeapObject prototype = JSGlobalProxy::cast(*receiver_).map().prototype();
if (prototype.IsJSGlobalObject()) {
DCHECK(receiver_->IsJSReceiver(isolate_));
if (receiver_->IsJSGlobalProxy(isolate_)) {
HeapObject prototype =
JSGlobalProxy::cast(*receiver_).map(isolate_).prototype(isolate_);
if (prototype.IsJSGlobalObject(isolate_)) {
return handle(JSGlobalObject::cast(prototype), isolate_);
}
}
return Handle<T>::cast(receiver_);
}
// static
template <bool is_element>
InterceptorInfo LookupIterator::GetInterceptor(JSObject holder) {
return is_element ? holder.GetIndexedInterceptor()
: holder.GetNamedInterceptor();
InterceptorInfo LookupIterator::GetInterceptor(Isolate* isolate,
JSObject holder) {
return is_element ? holder.GetIndexedInterceptor(isolate)
: holder.GetNamedInterceptor(isolate);
}
inline Handle<InterceptorInfo> LookupIterator::GetInterceptor() const {
DCHECK_EQ(INTERCEPTOR, state_);
InterceptorInfo result =
IsElement() ? GetInterceptor<true>(JSObject::cast(*holder_))
: GetInterceptor<false>(JSObject::cast(*holder_));
JSObject holder = JSObject::cast(*holder_);
InterceptorInfo result = IsElement()
? GetInterceptor<true>(isolate_, holder)
: GetInterceptor<false>(isolate_, holder);
return handle(result, isolate_);
}
......
This diff is collapsed.
......@@ -235,7 +235,8 @@ class V8_EXPORT_PRIVATE LookupIterator final {
template <bool is_element>
bool SkipInterceptor(JSObject holder);
template <bool is_element>
static inline InterceptorInfo GetInterceptor(JSObject holder);
static inline InterceptorInfo GetInterceptor(Isolate* isolate,
JSObject holder);
bool check_interceptor() const {
return (configuration_ & kInterceptor) != 0;
......@@ -243,7 +244,8 @@ class V8_EXPORT_PRIVATE LookupIterator final {
inline int descriptor_number() const;
inline int dictionary_entry() const;
static inline Configuration ComputeConfiguration(Configuration configuration,
static inline Configuration ComputeConfiguration(Isolate* isolate,
Configuration configuration,
Handle<Name> name);
static Handle<JSReceiver> GetRootForNonJSReceiver(
......
......@@ -92,16 +92,16 @@ BIT_FIELD_ACCESSORS(Map, bit_field3, may_have_interesting_symbols,
BIT_FIELD_ACCESSORS(Map, bit_field3, construction_counter,
Map::ConstructionCounterBits)
InterceptorInfo Map::GetNamedInterceptor() {
DEF_GETTER(Map, GetNamedInterceptor, InterceptorInfo) {
DCHECK(has_named_interceptor());
FunctionTemplateInfo info = GetFunctionTemplateInfo();
return InterceptorInfo::cast(info.GetNamedPropertyHandler());
FunctionTemplateInfo info = GetFunctionTemplateInfo(isolate);
return InterceptorInfo::cast(info.GetNamedPropertyHandler(isolate));
}
InterceptorInfo Map::GetIndexedInterceptor() {
DEF_GETTER(Map, GetIndexedInterceptor, InterceptorInfo) {
DCHECK(has_indexed_interceptor());
FunctionTemplateInfo info = GetFunctionTemplateInfo();
return InterceptorInfo::cast(info.GetIndexedPropertyHandler());
FunctionTemplateInfo info = GetFunctionTemplateInfo(isolate);
return InterceptorInfo::cast(info.GetIndexedPropertyHandler(isolate));
}
bool Map::IsMostGeneralFieldType(Representation representation,
......
......@@ -481,7 +481,7 @@ MaybeHandle<Map> Map::CopyWithConstant(Isolate* isolate, Handle<Map> map,
return MaybeHandle<Map>();
}
Representation representation = constant->OptimalRepresentation();
Representation representation = constant->OptimalRepresentation(isolate);
Handle<FieldType> type = constant->OptimalType(isolate, representation);
return CopyWithField(isolate, map, name, type, attributes,
PropertyConstness::kConst, representation, flag);
......@@ -616,7 +616,8 @@ void Map::DeprecateTransitionTree(Isolate* isolate) {
void Map::ReplaceDescriptors(Isolate* isolate, DescriptorArray new_descriptors,
LayoutDescriptor new_layout_descriptor) {
// Don't overwrite the empty descriptor array or initial map's descriptors.
if (NumberOfOwnDescriptors() == 0 || GetBackPointer().IsUndefined(isolate)) {
if (NumberOfOwnDescriptors() == 0 ||
GetBackPointer(isolate).IsUndefined(isolate)) {
return;
}
......@@ -627,8 +628,8 @@ void Map::ReplaceDescriptors(Isolate* isolate, DescriptorArray new_descriptors,
Map current = *this;
MarkingBarrierForDescriptorArray(isolate->heap(), current, to_replace,
to_replace.number_of_descriptors());
while (current.instance_descriptors() == to_replace) {
Object next = current.GetBackPointer();
while (current.instance_descriptors(isolate) == to_replace) {
Object next = current.GetBackPointer(isolate);
if (next.IsUndefined(isolate)) break; // Stop overwriting at initial map.
current.SetEnumLength(kInvalidEnumCacheSentinel);
current.UpdateDescriptors(isolate, new_descriptors, new_layout_descriptor,
......@@ -641,7 +642,7 @@ void Map::ReplaceDescriptors(Isolate* isolate, DescriptorArray new_descriptors,
Map Map::FindRootMap(Isolate* isolate) const {
Map result = *this;
while (true) {
Object back = result.GetBackPointer();
Object back = result.GetBackPointer(isolate);
if (back.IsUndefined(isolate)) {
// Initial map always owns descriptors and doesn't have unused entries
// in the descriptor array.
......@@ -656,10 +657,11 @@ Map Map::FindRootMap(Isolate* isolate) const {
Map Map::FindFieldOwner(Isolate* isolate, int descriptor) const {
DisallowHeapAllocation no_allocation;
DCHECK_EQ(kField, instance_descriptors().GetDetails(descriptor).location());
DCHECK_EQ(kField,
instance_descriptors(isolate).GetDetails(descriptor).location());
Map result = *this;
while (true) {
Object back = result.GetBackPointer();
Object back = result.GetBackPointer(isolate);
if (back.IsUndefined(isolate)) break;
const Map parent = Map::cast(back);
if (parent.NumberOfOwnDescriptors() <= descriptor) break;
......@@ -895,7 +897,7 @@ IntegrityLevelTransitionInfo DetectIntegrityLevelTransitions(
// Figure out the most restrictive integrity level transition (it should
// be the last one in the transition tree).
DCHECK(!map.is_extensible());
Map previous = Map::cast(map.GetBackPointer());
Map previous = Map::cast(map.GetBackPointer(isolate));
TransitionsAccessor last_transitions(isolate, previous, no_allocation);
if (!last_transitions.HasIntegrityLevelTransitionTo(
map, &(info.integrity_level_symbol), &(info.integrity_level))) {
......@@ -913,7 +915,7 @@ IntegrityLevelTransitionInfo DetectIntegrityLevelTransitions(
// transitions. If we encounter any non-integrity level transition interleaved
// with integrity level transitions, just bail out.
while (!source_map.is_extensible()) {
previous = Map::cast(source_map.GetBackPointer());
previous = Map::cast(source_map.GetBackPointer(isolate));
TransitionsAccessor transitions(isolate, previous, no_allocation);
if (!transitions.HasIntegrityLevelTransitionTo(source_map)) {
return info;
......@@ -2067,7 +2069,7 @@ Handle<Map> UpdateDescriptorForValue(Isolate* isolate, Handle<Map> map,
PropertyAttributes attributes =
map->instance_descriptors().GetDetails(descriptor).attributes();
Representation representation = value->OptimalRepresentation();
Representation representation = value->OptimalRepresentation(isolate);
Handle<FieldType> type = value->OptimalType(isolate, representation);
MapUpdater mu(isolate, map);
......@@ -2126,7 +2128,7 @@ Handle<Map> Map::TransitionToDataProperty(Isolate* isolate, Handle<Map> map,
isolate->bootstrapper()->IsActive() ? OMIT_TRANSITION : INSERT_TRANSITION;
MaybeHandle<Map> maybe_map;
if (!map->TooManyFastProperties(store_origin)) {
Representation representation = value->OptimalRepresentation();
Representation representation = value->OptimalRepresentation(isolate);
Handle<FieldType> type = value->OptimalType(isolate, representation);
maybe_map = Map::CopyWithField(isolate, map, name, type, attributes,
constness, representation, flag);
......
......@@ -215,8 +215,8 @@ class Map : public HeapObject {
Handle<Map> map, Handle<Context> native_context);
// Retrieve interceptors.
inline InterceptorInfo GetNamedInterceptor();
inline InterceptorInfo GetIndexedInterceptor();
DECL_GETTER(GetNamedInterceptor, InterceptorInfo)
DECL_GETTER(GetIndexedInterceptor, InterceptorInfo)
// Instance type.
DECL_PRIMITIVE_ACCESSORS(instance_type, InstanceType)
......
......@@ -531,25 +531,28 @@ bool Object::FilterKey(PropertyFilter filter) {
return false;
}
Representation Object::OptimalRepresentation() {
Representation Object::OptimalRepresentation(Isolate* isolate) const {
if (!FLAG_track_fields) return Representation::Tagged();
if (IsSmi()) {
return Representation::Smi();
} else if (FLAG_track_double_fields && IsHeapNumber()) {
}
HeapObject heap_object = HeapObject::cast(*this);
if (FLAG_track_double_fields && heap_object.IsHeapNumber(isolate)) {
return Representation::Double();
} else if (FLAG_track_computed_fields && IsUninitialized()) {
} else if (FLAG_track_computed_fields &&
heap_object.IsUninitialized(
heap_object.GetReadOnlyRoots(isolate))) {
return Representation::None();
} else if (FLAG_track_heap_object_fields) {
DCHECK(IsHeapObject());
return Representation::HeapObject();
} else {
return Representation::Tagged();
}
}
ElementsKind Object::OptimalElementsKind() {
ElementsKind Object::OptimalElementsKind(Isolate* isolate) const {
if (IsSmi()) return PACKED_SMI_ELEMENTS;
if (IsNumber()) return PACKED_DOUBLE_ELEMENTS;
if (IsNumber(isolate)) return PACKED_DOUBLE_ELEMENTS;
return PACKED_ELEMENTS;
}
......
......@@ -309,9 +309,9 @@ class Object : public TaggedImpl<HeapObjectReferenceType::STRONG, Address> {
V8_EXPORT_PRIVATE bool ToInt32(int32_t* value);
inline bool ToUint32(uint32_t* value) const;
inline Representation OptimalRepresentation();
inline Representation OptimalRepresentation(Isolate* isolate) const;
inline ElementsKind OptimalElementsKind();
inline ElementsKind OptimalElementsKind(Isolate* isolate) const;
inline bool FitsRepresentation(Representation representation);
......
......@@ -75,9 +75,10 @@ Descriptor Descriptor::DataField(Handle<Name> key, int field_index,
Descriptor Descriptor::DataConstant(Handle<Name> key, Handle<Object> value,
PropertyAttributes attributes) {
Isolate* isolate = GetIsolateForPtrCompr(*key);
return Descriptor(key, MaybeObjectHandle(value), kData, attributes,
kDescriptor, PropertyConstness::kConst,
value->OptimalRepresentation(), 0);
value->OptimalRepresentation(isolate), 0);
}
Descriptor Descriptor::DataConstant(Isolate* isolate, Handle<Name> key,
......
......@@ -55,7 +55,7 @@ SMI_ACCESSORS(FunctionTemplateInfo, flag, kFlagOffset)
// static
FunctionTemplateRareData FunctionTemplateInfo::EnsureFunctionTemplateRareData(
Isolate* isolate, Handle<FunctionTemplateInfo> function_template_info) {
HeapObject extra = function_template_info->rare_data();
HeapObject extra = function_template_info->rare_data(isolate);
if (extra.IsUndefined(isolate)) {
return AllocateFunctionTemplateRareData(isolate, function_template_info);
} else {
......@@ -64,9 +64,9 @@ FunctionTemplateRareData FunctionTemplateInfo::EnsureFunctionTemplateRareData(
}
#define RARE_ACCESSORS(Name, CamelName, Type) \
Type FunctionTemplateInfo::Get##CamelName() { \
HeapObject extra = rare_data(); \
HeapObject undefined = GetReadOnlyRoots().undefined_value(); \
DEF_GETTER(FunctionTemplateInfo, Get##CamelName, Type) { \
HeapObject extra = rare_data(isolate); \
HeapObject undefined = GetReadOnlyRoots(isolate).undefined_value(); \
return extra == undefined ? undefined \
: FunctionTemplateRareData::cast(extra).Name(); \
} \
......
......@@ -86,7 +86,7 @@ class FunctionTemplateInfo : public TemplateInfo {
DECL_ACCESSORS(rare_data, HeapObject)
#define DECL_RARE_ACCESSORS(Name, CamelName, Type) \
inline Type Get##CamelName(); \
DECL_GETTER(Get##CamelName, Type) \
static inline void Set##CamelName( \
Isolate* isolate, Handle<FunctionTemplateInfo> function_template_info, \
Handle<Type> Name);
......
......@@ -194,13 +194,13 @@ void TransitionsAccessor::Reload() {
}
void TransitionsAccessor::Initialize() {
raw_transitions_ = map_.raw_transitions();
raw_transitions_ = map_.raw_transitions(isolate_);
HeapObject heap_object;
if (raw_transitions_->IsSmi() || raw_transitions_->IsCleared()) {
encoding_ = kUninitialized;
} else if (raw_transitions_->IsWeak()) {
encoding_ = kWeakRef;
} else if (raw_transitions_->GetHeapObjectIfStrong(&heap_object)) {
} else if (raw_transitions_->GetHeapObjectIfStrong(isolate_, &heap_object)) {
if (heap_object.IsTransitionArray()) {
encoding_ = kFullTransitionArray;
} else if (heap_object.IsPrototypeInfo()) {
......
......@@ -332,7 +332,8 @@ bool AddDescriptorsByTemplate(
value = GetMethodWithSharedNameAndSetHomeObject(isolate, args, value,
*receiver);
}
details = details.CopyWithRepresentation(value.OptimalRepresentation());
details = details.CopyWithRepresentation(
value.OptimalRepresentation(isolate));
} else {
DCHECK_EQ(kAccessor, details.kind());
if (value.IsAccessorPair()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment