OLD | NEW |
---|---|
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 5162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5173 return handle(*result_internal, isolate); | 5173 return handle(*result_internal, isolate); |
5174 } | 5174 } |
5175 } | 5175 } |
5176 Handle<Object> result = | 5176 Handle<Object> result = |
5177 DeletePropertyPostInterceptor(object, name, NORMAL_DELETION); | 5177 DeletePropertyPostInterceptor(object, name, NORMAL_DELETION); |
5178 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 5178 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
5179 return result; | 5179 return result; |
5180 } | 5180 } |
5181 | 5181 |
5182 | 5182 |
5183 Handle<Object> JSObject::DeleteElementWithInterceptor(Handle<JSObject> object, | 5183 MaybeHandle<Object> JSObject::DeleteElementWithInterceptor( |
5184 uint32_t index) { | 5184 Handle<JSObject> object, |
5185 uint32_t index) { | |
5185 Isolate* isolate = object->GetIsolate(); | 5186 Isolate* isolate = object->GetIsolate(); |
5186 Factory* factory = isolate->factory(); | 5187 Factory* factory = isolate->factory(); |
5187 | 5188 |
5188 // Make sure that the top context does not change when doing | 5189 // Make sure that the top context does not change when doing |
5189 // callbacks or interceptor calls. | 5190 // callbacks or interceptor calls. |
5190 AssertNoContextChange ncc(isolate); | 5191 AssertNoContextChange ncc(isolate); |
5191 | 5192 |
5192 Handle<InterceptorInfo> interceptor(object->GetIndexedInterceptor()); | 5193 Handle<InterceptorInfo> interceptor(object->GetIndexedInterceptor()); |
5193 if (interceptor->deleter()->IsUndefined()) return factory->false_value(); | 5194 if (interceptor->deleter()->IsUndefined()) return factory->false_value(); |
5194 v8::IndexedPropertyDeleterCallback deleter = | 5195 v8::IndexedPropertyDeleterCallback deleter = |
5195 v8::ToCData<v8::IndexedPropertyDeleterCallback>(interceptor->deleter()); | 5196 v8::ToCData<v8::IndexedPropertyDeleterCallback>(interceptor->deleter()); |
5196 LOG(isolate, | 5197 LOG(isolate, |
5197 ApiIndexedPropertyAccess("interceptor-indexed-delete", *object, index)); | 5198 ApiIndexedPropertyAccess("interceptor-indexed-delete", *object, index)); |
5198 PropertyCallbackArguments args( | 5199 PropertyCallbackArguments args( |
5199 isolate, interceptor->data(), *object, *object); | 5200 isolate, interceptor->data(), *object, *object); |
5200 v8::Handle<v8::Boolean> result = args.Call(deleter, index); | 5201 v8::Handle<v8::Boolean> result = args.Call(deleter, index); |
5201 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 5202 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
5202 if (!result.IsEmpty()) { | 5203 if (!result.IsEmpty()) { |
5203 ASSERT(result->IsBoolean()); | 5204 ASSERT(result->IsBoolean()); |
5204 Handle<Object> result_internal = v8::Utils::OpenHandle(*result); | 5205 Handle<Object> result_internal = v8::Utils::OpenHandle(*result); |
5205 result_internal->VerifyApiCallResultType(); | 5206 result_internal->VerifyApiCallResultType(); |
5206 // Rebox CustomArguments::kReturnValueOffset before returning. | 5207 // Rebox CustomArguments::kReturnValueOffset before returning. |
5207 return handle(*result_internal, isolate); | 5208 return handle(*result_internal, isolate); |
5208 } | 5209 } |
5209 Handle<Object> delete_result = object->GetElementsAccessor()->Delete( | 5210 MaybeHandle<Object> delete_result = object->GetElementsAccessor()->Delete( |
5210 object, index, NORMAL_DELETION); | 5211 object, index, NORMAL_DELETION); |
5211 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 5212 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); |
Yang
2014/04/09 15:09:59
Where does the API callback happen? Could we move
Igor Sheludko
2014/04/09 15:44:54
I did not find any callbacks inside Delete() call
| |
5212 return delete_result; | 5213 return delete_result; |
5213 } | 5214 } |
5214 | 5215 |
5215 | 5216 |
5216 Handle<Object> JSObject::DeleteElement(Handle<JSObject> object, | 5217 MaybeHandle<Object> JSObject::DeleteElement(Handle<JSObject> object, |
5217 uint32_t index, | 5218 uint32_t index, |
5218 DeleteMode mode) { | 5219 DeleteMode mode) { |
5219 Isolate* isolate = object->GetIsolate(); | 5220 Isolate* isolate = object->GetIsolate(); |
5220 Factory* factory = isolate->factory(); | 5221 Factory* factory = isolate->factory(); |
5221 | 5222 |
5222 // Check access rights if needed. | 5223 // Check access rights if needed. |
5223 if (object->IsAccessCheckNeeded() && | 5224 if (object->IsAccessCheckNeeded() && |
5224 !isolate->MayIndexedAccessWrapper(object, index, v8::ACCESS_DELETE)) { | 5225 !isolate->MayIndexedAccessWrapper(object, index, v8::ACCESS_DELETE)) { |
5225 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_DELETE); | 5226 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_DELETE); |
5226 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 5227 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
5227 return factory->false_value(); | 5228 return factory->false_value(); |
5228 } | 5229 } |
(...skipping 26 matching lines...) Expand all Loading... | |
5255 if (should_enqueue_change_record) { | 5256 if (should_enqueue_change_record) { |
5256 if (!GetLocalElementAccessorPair(object, index).is_null()) { | 5257 if (!GetLocalElementAccessorPair(object, index).is_null()) { |
5257 old_value = Handle<Object>::cast(factory->the_hole_value()); | 5258 old_value = Handle<Object>::cast(factory->the_hole_value()); |
5258 } else { | 5259 } else { |
5259 old_value = Object::GetElementNoExceptionThrown(isolate, object, index); | 5260 old_value = Object::GetElementNoExceptionThrown(isolate, object, index); |
5260 } | 5261 } |
5261 } | 5262 } |
5262 } | 5263 } |
5263 | 5264 |
5264 // Skip interceptor if forcing deletion. | 5265 // Skip interceptor if forcing deletion. |
5266 MaybeHandle<Object> maybe_result; | |
5267 if (object->HasIndexedInterceptor() && mode != FORCE_DELETION) { | |
5268 maybe_result = DeleteElementWithInterceptor(object, index); | |
5269 } else { | |
5270 maybe_result = object->GetElementsAccessor()->Delete(object, index, mode); | |
Yang
2014/04/09 15:09:59
Seems like here we don't do the API callback excep
Igor Sheludko
2014/04/09 15:44:54
We don't need API callback exception check for Del
| |
5271 } | |
5265 Handle<Object> result; | 5272 Handle<Object> result; |
5266 if (object->HasIndexedInterceptor() && mode != FORCE_DELETION) { | 5273 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, maybe_result, Object); |
5267 result = DeleteElementWithInterceptor(object, index); | |
5268 } else { | |
5269 result = object->GetElementsAccessor()->Delete(object, index, mode); | |
5270 } | |
5271 | 5274 |
5272 if (should_enqueue_change_record && !HasLocalElement(object, index)) { | 5275 if (should_enqueue_change_record && !HasLocalElement(object, index)) { |
5273 Handle<String> name = factory->Uint32ToString(index); | 5276 Handle<String> name = factory->Uint32ToString(index); |
5274 EnqueueChangeRecord(object, "delete", name, old_value); | 5277 EnqueueChangeRecord(object, "delete", name, old_value); |
5275 } | 5278 } |
5276 | 5279 |
5277 return result; | 5280 return result; |
5278 } | 5281 } |
5279 | 5282 |
5280 | 5283 |
5281 Handle<Object> JSObject::DeleteProperty(Handle<JSObject> object, | 5284 MaybeHandle<Object> JSObject::DeleteProperty(Handle<JSObject> object, |
5282 Handle<Name> name, | 5285 Handle<Name> name, |
5283 DeleteMode mode) { | 5286 DeleteMode mode) { |
5284 Isolate* isolate = object->GetIsolate(); | 5287 Isolate* isolate = object->GetIsolate(); |
5285 // ECMA-262, 3rd, 8.6.2.5 | 5288 // ECMA-262, 3rd, 8.6.2.5 |
5286 ASSERT(name->IsName()); | 5289 ASSERT(name->IsName()); |
5287 | 5290 |
5288 // Check access rights if needed. | 5291 // Check access rights if needed. |
5289 if (object->IsAccessCheckNeeded() && | 5292 if (object->IsAccessCheckNeeded() && |
5290 !isolate->MayNamedAccessWrapper(object, name, v8::ACCESS_DELETE)) { | 5293 !isolate->MayNamedAccessWrapper(object, name, v8::ACCESS_DELETE)) { |
5291 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_DELETE); | 5294 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_DELETE); |
5292 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 5295 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
5293 return isolate->factory()->false_value(); | 5296 return isolate->factory()->false_value(); |
(...skipping 8982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14276 Object*); | 14279 Object*); |
14277 | 14280 |
14278 template void Dictionary<SeededNumberDictionaryShape, uint32_t>::CopyKeysTo( | 14281 template void Dictionary<SeededNumberDictionaryShape, uint32_t>::CopyKeysTo( |
14279 FixedArray*, | 14282 FixedArray*, |
14280 PropertyAttributes, | 14283 PropertyAttributes, |
14281 Dictionary<SeededNumberDictionaryShape, uint32_t>::SortMode); | 14284 Dictionary<SeededNumberDictionaryShape, uint32_t>::SortMode); |
14282 | 14285 |
14283 template Object* Dictionary<NameDictionaryShape, Name*>::DeleteProperty( | 14286 template Object* Dictionary<NameDictionaryShape, Name*>::DeleteProperty( |
14284 int, JSObject::DeleteMode); | 14287 int, JSObject::DeleteMode); |
14285 | 14288 |
14289 template Handle<Object> Dictionary<NameDictionaryShape, Name*>::DeleteProperty( | |
14290 Handle<Dictionary<NameDictionaryShape, Name*> >, | |
14291 int, | |
14292 JSObject::DeleteMode); | |
14293 | |
14286 template Object* Dictionary<SeededNumberDictionaryShape, uint32_t>:: | 14294 template Object* Dictionary<SeededNumberDictionaryShape, uint32_t>:: |
14287 DeleteProperty(int, JSObject::DeleteMode); | 14295 DeleteProperty(int, JSObject::DeleteMode); |
14288 | 14296 |
14297 template Handle<Object> | |
14298 Dictionary<SeededNumberDictionaryShape, uint32_t>::DeleteProperty( | |
14299 Handle<Dictionary<SeededNumberDictionaryShape, uint32_t> >, | |
14300 int, | |
14301 JSObject::DeleteMode); | |
14302 | |
14289 template MaybeObject* Dictionary<NameDictionaryShape, Name*>::Shrink(Name* n); | 14303 template MaybeObject* Dictionary<NameDictionaryShape, Name*>::Shrink(Name* n); |
14290 | 14304 |
14291 template MaybeObject* Dictionary<SeededNumberDictionaryShape, uint32_t>::Shrink( | 14305 template MaybeObject* Dictionary<SeededNumberDictionaryShape, uint32_t>::Shrink( |
14292 uint32_t); | 14306 uint32_t); |
14307 template Handle<FixedArray> | |
14308 Dictionary<SeededNumberDictionaryShape, uint32_t>::Shrink( | |
14309 Handle<Dictionary<SeededNumberDictionaryShape, uint32_t> >, | |
14310 uint32_t); | |
14293 | 14311 |
14294 template void Dictionary<NameDictionaryShape, Name*>::CopyKeysTo( | 14312 template void Dictionary<NameDictionaryShape, Name*>::CopyKeysTo( |
14295 FixedArray*, | 14313 FixedArray*, |
14296 int, | 14314 int, |
14297 PropertyAttributes, | 14315 PropertyAttributes, |
14298 Dictionary<NameDictionaryShape, Name*>::SortMode); | 14316 Dictionary<NameDictionaryShape, Name*>::SortMode); |
14299 | 14317 |
14300 template int | 14318 template int |
14301 Dictionary<NameDictionaryShape, Name*>::NumberOfElementsFilterAttributes( | 14319 Dictionary<NameDictionaryShape, Name*>::NumberOfElementsFilterAttributes( |
14302 PropertyAttributes); | 14320 PropertyAttributes); |
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15281 // If not, we generate new indices for the properties. | 15299 // If not, we generate new indices for the properties. |
15282 Object* result; | 15300 Object* result; |
15283 { MaybeObject* maybe_result = GenerateNewEnumerationIndices(); | 15301 { MaybeObject* maybe_result = GenerateNewEnumerationIndices(); |
15284 if (!maybe_result->ToObject(&result)) return maybe_result; | 15302 if (!maybe_result->ToObject(&result)) return maybe_result; |
15285 } | 15303 } |
15286 } | 15304 } |
15287 return HashTable<Shape, Key>::EnsureCapacity(n, key); | 15305 return HashTable<Shape, Key>::EnsureCapacity(n, key); |
15288 } | 15306 } |
15289 | 15307 |
15290 | 15308 |
15309 // TODO(ishell): Temporary wrapper until handlified. | |
15310 template<typename Shape, typename Key> | |
15311 Handle<Object> Dictionary<Shape, Key>::DeleteProperty( | |
15312 Handle<Dictionary<Shape, Key> > dictionary, | |
15313 int entry, | |
15314 JSObject::DeleteMode mode) { | |
15315 CALL_HEAP_FUNCTION(dictionary->GetIsolate(), | |
15316 dictionary->DeleteProperty(entry, mode), | |
15317 Object); | |
15318 } | |
15319 | |
15320 | |
15291 template<typename Shape, typename Key> | 15321 template<typename Shape, typename Key> |
15292 Object* Dictionary<Shape, Key>::DeleteProperty(int entry, | 15322 Object* Dictionary<Shape, Key>::DeleteProperty(int entry, |
15293 JSReceiver::DeleteMode mode) { | 15323 JSReceiver::DeleteMode mode) { |
15294 Heap* heap = Dictionary<Shape, Key>::GetHeap(); | 15324 Heap* heap = Dictionary<Shape, Key>::GetHeap(); |
15295 PropertyDetails details = DetailsAt(entry); | 15325 PropertyDetails details = DetailsAt(entry); |
15296 // Ignore attributes if forcing a deletion. | 15326 // Ignore attributes if forcing a deletion. |
15297 if (details.IsDontDelete() && mode != JSReceiver::FORCE_DELETION) { | 15327 if (details.IsDontDelete() && mode != JSReceiver::FORCE_DELETION) { |
15298 return heap->false_value(); | 15328 return heap->false_value(); |
15299 } | 15329 } |
15300 SetEntry(entry, heap->the_hole_value(), heap->the_hole_value()); | 15330 SetEntry(entry, heap->the_hole_value(), heap->the_hole_value()); |
15301 HashTable<Shape, Key>::ElementRemoved(); | 15331 HashTable<Shape, Key>::ElementRemoved(); |
15302 return heap->true_value(); | 15332 return heap->true_value(); |
15303 } | 15333 } |
15304 | 15334 |
15305 | 15335 |
15336 // TODO(ishell): Temporary wrapper until handlified. | |
15337 template<typename Shape, typename Key> | |
15338 Handle<FixedArray> Dictionary<Shape, Key>::Shrink( | |
15339 Handle<Dictionary<Shape, Key> > dictionary, | |
15340 Key key) { | |
15341 CALL_HEAP_FUNCTION(dictionary->GetIsolate(), | |
15342 dictionary->Shrink(key), | |
15343 FixedArray); | |
15344 } | |
15345 | |
15346 | |
15306 template<typename Shape, typename Key> | 15347 template<typename Shape, typename Key> |
15307 MaybeObject* Dictionary<Shape, Key>::Shrink(Key key) { | 15348 MaybeObject* Dictionary<Shape, Key>::Shrink(Key key) { |
15308 return HashTable<Shape, Key>::Shrink(key); | 15349 return HashTable<Shape, Key>::Shrink(key); |
15309 } | 15350 } |
15310 | 15351 |
15311 | 15352 |
15312 template<typename Shape, typename Key> | 15353 template<typename Shape, typename Key> |
15313 MaybeObject* Dictionary<Shape, Key>::AtPut(Key key, Object* value) { | 15354 MaybeObject* Dictionary<Shape, Key>::AtPut(Key key, Object* value) { |
15314 int entry = this->FindEntry(key); | 15355 int entry = this->FindEntry(key); |
15315 | 15356 |
(...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16656 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16697 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16657 static const char* error_messages_[] = { | 16698 static const char* error_messages_[] = { |
16658 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16699 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16659 }; | 16700 }; |
16660 #undef ERROR_MESSAGES_TEXTS | 16701 #undef ERROR_MESSAGES_TEXTS |
16661 return error_messages_[reason]; | 16702 return error_messages_[reason]; |
16662 } | 16703 } |
16663 | 16704 |
16664 | 16705 |
16665 } } // namespace v8::internal | 16706 } } // namespace v8::internal |
OLD | NEW |