Commit 07cfad7a authored by Marja Hölttä's avatar Marja Hölttä Committed by Commit Bot

[in-place weak refs] Pass MaybeObjectHandles as const&

BUG=v8:7308

Change-Id: I564f340096e64b3d17f9367aea031148a40faf40
Reviewed-on: https://chromium-review.googlesource.com/1218742Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55778}
parent 8238a9b2
......@@ -17,7 +17,7 @@ CompilationDependencies::CompilationDependencies(Isolate* isolate, Zone* zone)
class CompilationDependencies::Dependency : public ZoneObject {
public:
virtual bool IsValid() const = 0;
virtual void Install(MaybeObjectHandle code) = 0;
virtual void Install(const MaybeObjectHandle& code) = 0;
};
class InitialMapDependency final : public CompilationDependencies::Dependency {
......@@ -36,7 +36,7 @@ class InitialMapDependency final : public CompilationDependencies::Dependency {
function->initial_map() == *initial_map_.object<Map>();
}
void Install(MaybeObjectHandle code) override {
void Install(const MaybeObjectHandle& code) override {
SLOW_DCHECK(IsValid());
DependentCode::InstallDependency(function_.isolate(), code,
initial_map_.object<Map>(),
......@@ -68,7 +68,7 @@ class PrototypePropertyDependency final
function->prototype() == *prototype_.object();
}
void Install(MaybeObjectHandle code) override {
void Install(const MaybeObjectHandle& code) override {
SLOW_DCHECK(IsValid());
Handle<JSFunction> function = function_.object<JSFunction>();
if (!function->has_initial_map()) JSFunction::EnsureHasInitialMap(function);
......@@ -90,7 +90,7 @@ class StableMapDependency final : public CompilationDependencies::Dependency {
bool IsValid() const override { return map_.object<Map>()->is_stable(); }
void Install(MaybeObjectHandle code) override {
void Install(const MaybeObjectHandle& code) override {
SLOW_DCHECK(IsValid());
DependentCode::InstallDependency(map_.isolate(), code, map_.object<Map>(),
DependentCode::kPrototypeCheckGroup);
......@@ -108,7 +108,7 @@ class TransitionDependency final : public CompilationDependencies::Dependency {
bool IsValid() const override { return !map_.object<Map>()->is_deprecated(); }
void Install(MaybeObjectHandle code) override {
void Install(const MaybeObjectHandle& code) override {
SLOW_DCHECK(IsValid());
DependentCode::InstallDependency(map_.isolate(), code, map_.object<Map>(),
DependentCode::kTransitionGroup);
......@@ -132,7 +132,7 @@ class PretenureModeDependency final
return mode_ == site_.object<AllocationSite>()->GetPretenureMode();
}
void Install(MaybeObjectHandle code) override {
void Install(const MaybeObjectHandle& code) override {
SLOW_DCHECK(IsValid());
DependentCode::InstallDependency(
site_.isolate(), code, site_.object<AllocationSite>(),
......@@ -162,7 +162,7 @@ class FieldTypeDependency final : public CompilationDependencies::Dependency {
return *type == owner->instance_descriptors()->GetFieldType(descriptor_);
}
void Install(MaybeObjectHandle code) override {
void Install(const MaybeObjectHandle& code) override {
SLOW_DCHECK(IsValid());
DependentCode::InstallDependency(owner_.isolate(), code,
owner_.object<Map>(),
......@@ -193,7 +193,7 @@ class GlobalPropertyDependency final
read_only_ == cell->property_details().IsReadOnly();
}
void Install(MaybeObjectHandle code) override {
void Install(const MaybeObjectHandle& code) override {
SLOW_DCHECK(IsValid());
DependentCode::InstallDependency(cell_.isolate(), code,
cell_.object<PropertyCell>(),
......@@ -217,7 +217,7 @@ class ProtectorDependency final : public CompilationDependencies::Dependency {
return cell->value() == Smi::FromInt(Isolate::kProtectorValid);
}
void Install(MaybeObjectHandle code) override {
void Install(const MaybeObjectHandle& code) override {
SLOW_DCHECK(IsValid());
DependentCode::InstallDependency(cell_.isolate(), code,
cell_.object<PropertyCell>(),
......@@ -249,7 +249,7 @@ class ElementsKindDependency final
return kind_ == kind;
}
void Install(MaybeObjectHandle code) override {
void Install(const MaybeObjectHandle& code) override {
SLOW_DCHECK(IsValid());
DependentCode::InstallDependency(
site_.isolate(), code, site_.object<AllocationSite>(),
......@@ -277,7 +277,7 @@ class InitialMapInstanceSizePredictionDependency final
return instance_size == instance_size_;
}
void Install(MaybeObjectHandle code) override {
void Install(const MaybeObjectHandle& code) override {
DCHECK(IsValid());
// Finish the slack tracking.
function_.object<JSFunction>()->CompleteInobjectSlackTrackingIfActive();
......
......@@ -140,7 +140,7 @@ Handle<Object> LoadHandler::LoadFromPrototype(Isolate* isolate,
// static
Handle<Object> LoadHandler::LoadFullChain(Isolate* isolate,
Handle<Map> receiver_map,
MaybeObjectHandle holder,
const MaybeObjectHandle& holder,
Handle<Smi> smi_handler) {
Handle<JSReceiver> end; // null handle, means full prototype chain lookup.
MaybeObjectHandle data1 = holder;
......
......@@ -150,7 +150,7 @@ class LoadHandler final : public DataHandler {
// needed (e.g., for "nonexistent"), null_value() may be passed in.
static Handle<Object> LoadFullChain(Isolate* isolate,
Handle<Map> receiver_map,
MaybeObjectHandle holder,
const MaybeObjectHandle& holder,
Handle<Smi> smi_handler);
// Creates a data handler that represents a prototype chain check followed
......
......@@ -4717,7 +4717,7 @@ Map* Map::FindFieldOwner(Isolate* isolate, int descriptor) const {
void Map::UpdateFieldType(Isolate* isolate, int descriptor, Handle<Name> name,
PropertyConstness new_constness,
Representation new_representation,
MaybeObjectHandle new_wrapped_type) {
const MaybeObjectHandle& new_wrapped_type) {
DCHECK(new_wrapped_type->IsSmi() || new_wrapped_type->IsWeakHeapObject());
// We store raw pointers in the queue, so no allocations are allowed.
DisallowHeapAllocation no_allocation;
......@@ -10525,7 +10525,7 @@ Handle<ArrayList> ArrayList::EnsureSpace(Isolate* isolate,
// static
Handle<WeakArrayList> WeakArrayList::AddToEnd(Isolate* isolate,
Handle<WeakArrayList> array,
MaybeObjectHandle value) {
const MaybeObjectHandle& value) {
int length = array->length();
array = EnsureSpace(isolate, array, length + 1);
// Reload length; GC might have removed elements from the array.
......@@ -10563,7 +10563,7 @@ int WeakArrayList::CountLiveWeakReferences() const {
return live_weak_references;
}
bool WeakArrayList::RemoveOne(MaybeObjectHandle value) {
bool WeakArrayList::RemoveOne(const MaybeObjectHandle& value) {
if (length() == 0) return false;
// Optimize for the most recently added element to be removed again.
int last_index = length() - 1;
......@@ -15319,7 +15319,8 @@ void DependentCode::SetDependentCode(Handle<HeapObject> object,
}
}
void DependentCode::InstallDependency(Isolate* isolate, MaybeObjectHandle code,
void DependentCode::InstallDependency(Isolate* isolate,
const MaybeObjectHandle& code,
Handle<HeapObject> object,
DependencyGroup group) {
Handle<DependentCode> old_deps(DependentCode::GetDependentCode(object),
......@@ -15333,7 +15334,7 @@ void DependentCode::InstallDependency(Isolate* isolate, MaybeObjectHandle code,
Handle<DependentCode> DependentCode::InsertWeakCode(
Isolate* isolate, Handle<DependentCode> entries, DependencyGroup group,
MaybeObjectHandle code) {
const MaybeObjectHandle& code) {
if (entries->length() == 0 || entries->group() > group) {
// There is no such group.
return DependentCode::New(isolate, group, code, entries);
......@@ -15366,7 +15367,7 @@ Handle<DependentCode> DependentCode::InsertWeakCode(
Handle<DependentCode> DependentCode::New(Isolate* isolate,
DependencyGroup group,
MaybeObjectHandle object,
const MaybeObjectHandle& object,
Handle<DependentCode> next) {
Handle<DependentCode> result = Handle<DependentCode>::cast(
isolate->factory()->NewWeakFixedArray(kCodesStartIndex + 1, TENURED));
......
......@@ -624,7 +624,7 @@ class DependentCode : public WeakFixedArray {
};
// Register a code dependency of {cell} on {object}.
static void InstallDependency(Isolate* isolate, MaybeObjectHandle code,
static void InstallDependency(Isolate* isolate, const MaybeObjectHandle& code,
Handle<HeapObject> object,
DependencyGroup group);
......@@ -650,14 +650,14 @@ class DependentCode : public WeakFixedArray {
Handle<DependentCode> dep);
static Handle<DependentCode> New(Isolate* isolate, DependencyGroup group,
MaybeObjectHandle object,
const MaybeObjectHandle& object,
Handle<DependentCode> next);
static Handle<DependentCode> EnsureSpace(Isolate* isolate,
Handle<DependentCode> entries);
static Handle<DependentCode> InsertWeakCode(Isolate* isolate,
Handle<DependentCode> entries,
DependencyGroup group,
MaybeObjectHandle code);
const MaybeObjectHandle& code);
// Compact by removing cleared weak cells and return true if there was
// any cleared weak cell.
......
......@@ -334,7 +334,7 @@ class WeakArrayList : public HeapObject {
static Handle<WeakArrayList> AddToEnd(Isolate* isolate,
Handle<WeakArrayList> array,
MaybeObjectHandle value);
const MaybeObjectHandle& value);
inline MaybeObject* Get(int index) const;
......@@ -381,7 +381,7 @@ class WeakArrayList : public HeapObject {
// around in the array - this method can only be used in cases where the user
// doesn't care about the indices! Users should make sure there are no
// duplicates.
bool RemoveOne(MaybeObjectHandle value);
bool RemoveOne(const MaybeObjectHandle& value);
class Iterator {
public:
......
......@@ -945,7 +945,7 @@ class Map : public HeapObject {
void UpdateFieldType(Isolate* isolate, int descriptor_number,
Handle<Name> name, PropertyConstness new_constness,
Representation new_representation,
MaybeObjectHandle new_wrapped_type);
const MaybeObjectHandle& new_wrapped_type);
// TODO(ishell): Move to MapUpdater.
void PrintReconfiguration(Isolate* isolate, FILE* file, int modify_index,
......
......@@ -25,7 +25,7 @@ std::ostream& operator<<(std::ostream& os,
Descriptor::Descriptor() : details_(Smi::kZero) {}
Descriptor::Descriptor(Handle<Name> key, MaybeObjectHandle value,
Descriptor::Descriptor(Handle<Name> key, const MaybeObjectHandle& value,
PropertyKind kind, PropertyAttributes attributes,
PropertyLocation location, PropertyConstness constness,
Representation representation, int field_index)
......@@ -37,7 +37,7 @@ Descriptor::Descriptor(Handle<Name> key, MaybeObjectHandle value,
DCHECK_IMPLIES(key->IsPrivate(), !details_.IsEnumerable());
}
Descriptor::Descriptor(Handle<Name> key, MaybeObjectHandle value,
Descriptor::Descriptor(Handle<Name> key, const MaybeObjectHandle& value,
PropertyDetails details)
: key_(key), value_(value), details_(details) {
DCHECK(key->IsUniqueName());
......@@ -55,7 +55,7 @@ Descriptor Descriptor::DataField(Handle<Name> key, int field_index,
PropertyAttributes attributes,
PropertyConstness constness,
Representation representation,
MaybeObjectHandle wrapped_field_type) {
const MaybeObjectHandle& wrapped_field_type) {
DCHECK(wrapped_field_type->IsSmi() || wrapped_field_type->IsWeakHeapObject());
PropertyDetails details(kData, attributes, kField, constness, representation,
field_index);
......
......@@ -40,7 +40,7 @@ class Descriptor final BASE_EMBEDDED {
PropertyAttributes attributes,
PropertyConstness constness,
Representation representation,
MaybeObjectHandle wrapped_field_type);
const MaybeObjectHandle& wrapped_field_type);
static Descriptor DataConstant(Handle<Name> key, Handle<Object> value,
PropertyAttributes attributes);
......@@ -58,13 +58,13 @@ class Descriptor final BASE_EMBEDDED {
PropertyDetails details_;
protected:
Descriptor(Handle<Name> key, MaybeObjectHandle value,
Descriptor(Handle<Name> key, const MaybeObjectHandle& value,
PropertyDetails details);
Descriptor(Handle<Name> key, MaybeObjectHandle value, PropertyKind kind,
PropertyAttributes attributes, PropertyLocation location,
PropertyConstness constness, Representation representation,
int field_index);
Descriptor(Handle<Name> key, const MaybeObjectHandle& value,
PropertyKind kind, PropertyAttributes attributes,
PropertyLocation location, PropertyConstness constness,
Representation representation, int field_index);
friend class MapUpdater;
};
......
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