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

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: 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
« no previous file with comments | « 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 5127 matching lines...) Expand 10 before | Expand all | Expand 10 after
5138 5138
5139 DCHECK(result->IsBoolean()); 5139 DCHECK(result->IsBoolean());
5140 Handle<Object> result_internal = v8::Utils::OpenHandle(*result); 5140 Handle<Object> result_internal = v8::Utils::OpenHandle(*result);
5141 result_internal->VerifyApiCallResultType(); 5141 result_internal->VerifyApiCallResultType();
5142 // Rebox CustomArguments::kReturnValueOffset before returning. 5142 // Rebox CustomArguments::kReturnValueOffset before returning.
5143 return handle(*result_internal, isolate); 5143 return handle(*result_internal, isolate);
5144 } 5144 }
5145 5145
5146 5146
5147 void JSObject::DeleteNormalizedProperty(Handle<JSObject> object, 5147 void JSObject::DeleteNormalizedProperty(Handle<JSObject> object,
5148 Handle<Name> name) { 5148 Handle<Name> name, int entry) {
5149 DCHECK(!object->HasFastProperties()); 5149 DCHECK(!object->HasFastProperties());
5150 Isolate* isolate = object->GetIsolate(); 5150 Isolate* isolate = object->GetIsolate();
5151 5151
5152 if (object->IsGlobalObject()) { 5152 if (object->IsGlobalObject()) {
5153 // If we have a global object, invalidate the cell and swap in a new one. 5153 // If we have a global object, invalidate the cell and swap in a new one.
5154 Handle<GlobalDictionary> dictionary(object->global_dictionary()); 5154 Handle<GlobalDictionary> dictionary(object->global_dictionary());
5155 int entry = dictionary->FindEntry(name);
5156 DCHECK_NE(GlobalDictionary::kNotFound, entry); 5155 DCHECK_NE(GlobalDictionary::kNotFound, entry);
5157 5156
5158 auto cell = PropertyCell::InvalidateEntry(dictionary, entry); 5157 auto cell = PropertyCell::InvalidateEntry(dictionary, entry);
5159 cell->set_value(isolate->heap()->the_hole_value()); 5158 cell->set_value(isolate->heap()->the_hole_value());
5160 // TODO(ishell): InvalidateForDelete 5159 // TODO(ishell): InvalidateForDelete
5161 cell->set_property_details( 5160 cell->set_property_details(
5162 cell->property_details().set_cell_type(PropertyCellType::kInvalidated)); 5161 cell->property_details().set_cell_type(PropertyCellType::kInvalidated));
5163 } else { 5162 } else {
5164 Handle<NameDictionary> dictionary(object->property_dictionary()); 5163 Handle<NameDictionary> dictionary(object->property_dictionary());
5165 int entry = dictionary->FindEntry(name);
5166 DCHECK_NE(NameDictionary::kNotFound, entry); 5164 DCHECK_NE(NameDictionary::kNotFound, entry);
5167 5165
5168 NameDictionary::DeleteProperty(dictionary, entry); 5166 NameDictionary::DeleteProperty(dictionary, entry);
5169 Handle<NameDictionary> new_properties = 5167 Handle<NameDictionary> new_properties =
5170 NameDictionary::Shrink(dictionary, name); 5168 NameDictionary::Shrink(dictionary, name);
5171 object->set_properties(*new_properties); 5169 object->set_properties(*new_properties);
5172 } 5170 }
5173 } 5171 }
5174 5172
5175 5173
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
5214 return it->factory()->true_value(); 5212 return it->factory()->true_value();
5215 case LookupIterator::DATA: 5213 case LookupIterator::DATA:
5216 if (is_observed) { 5214 if (is_observed) {
5217 old_value = it->GetDataValue(); 5215 old_value = it->GetDataValue();
5218 } 5216 }
5219 // Fall through. 5217 // Fall through.
5220 case LookupIterator::ACCESSOR: { 5218 case LookupIterator::ACCESSOR: {
5221 if (!it->IsConfigurable() || receiver->map()->is_strong()) { 5219 if (!it->IsConfigurable() || receiver->map()->is_strong()) {
5222 // Fail if the property is not configurable, or on a strong object. 5220 // Fail if the property is not configurable, or on a strong object.
5223 if (is_strict(language_mode)) { 5221 if (is_strict(language_mode)) {
5224 if (receiver->map()->is_strong()) { 5222 MessageTemplate::Template templ =
5225 THROW_NEW_ERROR( 5223 receiver->map()->is_strong()
5226 isolate, NewTypeError(MessageTemplate::kStrongDeleteProperty, 5224 ? MessageTemplate::kStrongDeleteProperty
5227 receiver, it->GetName()), 5225 : MessageTemplate::kStrictDeleteProperty;
5228 Object); 5226 THROW_NEW_ERROR(
5229 } 5227 isolate, NewTypeError(templ, it->GetName(), receiver), Object);
5230 THROW_NEW_ERROR(isolate,
5231 NewTypeError(MessageTemplate::kStrictDeleteProperty,
5232 it->GetName(), receiver),
5233 Object);
5234 } 5228 }
5235 return it->factory()->false_value(); 5229 return it->factory()->false_value();
5236 } 5230 }
5237 5231
5238 Handle<JSObject> holder = it->GetHolder<JSObject>(); 5232 Handle<JSObject> holder = it->GetHolder<JSObject>();
5239 // TODO(verwaest): Remove this temporary compatibility hack when blink 5233 // TODO(verwaest): Remove this temporary compatibility hack when blink
5240 // tests are updated. 5234 // tests are updated.
5241 if (!holder.is_identical_to(receiver) && 5235 if (!holder.is_identical_to(receiver) &&
5242 !(receiver->IsJSGlobalProxy() && holder->IsJSGlobalObject())) { 5236 !(receiver->IsJSGlobalProxy() && holder->IsJSGlobalObject())) {
5243 return it->factory()->true_value(); 5237 return it->factory()->true_value();
5244 } 5238 }
5245 5239
5246 if (it->IsElement()) { 5240 it->Delete();
5247 ElementsAccessor* accessor = holder->GetElementsAccessor();
5248 accessor->Delete(holder, it->index(), language_mode);
5249 } else {
5250 PropertyNormalizationMode mode = holder->map()->is_prototype_map()
5251 ? KEEP_INOBJECT_PROPERTIES
5252 : CLEAR_INOBJECT_PROPERTIES;
5253
5254 JSObject::NormalizeProperties(holder, mode, 0, "DeletingProperty");
5255 JSObject::DeleteNormalizedProperty(holder, it->name());
5256 JSObject::ReoptimizeIfPrototype(holder);
5257 }
5258 5241
5259 if (is_observed) { 5242 if (is_observed) {
5260 RETURN_ON_EXCEPTION(isolate, 5243 RETURN_ON_EXCEPTION(isolate,
5261 JSObject::EnqueueChangeRecord( 5244 JSObject::EnqueueChangeRecord(
5262 receiver, "delete", it->GetName(), old_value), 5245 receiver, "delete", it->GetName(), old_value),
5263 Object); 5246 Object);
5264 } 5247 }
5265 5248
5266 return it->factory()->true_value(); 5249 return it->factory()->true_value();
5267 } 5250 }
(...skipping 10880 matching lines...) Expand 10 before | Expand all | Expand 10 after
16148 Handle<Object> new_value) { 16131 Handle<Object> new_value) {
16149 if (cell->value() != *new_value) { 16132 if (cell->value() != *new_value) {
16150 cell->set_value(*new_value); 16133 cell->set_value(*new_value);
16151 Isolate* isolate = cell->GetIsolate(); 16134 Isolate* isolate = cell->GetIsolate();
16152 cell->dependent_code()->DeoptimizeDependentCodeGroup( 16135 cell->dependent_code()->DeoptimizeDependentCodeGroup(
16153 isolate, DependentCode::kPropertyCellChangedGroup); 16136 isolate, DependentCode::kPropertyCellChangedGroup);
16154 } 16137 }
16155 } 16138 }
16156 } // namespace internal 16139 } // namespace internal
16157 } // namespace v8 16140 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698