| Index: src/objects.cc
|
| diff --git a/src/objects.cc b/src/objects.cc
|
| index a72585d696948c827a1659fb0d0c201003b9ac11..27af39f8219915c3e61e02ce6f9dd13d6315f6f9 100644
|
| --- a/src/objects.cc
|
| +++ b/src/objects.cc
|
| @@ -3624,6 +3624,7 @@ MaybeObject* JSObject::NormalizeProperties(PropertyNormalizationMode mode,
|
| }
|
|
|
| set_map(new_map);
|
| + map_of_this->NotifyObjectLayoutChange();
|
|
|
| set_properties(dictionary);
|
|
|
| @@ -5292,6 +5293,7 @@ MaybeObject* Map::CopyDropDescriptors() {
|
| result->set_pre_allocated_property_fields(pre_allocated_property_fields());
|
| result->set_is_shared(false);
|
| result->ClearCodeCache(GetHeap());
|
| + NotifyObjectLayoutChange();
|
| return result;
|
| }
|
|
|
| @@ -9501,14 +9503,27 @@ void Map::ZapPrototypeTransitions() {
|
| }
|
|
|
|
|
| -Handle<DependentCodes> DependentCodes::Insert(Handle<DependentCodes> codes,
|
| +DependentCode::GroupStartIndexes::GroupStartIndexes(DependentCode* codes) {
|
| + Recompute(codes);
|
| +}
|
| +
|
| +
|
| +void DependentCode::GroupStartIndexes::Recompute(DependentCode* codes) {
|
| + start_indexes_[0] = 0;
|
| + for (int g = 1; g <= kGroupCount; g++) {
|
| + int count = codes->number_of_codes(static_cast<DependencyGroup>(g - 1));
|
| + start_indexes_[g] = start_indexes_[g - 1] + count;
|
| + }
|
| +}
|
| +
|
| +
|
| +Handle<DependentCode> DependentCode::Insert(Handle<DependentCode> codes,
|
| DependencyGroup group,
|
| Handle<Code> value) {
|
| - GroupStartIndexes starts;
|
| - codes->ComputeGroupStartIndexes(starts);
|
| - int start = starts[group];
|
| - int end = starts[group + 1];
|
| - int number_of_codes = starts[kGroupCount];
|
| + GroupStartIndexes starts(*codes);
|
| + int start = starts.at(group);
|
| + int end = starts.at(group + 1);
|
| + int number_of_codes = starts.at(kGroupCount);
|
| if (start < end && codes->code_at(end - 1) == *value) {
|
| // Do not append the code if it is already in the array.
|
| // It is sufficient to just check only the last element because
|
| @@ -9519,13 +9534,13 @@ Handle<DependentCodes> DependentCodes::Insert(Handle<DependentCodes> codes,
|
| Factory* factory = codes->GetIsolate()->factory();
|
| int capacity = kCodesStartIndex + number_of_codes + 1;
|
| if (capacity > 5) capacity = capacity * 5 / 4;
|
| - Handle<DependentCodes> new_codes = Handle<DependentCodes>::cast(
|
| + Handle<DependentCode> new_codes = Handle<DependentCode>::cast(
|
| factory->CopySizeFixedArray(codes, capacity));
|
| // The number of codes can change after GC.
|
| - codes->ComputeGroupStartIndexes(starts);
|
| - start = starts[group];
|
| - end = starts[group + 1];
|
| - number_of_codes = starts[kGroupCount];
|
| + starts.Recompute(*codes);
|
| + start = starts.at(group);
|
| + end = starts.at(group + 1);
|
| + number_of_codes = starts.at(kGroupCount);
|
| for (int i = 0; i < number_of_codes; i++) {
|
| codes->clear_code_at(i);
|
| }
|
| @@ -9545,10 +9560,9 @@ Handle<DependentCodes> DependentCodes::Insert(Handle<DependentCodes> codes,
|
| }
|
|
|
|
|
| -bool DependentCodes::Contains(DependencyGroup group, Code* code) {
|
| - GroupStartIndexes starts;
|
| - ComputeGroupStartIndexes(starts);
|
| - int number_of_codes = starts[kGroupCount];
|
| +bool DependentCode::Contains(DependencyGroup group, Code* code) {
|
| + GroupStartIndexes starts(this);
|
| + int number_of_codes = starts.at(kGroupCount);
|
| for (int i = 0; i < number_of_codes; i++) {
|
| if (code_at(i) == code) return true;
|
| }
|
| @@ -9556,6 +9570,35 @@ bool DependentCodes::Contains(DependencyGroup group, Code* code) {
|
| }
|
|
|
|
|
| +class DeoptimizeDependentCodeFilter : public OptimizedFunctionFilter {
|
| + public:
|
| + virtual bool TakeFunction(JSFunction* function) {
|
| + return function->code()->marked_for_deoptimization();
|
| + }
|
| +};
|
| +
|
| +
|
| +void Map::DeoptimizeDependentCode(DependentCode::DependencyGroup group) {
|
| + AssertNoAllocation no_allocation_scope;
|
| + DependentCode* codes = dependent_code();
|
| + DependentCode::GroupStartIndexes starts(codes);
|
| + int start = starts.at(group);
|
| + int end = starts.at(group + 1);
|
| + int number_of_codes = starts.at(DependentCode::kGroupCount);
|
| + if (start == end) return;
|
| + for (int i = start; i < end; i++) {
|
| + Code* code = codes->code_at(i);
|
| + code->set_marked_for_deoptimization(true);
|
| + }
|
| + for (int src = end, dst = start; src < number_of_codes; src++, dst++) {
|
| + codes->set_code_at(dst, codes->code_at(src));
|
| + }
|
| + codes->set_number_of_codes(group, 0);
|
| + DeoptimizeDependentCodeFilter filter;
|
| + Deoptimizer::DeoptimizeAllFunctionsWith(&filter);
|
| +}
|
| +
|
| +
|
| MaybeObject* JSReceiver::SetPrototype(Object* value,
|
| bool skip_hidden_prototypes) {
|
| #ifdef DEBUG
|
|
|