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

Side by Side Diff: src/objects.cc

Issue 230733003: ElementsAccessor::Delete() maybehandlified. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebasing on r20629 Created 6 years, 8 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 | Annotate | Revision Log
« 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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 5171 matching lines...) Expand 10 before | Expand all | Expand 10 after
5182 return handle(*result_internal, isolate); 5182 return handle(*result_internal, isolate);
5183 } 5183 }
5184 } 5184 }
5185 Handle<Object> result = 5185 Handle<Object> result =
5186 DeletePropertyPostInterceptor(object, name, NORMAL_DELETION); 5186 DeletePropertyPostInterceptor(object, name, NORMAL_DELETION);
5187 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); 5187 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object);
5188 return result; 5188 return result;
5189 } 5189 }
5190 5190
5191 5191
5192 Handle<Object> JSObject::DeleteElementWithInterceptor(Handle<JSObject> object, 5192 MaybeHandle<Object> JSObject::DeleteElementWithInterceptor(
5193 uint32_t index) { 5193 Handle<JSObject> object,
5194 uint32_t index) {
5194 Isolate* isolate = object->GetIsolate(); 5195 Isolate* isolate = object->GetIsolate();
5195 Factory* factory = isolate->factory(); 5196 Factory* factory = isolate->factory();
5196 5197
5197 // Make sure that the top context does not change when doing 5198 // Make sure that the top context does not change when doing
5198 // callbacks or interceptor calls. 5199 // callbacks or interceptor calls.
5199 AssertNoContextChange ncc(isolate); 5200 AssertNoContextChange ncc(isolate);
5200 5201
5201 Handle<InterceptorInfo> interceptor(object->GetIndexedInterceptor()); 5202 Handle<InterceptorInfo> interceptor(object->GetIndexedInterceptor());
5202 if (interceptor->deleter()->IsUndefined()) return factory->false_value(); 5203 if (interceptor->deleter()->IsUndefined()) return factory->false_value();
5203 v8::IndexedPropertyDeleterCallback deleter = 5204 v8::IndexedPropertyDeleterCallback deleter =
5204 v8::ToCData<v8::IndexedPropertyDeleterCallback>(interceptor->deleter()); 5205 v8::ToCData<v8::IndexedPropertyDeleterCallback>(interceptor->deleter());
5205 LOG(isolate, 5206 LOG(isolate,
5206 ApiIndexedPropertyAccess("interceptor-indexed-delete", *object, index)); 5207 ApiIndexedPropertyAccess("interceptor-indexed-delete", *object, index));
5207 PropertyCallbackArguments args( 5208 PropertyCallbackArguments args(
5208 isolate, interceptor->data(), *object, *object); 5209 isolate, interceptor->data(), *object, *object);
5209 v8::Handle<v8::Boolean> result = args.Call(deleter, index); 5210 v8::Handle<v8::Boolean> result = args.Call(deleter, index);
5210 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); 5211 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object);
5211 if (!result.IsEmpty()) { 5212 if (!result.IsEmpty()) {
5212 ASSERT(result->IsBoolean()); 5213 ASSERT(result->IsBoolean());
5213 Handle<Object> result_internal = v8::Utils::OpenHandle(*result); 5214 Handle<Object> result_internal = v8::Utils::OpenHandle(*result);
5214 result_internal->VerifyApiCallResultType(); 5215 result_internal->VerifyApiCallResultType();
5215 // Rebox CustomArguments::kReturnValueOffset before returning. 5216 // Rebox CustomArguments::kReturnValueOffset before returning.
5216 return handle(*result_internal, isolate); 5217 return handle(*result_internal, isolate);
5217 } 5218 }
5218 Handle<Object> delete_result = object->GetElementsAccessor()->Delete( 5219 MaybeHandle<Object> delete_result = object->GetElementsAccessor()->Delete(
5219 object, index, NORMAL_DELETION); 5220 object, index, NORMAL_DELETION);
5220 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object);
5221 return delete_result; 5221 return delete_result;
5222 } 5222 }
5223 5223
5224 5224
5225 Handle<Object> JSObject::DeleteElement(Handle<JSObject> object, 5225 MaybeHandle<Object> JSObject::DeleteElement(Handle<JSObject> object,
5226 uint32_t index, 5226 uint32_t index,
5227 DeleteMode mode) { 5227 DeleteMode mode) {
5228 Isolate* isolate = object->GetIsolate(); 5228 Isolate* isolate = object->GetIsolate();
5229 Factory* factory = isolate->factory(); 5229 Factory* factory = isolate->factory();
5230 5230
5231 // Check access rights if needed. 5231 // Check access rights if needed.
5232 if (object->IsAccessCheckNeeded() && 5232 if (object->IsAccessCheckNeeded() &&
5233 !isolate->MayIndexedAccessWrapper(object, index, v8::ACCESS_DELETE)) { 5233 !isolate->MayIndexedAccessWrapper(object, index, v8::ACCESS_DELETE)) {
5234 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_DELETE); 5234 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_DELETE);
5235 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); 5235 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object);
5236 return factory->false_value(); 5236 return factory->false_value();
5237 } 5237 }
(...skipping 26 matching lines...) Expand all
5264 if (should_enqueue_change_record) { 5264 if (should_enqueue_change_record) {
5265 if (!GetLocalElementAccessorPair(object, index).is_null()) { 5265 if (!GetLocalElementAccessorPair(object, index).is_null()) {
5266 old_value = Handle<Object>::cast(factory->the_hole_value()); 5266 old_value = Handle<Object>::cast(factory->the_hole_value());
5267 } else { 5267 } else {
5268 old_value = Object::GetElementNoExceptionThrown(isolate, object, index); 5268 old_value = Object::GetElementNoExceptionThrown(isolate, object, index);
5269 } 5269 }
5270 } 5270 }
5271 } 5271 }
5272 5272
5273 // Skip interceptor if forcing deletion. 5273 // Skip interceptor if forcing deletion.
5274 MaybeHandle<Object> maybe_result;
5275 if (object->HasIndexedInterceptor() && mode != FORCE_DELETION) {
5276 maybe_result = DeleteElementWithInterceptor(object, index);
5277 } else {
5278 maybe_result = object->GetElementsAccessor()->Delete(object, index, mode);
5279 }
5274 Handle<Object> result; 5280 Handle<Object> result;
5275 if (object->HasIndexedInterceptor() && mode != FORCE_DELETION) { 5281 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, maybe_result, Object);
5276 result = DeleteElementWithInterceptor(object, index);
5277 } else {
5278 result = object->GetElementsAccessor()->Delete(object, index, mode);
5279 }
5280 5282
5281 if (should_enqueue_change_record && !HasLocalElement(object, index)) { 5283 if (should_enqueue_change_record && !HasLocalElement(object, index)) {
5282 Handle<String> name = factory->Uint32ToString(index); 5284 Handle<String> name = factory->Uint32ToString(index);
5283 EnqueueChangeRecord(object, "delete", name, old_value); 5285 EnqueueChangeRecord(object, "delete", name, old_value);
5284 } 5286 }
5285 5287
5286 return result; 5288 return result;
5287 } 5289 }
5288 5290
5289 5291
5290 Handle<Object> JSObject::DeleteProperty(Handle<JSObject> object, 5292 MaybeHandle<Object> JSObject::DeleteProperty(Handle<JSObject> object,
5291 Handle<Name> name, 5293 Handle<Name> name,
5292 DeleteMode mode) { 5294 DeleteMode mode) {
5293 Isolate* isolate = object->GetIsolate(); 5295 Isolate* isolate = object->GetIsolate();
5294 // ECMA-262, 3rd, 8.6.2.5 5296 // ECMA-262, 3rd, 8.6.2.5
5295 ASSERT(name->IsName()); 5297 ASSERT(name->IsName());
5296 5298
5297 // Check access rights if needed. 5299 // Check access rights if needed.
5298 if (object->IsAccessCheckNeeded() && 5300 if (object->IsAccessCheckNeeded() &&
5299 !isolate->MayNamedAccessWrapper(object, name, v8::ACCESS_DELETE)) { 5301 !isolate->MayNamedAccessWrapper(object, name, v8::ACCESS_DELETE)) {
5300 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_DELETE); 5302 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_DELETE);
5301 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); 5303 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object);
5302 return isolate->factory()->false_value(); 5304 return isolate->factory()->false_value();
(...skipping 8946 matching lines...) Expand 10 before | Expand all | Expand 10 after
14249 Object*); 14251 Object*);
14250 14252
14251 template void Dictionary<SeededNumberDictionaryShape, uint32_t>::CopyKeysTo( 14253 template void Dictionary<SeededNumberDictionaryShape, uint32_t>::CopyKeysTo(
14252 FixedArray*, 14254 FixedArray*,
14253 PropertyAttributes, 14255 PropertyAttributes,
14254 Dictionary<SeededNumberDictionaryShape, uint32_t>::SortMode); 14256 Dictionary<SeededNumberDictionaryShape, uint32_t>::SortMode);
14255 14257
14256 template Object* Dictionary<NameDictionaryShape, Name*>::DeleteProperty( 14258 template Object* Dictionary<NameDictionaryShape, Name*>::DeleteProperty(
14257 int, JSObject::DeleteMode); 14259 int, JSObject::DeleteMode);
14258 14260
14261 template Handle<Object> Dictionary<NameDictionaryShape, Name*>::DeleteProperty(
14262 Handle<Dictionary<NameDictionaryShape, Name*> >,
14263 int,
14264 JSObject::DeleteMode);
14265
14259 template Object* Dictionary<SeededNumberDictionaryShape, uint32_t>:: 14266 template Object* Dictionary<SeededNumberDictionaryShape, uint32_t>::
14260 DeleteProperty(int, JSObject::DeleteMode); 14267 DeleteProperty(int, JSObject::DeleteMode);
14261 14268
14269 template Handle<Object>
14270 Dictionary<SeededNumberDictionaryShape, uint32_t>::DeleteProperty(
14271 Handle<Dictionary<SeededNumberDictionaryShape, uint32_t> >,
14272 int,
14273 JSObject::DeleteMode);
14274
14262 template MaybeObject* Dictionary<NameDictionaryShape, Name*>::Shrink(Name* n); 14275 template MaybeObject* Dictionary<NameDictionaryShape, Name*>::Shrink(Name* n);
14263 14276
14264 template MaybeObject* Dictionary<SeededNumberDictionaryShape, uint32_t>::Shrink( 14277 template MaybeObject* Dictionary<SeededNumberDictionaryShape, uint32_t>::Shrink(
14265 uint32_t); 14278 uint32_t);
14279 template Handle<FixedArray>
14280 Dictionary<SeededNumberDictionaryShape, uint32_t>::Shrink(
14281 Handle<Dictionary<SeededNumberDictionaryShape, uint32_t> >,
14282 uint32_t);
14266 14283
14267 template void Dictionary<NameDictionaryShape, Name*>::CopyKeysTo( 14284 template void Dictionary<NameDictionaryShape, Name*>::CopyKeysTo(
14268 FixedArray*, 14285 FixedArray*,
14269 int, 14286 int,
14270 PropertyAttributes, 14287 PropertyAttributes,
14271 Dictionary<NameDictionaryShape, Name*>::SortMode); 14288 Dictionary<NameDictionaryShape, Name*>::SortMode);
14272 14289
14273 template int 14290 template int
14274 Dictionary<NameDictionaryShape, Name*>::NumberOfElementsFilterAttributes( 14291 Dictionary<NameDictionaryShape, Name*>::NumberOfElementsFilterAttributes(
14275 PropertyAttributes); 14292 PropertyAttributes);
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
15254 // If not, we generate new indices for the properties. 15271 // If not, we generate new indices for the properties.
15255 Object* result; 15272 Object* result;
15256 { MaybeObject* maybe_result = GenerateNewEnumerationIndices(); 15273 { MaybeObject* maybe_result = GenerateNewEnumerationIndices();
15257 if (!maybe_result->ToObject(&result)) return maybe_result; 15274 if (!maybe_result->ToObject(&result)) return maybe_result;
15258 } 15275 }
15259 } 15276 }
15260 return HashTable<Shape, Key>::EnsureCapacity(n, key); 15277 return HashTable<Shape, Key>::EnsureCapacity(n, key);
15261 } 15278 }
15262 15279
15263 15280
15281 // TODO(ishell): Temporary wrapper until handlified.
15282 template<typename Shape, typename Key>
15283 Handle<Object> Dictionary<Shape, Key>::DeleteProperty(
15284 Handle<Dictionary<Shape, Key> > dictionary,
15285 int entry,
15286 JSObject::DeleteMode mode) {
15287 CALL_HEAP_FUNCTION(dictionary->GetIsolate(),
15288 dictionary->DeleteProperty(entry, mode),
15289 Object);
15290 }
15291
15292
15264 template<typename Shape, typename Key> 15293 template<typename Shape, typename Key>
15265 Object* Dictionary<Shape, Key>::DeleteProperty(int entry, 15294 Object* Dictionary<Shape, Key>::DeleteProperty(int entry,
15266 JSReceiver::DeleteMode mode) { 15295 JSReceiver::DeleteMode mode) {
15267 Heap* heap = Dictionary<Shape, Key>::GetHeap(); 15296 Heap* heap = Dictionary<Shape, Key>::GetHeap();
15268 PropertyDetails details = DetailsAt(entry); 15297 PropertyDetails details = DetailsAt(entry);
15269 // Ignore attributes if forcing a deletion. 15298 // Ignore attributes if forcing a deletion.
15270 if (details.IsDontDelete() && mode != JSReceiver::FORCE_DELETION) { 15299 if (details.IsDontDelete() && mode != JSReceiver::FORCE_DELETION) {
15271 return heap->false_value(); 15300 return heap->false_value();
15272 } 15301 }
15273 SetEntry(entry, heap->the_hole_value(), heap->the_hole_value()); 15302 SetEntry(entry, heap->the_hole_value(), heap->the_hole_value());
15274 HashTable<Shape, Key>::ElementRemoved(); 15303 HashTable<Shape, Key>::ElementRemoved();
15275 return heap->true_value(); 15304 return heap->true_value();
15276 } 15305 }
15277 15306
15278 15307
15308 // TODO(ishell): Temporary wrapper until handlified.
15309 template<typename Shape, typename Key>
15310 Handle<FixedArray> Dictionary<Shape, Key>::Shrink(
15311 Handle<Dictionary<Shape, Key> > dictionary,
15312 Key key) {
15313 CALL_HEAP_FUNCTION(dictionary->GetIsolate(),
15314 dictionary->Shrink(key),
15315 FixedArray);
15316 }
15317
15318
15279 template<typename Shape, typename Key> 15319 template<typename Shape, typename Key>
15280 MaybeObject* Dictionary<Shape, Key>::Shrink(Key key) { 15320 MaybeObject* Dictionary<Shape, Key>::Shrink(Key key) {
15281 return HashTable<Shape, Key>::Shrink(key); 15321 return HashTable<Shape, Key>::Shrink(key);
15282 } 15322 }
15283 15323
15284 15324
15285 template<typename Shape, typename Key> 15325 template<typename Shape, typename Key>
15286 MaybeObject* Dictionary<Shape, Key>::AtPut(Key key, Object* value) { 15326 MaybeObject* Dictionary<Shape, Key>::AtPut(Key key, Object* value) {
15287 int entry = this->FindEntry(key); 15327 int entry = this->FindEntry(key);
15288 15328
(...skipping 1342 matching lines...) Expand 10 before | Expand all | Expand 10 after
16631 #define ERROR_MESSAGES_TEXTS(C, T) T, 16671 #define ERROR_MESSAGES_TEXTS(C, T) T,
16632 static const char* error_messages_[] = { 16672 static const char* error_messages_[] = {
16633 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16673 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16634 }; 16674 };
16635 #undef ERROR_MESSAGES_TEXTS 16675 #undef ERROR_MESSAGES_TEXTS
16636 return error_messages_[reason]; 16676 return error_messages_[reason];
16637 } 16677 }
16638 16678
16639 16679
16640 } } // namespace v8::internal 16680 } } // namespace v8::internal
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