Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: src/objects.cc

Issue 1218813012: Cleanup Delete backend implementation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« src/lookup.cc ('K') | « src/objects.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <iomanip> 5 #include <iomanip>
6 #include <sstream> 6 #include <sstream>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 5101 matching lines...) Expand 10 before | Expand all | Expand 10 after
5112 5112
5113 DCHECK(result->IsBoolean()); 5113 DCHECK(result->IsBoolean());
5114 Handle<Object> result_internal = v8::Utils::OpenHandle(*result); 5114 Handle<Object> result_internal = v8::Utils::OpenHandle(*result);
5115 result_internal->VerifyApiCallResultType(); 5115 result_internal->VerifyApiCallResultType();
5116 // Rebox CustomArguments::kReturnValueOffset before returning. 5116 // Rebox CustomArguments::kReturnValueOffset before returning.
5117 return handle(*result_internal, isolate); 5117 return handle(*result_internal, isolate);
5118 } 5118 }
5119 5119
5120 5120
5121 void JSObject::DeleteNormalizedProperty(Handle<JSObject> object, 5121 void JSObject::DeleteNormalizedProperty(Handle<JSObject> object,
5122 Handle<Name> name) { 5122 Handle<Name> name, int entry) {
5123 DCHECK(!object->HasFastProperties()); 5123 DCHECK(!object->HasFastProperties());
5124 Isolate* isolate = object->GetIsolate(); 5124 Isolate* isolate = object->GetIsolate();
5125 5125
5126 if (object->IsGlobalObject()) { 5126 if (object->IsGlobalObject()) {
5127 // If we have a global object, invalidate the cell and swap in a new one. 5127 // If we have a global object, invalidate the cell and swap in a new one.
5128 Handle<GlobalDictionary> dictionary(object->global_dictionary()); 5128 Handle<GlobalDictionary> dictionary(object->global_dictionary());
5129 int entry = dictionary->FindEntry(name);
5130 DCHECK_NE(GlobalDictionary::kNotFound, entry); 5129 DCHECK_NE(GlobalDictionary::kNotFound, entry);
5131 5130
5132 auto cell = PropertyCell::InvalidateEntry(dictionary, entry); 5131 auto cell = PropertyCell::InvalidateEntry(dictionary, entry);
5133 cell->set_value(isolate->heap()->the_hole_value()); 5132 cell->set_value(isolate->heap()->the_hole_value());
5134 // TODO(ishell): InvalidateForDelete 5133 // TODO(ishell): InvalidateForDelete
5135 cell->set_property_details( 5134 cell->set_property_details(
5136 cell->property_details().set_cell_type(PropertyCellType::kInvalidated)); 5135 cell->property_details().set_cell_type(PropertyCellType::kInvalidated));
5137 } else { 5136 } else {
5138 Handle<NameDictionary> dictionary(object->property_dictionary()); 5137 Handle<NameDictionary> dictionary(object->property_dictionary());
5139 int entry = dictionary->FindEntry(name);
5140 DCHECK_NE(NameDictionary::kNotFound, entry); 5138 DCHECK_NE(NameDictionary::kNotFound, entry);
5141 5139
5142 NameDictionary::DeleteProperty(dictionary, entry); 5140 NameDictionary::DeleteProperty(dictionary, entry);
5143 Handle<NameDictionary> new_properties = 5141 Handle<NameDictionary> new_properties =
5144 NameDictionary::Shrink(dictionary, name); 5142 NameDictionary::Shrink(dictionary, name);
5145 object->set_properties(*new_properties); 5143 object->set_properties(*new_properties);
5146 } 5144 }
5147 } 5145 }
5148 5146
5149 5147
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
5188 return it->factory()->true_value(); 5186 return it->factory()->true_value();
5189 case LookupIterator::DATA: 5187 case LookupIterator::DATA:
5190 if (is_observed) { 5188 if (is_observed) {
5191 old_value = it->GetDataValue(); 5189 old_value = it->GetDataValue();
5192 } 5190 }
5193 // Fall through. 5191 // Fall through.
5194 case LookupIterator::ACCESSOR: { 5192 case LookupIterator::ACCESSOR: {
5195 if (!it->IsConfigurable() || receiver->map()->is_strong()) { 5193 if (!it->IsConfigurable() || receiver->map()->is_strong()) {
5196 // Fail if the property is not configurable, or on a strong object. 5194 // Fail if the property is not configurable, or on a strong object.
5197 if (is_strict(language_mode)) { 5195 if (is_strict(language_mode)) {
5198 if (receiver->map()->is_strong()) { 5196 MessageTemplate::Template templ =
5199 THROW_NEW_ERROR( 5197 receiver->map()->is_strong()
5200 isolate, NewTypeError(MessageTemplate::kStrongDeleteProperty, 5198 ? MessageTemplate::kStrongDeleteProperty
5201 receiver, it->GetName()), 5199 : MessageTemplate::kStrictDeleteProperty;
5202 Object); 5200 THROW_NEW_ERROR(
5203 } 5201 isolate, NewTypeError(templ, it->GetName(), receiver), Object);
5204 THROW_NEW_ERROR(isolate,
5205 NewTypeError(MessageTemplate::kStrictDeleteProperty,
5206 it->GetName(), receiver),
5207 Object);
5208 } 5202 }
5209 return it->factory()->false_value(); 5203 return it->factory()->false_value();
5210 } 5204 }
5211 5205
5212 Handle<JSObject> holder = it->GetHolder<JSObject>(); 5206 Handle<JSObject> holder = it->GetHolder<JSObject>();
5213 // TODO(verwaest): Remove this temporary compatibility hack when blink 5207 // TODO(verwaest): Remove this temporary compatibility hack when blink
5214 // tests are updated. 5208 // tests are updated.
5215 if (!holder.is_identical_to(receiver) && 5209 if (!holder.is_identical_to(receiver) &&
5216 !(receiver->IsJSGlobalProxy() && holder->IsJSGlobalObject())) { 5210 !(receiver->IsJSGlobalProxy() && holder->IsJSGlobalObject())) {
5217 return it->factory()->true_value(); 5211 return it->factory()->true_value();
5218 } 5212 }
5219 5213
5220 if (it->IsElement()) { 5214 it->Delete();
5221 ElementsAccessor* accessor = holder->GetElementsAccessor();
5222 accessor->Delete(holder, it->index(), language_mode);
5223 } else {
5224 PropertyNormalizationMode mode = holder->map()->is_prototype_map()
5225 ? KEEP_INOBJECT_PROPERTIES
5226 : CLEAR_INOBJECT_PROPERTIES;
5227
5228 JSObject::NormalizeProperties(holder, mode, 0, "DeletingProperty");
5229 JSObject::DeleteNormalizedProperty(holder, it->name());
5230 JSObject::ReoptimizeIfPrototype(holder);
5231 }
5232 5215
5233 if (is_observed) { 5216 if (is_observed) {
5234 RETURN_ON_EXCEPTION(isolate, 5217 RETURN_ON_EXCEPTION(isolate,
5235 JSObject::EnqueueChangeRecord( 5218 JSObject::EnqueueChangeRecord(
5236 receiver, "delete", it->GetName(), old_value), 5219 receiver, "delete", it->GetName(), old_value),
5237 Object); 5220 Object);
5238 } 5221 }
5239 5222
5240 return it->factory()->true_value(); 5223 return it->factory()->true_value();
5241 } 5224 }
(...skipping 10871 matching lines...) Expand 10 before | Expand all | Expand 10 after
16113 Handle<Object> new_value) { 16096 Handle<Object> new_value) {
16114 if (cell->value() != *new_value) { 16097 if (cell->value() != *new_value) {
16115 cell->set_value(*new_value); 16098 cell->set_value(*new_value);
16116 Isolate* isolate = cell->GetIsolate(); 16099 Isolate* isolate = cell->GetIsolate();
16117 cell->dependent_code()->DeoptimizeDependentCodeGroup( 16100 cell->dependent_code()->DeoptimizeDependentCodeGroup(
16118 isolate, DependentCode::kPropertyCellChangedGroup); 16101 isolate, DependentCode::kPropertyCellChangedGroup);
16119 } 16102 }
16120 } 16103 }
16121 } // namespace internal 16104 } // namespace internal
16122 } // namespace v8 16105 } // namespace v8
OLDNEW
« src/lookup.cc ('K') | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698