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