Commit 110f78f0 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[GetIsolate] More low-hanging GetIsolate fruit

FeedbackVector and AllocationSite are now NeverReadOnlySpaceObjects

Bug: v8:7786
Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
Change-Id: I6109c0c4a391b19c5c77c61b52aae989707fecc4
Reviewed-on: https://chromium-review.googlesource.com/1120532
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54139}
parent b3aefb32
......@@ -6453,10 +6453,9 @@ i::Object** Context::GetDataFromSnapshotOnce(size_t index) {
MaybeLocal<v8::Object> ObjectTemplate::NewInstance(Local<Context> context) {
PREPARE_FOR_EXECUTION(context, ObjectTemplate, NewInstance, Object);
auto self = Utils::OpenHandle(this);
i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate();
Local<Object> result;
has_pending_exception = !ToLocal<Object>(
i::ApiNatives::InstantiateObject(i_isolate, self), &result);
i::ApiNatives::InstantiateObject(isolate, self), &result);
RETURN_ON_FAILED_EXECUTION(Object);
RETURN_ESCAPED(result);
}
......
......@@ -250,9 +250,7 @@ OPEN_HANDLE_LIST(DECLARE_OPEN_HANDLE)
template<class From, class To>
static inline Local<To> Convert(v8::internal::Handle<From> obj) {
DCHECK(obj.is_null() ||
(obj->IsSmi() ||
!obj->IsTheHole(i::HeapObject::cast(*obj)->GetIsolate())));
DCHECK(obj.is_null() || (obj->IsSmi() || !obj->IsTheHole()));
return Local<To>(reinterpret_cast<To*>(obj.location()));
}
......
......@@ -55,8 +55,6 @@ FeedbackVector* FeedbackVector::cast(Object* obj) {
return reinterpret_cast<FeedbackVector*>(obj);
}
Isolate* FeedbackVector::GetIsolate() const { return GetHeap()->isolate(); }
int FeedbackMetadata::GetSlotSize(FeedbackSlotKind kind) {
switch (kind) {
case FeedbackSlotKind::kForIn:
......
......@@ -140,13 +140,16 @@ class FeedbackMetadata;
// - optimized code cell (weak cell or Smi marker)
// followed by an array of feedback slots, of length determined by the feedback
// metadata.
class FeedbackVector : public HeapObject {
class FeedbackVector : public HeapObject, public NeverReadOnlySpaceObject {
public:
// Use the mixin methods over the HeapObject methods.
// TODO(v8:7786) Remove once the HeapObject methods are gone.
using NeverReadOnlySpaceObject::GetHeap;
using NeverReadOnlySpaceObject::GetIsolate;
// Casting.
static inline FeedbackVector* cast(Object* obj);
inline Isolate* GetIsolate() const;
inline void ComputeCounts(int* with_type_info, int* generic,
int* vector_ic_count);
......
......@@ -56,7 +56,7 @@ class V8_EXPORT_PRIVATE LookupIterator final BASE_EMBEDDED {
LookupIterator(Handle<Object> receiver, Handle<Name> name,
Handle<JSReceiver> holder,
Configuration configuration = DEFAULT)
: LookupIterator(name->GetIsolate(), receiver, name, holder,
: LookupIterator(holder->GetIsolate(), receiver, name, holder,
configuration) {}
LookupIterator(Isolate* isolate, Handle<Object> receiver, Handle<Name> name,
......
......@@ -2964,8 +2964,8 @@ MaybeHandle<Object> Object::SetPropertyOrElement(Handle<Object> object,
MaybeHandle<Object> Object::GetPropertyOrElement(Handle<Object> receiver,
Handle<Name> name,
Handle<JSReceiver> holder) {
LookupIterator it = LookupIterator::PropertyOrElement(
name->GetIsolate(), receiver, name, holder);
LookupIterator it = LookupIterator::PropertyOrElement(holder->GetIsolate(),
receiver, name, holder);
return GetProperty(&it);
}
......@@ -3039,7 +3039,7 @@ Maybe<bool> JSReceiver::HasOwnProperty(Handle<JSReceiver> object,
Maybe<PropertyAttributes> JSReceiver::GetPropertyAttributes(
Handle<JSReceiver> object, Handle<Name> name) {
LookupIterator it = LookupIterator::PropertyOrElement(name->GetIsolate(),
LookupIterator it = LookupIterator::PropertyOrElement(object->GetIsolate(),
object, name, object);
return GetPropertyAttributes(&it);
}
......@@ -3048,7 +3048,7 @@ Maybe<PropertyAttributes> JSReceiver::GetPropertyAttributes(
Maybe<PropertyAttributes> JSReceiver::GetOwnPropertyAttributes(
Handle<JSReceiver> object, Handle<Name> name) {
LookupIterator it = LookupIterator::PropertyOrElement(
name->GetIsolate(), object, name, object, LookupIterator::OWN);
object->GetIsolate(), object, name, object, LookupIterator::OWN);
return GetPropertyAttributes(&it);
}
......
......@@ -7977,7 +7977,7 @@ Maybe<bool> JSProxy::GetOwnPropertyDescriptor(Isolate* isolate,
bool JSObject::ReferencesObjectFromElements(FixedArray* elements,
ElementsKind kind,
Object* object) {
Isolate* isolate = elements->GetIsolate();
Isolate* isolate = GetIsolate();
if (IsObjectElementsKind(kind) || kind == FAST_STRING_WRAPPER_ELEMENTS) {
int length = IsJSArray() ? Smi::ToInt(JSArray::cast(this)->length())
: elements->length();
......@@ -10249,7 +10249,7 @@ void FixedArrayOfWeakCells::Set(Isolate* isolate,
DCHECK(array->IsEmptySlot(index)); // Don't overwrite anything.
Handle<WeakCell> cell =
value->IsMap() ? Map::WeakCellForMap(isolate, Handle<Map>::cast(value))
: array->GetIsolate()->factory()->NewWeakCell(value);
: isolate->factory()->NewWeakCell(value);
Handle<FixedArray>::cast(array)->set(index + kFirstIndex, *cell);
array->set_last_used_index(index);
}
......@@ -10261,8 +10261,7 @@ Handle<FixedArrayOfWeakCells> FixedArrayOfWeakCells::Add(
int* assigned_index) {
Handle<FixedArrayOfWeakCells> array =
(maybe_array.is_null() || !maybe_array->IsFixedArrayOfWeakCells())
? Allocate(value->GetIsolate(), 1,
Handle<FixedArrayOfWeakCells>::null())
? Allocate(isolate, 1, Handle<FixedArrayOfWeakCells>::null())
: Handle<FixedArrayOfWeakCells>::cast(maybe_array);
// Try to store the new entry if there's room. Optimize for consecutive
// accesses.
......@@ -10283,7 +10282,7 @@ Handle<FixedArrayOfWeakCells> FixedArrayOfWeakCells::Add(
// No usable slot found, grow the array.
int new_length = length == 0 ? 1 : length + (length >> 1) + 4;
Handle<FixedArrayOfWeakCells> new_array =
Allocate(array->GetIsolate(), new_length, array);
Allocate(isolate, new_length, array);
FixedArrayOfWeakCells::Set(isolate, new_array, length, value);
if (assigned_index != nullptr) *assigned_index = length;
return new_array;
......@@ -14834,7 +14833,7 @@ void BytecodeArray::Disassemble(Isolate* isolate, std::ostream& os) {
Address base_address = GetFirstBytecodeAddress();
SourcePositionTableIterator source_positions(SourcePositionTable());
interpreter::BytecodeArrayIterator iterator(handle(this, this->GetIsolate()));
interpreter::BytecodeArrayIterator iterator(handle(this, isolate));
while (!iterator.done()) {
if (!source_positions.done() &&
iterator.current_offset() == source_positions.code_offset()) {
......
......@@ -3939,7 +3939,7 @@ class JSMessageObject: public JSObject {
typedef BodyDescriptor BodyDescriptorWeak;
};
class AllocationSite: public Struct {
class AllocationSite : public Struct, public NeverReadOnlySpaceObject {
public:
static const uint32_t kMaximumArrayBytesToPretransition = 8 * 1024;
static const double kPretenureRatio;
......@@ -3955,6 +3955,11 @@ class AllocationSite: public Struct {
kLastPretenureDecisionValue = kZombie
};
// Use the mixin methods over the HeapObject methods.
// TODO(v8:7786) Remove once the HeapObject methods are gone.
using NeverReadOnlySpaceObject::GetHeap;
using NeverReadOnlySpaceObject::GetIsolate;
const char* PretenureDecisionName(PretenureDecision decision);
// Contains either a Smi-encoded bitfield or a boilerplate. If it's a Smi the
......
......@@ -44,7 +44,7 @@ uint32_t CompilationCacheShape::HashForObject(Isolate* isolate,
if (object->IsNumber()) return static_cast<uint32_t>(object->Number());
FixedArray* val = FixedArray::cast(object);
if (val->map() == val->GetHeap()->fixed_cow_array_map()) {
if (val->map() == isolate->heap()->fixed_cow_array_map()) {
DCHECK_EQ(4, val->length());
SharedFunctionInfo* shared = SharedFunctionInfo::cast(val->get(0));
String* source = String::cast(val->get(1));
......
......@@ -1397,7 +1397,7 @@ struct CheckCopyGeneralizeAllFields {
CHECK(!map->is_deprecated());
CHECK_NE(*map, *new_map);
CHECK(new_map->GetBackPointer()->IsUndefined(map->GetIsolate()));
CHECK(new_map->GetBackPointer()->IsUndefined(isolate));
for (int i = 0; i < kPropCount; i++) {
expectations.GeneralizeField(i);
}
......
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