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