Chromium Code Reviews| 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 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 694 cell->set_value(value); | 694 cell->set_value(value); |
| 695 // Please note we have to update the property details. | 695 // Please note we have to update the property details. |
| 696 property_dictionary()->DetailsAtPut(entry, details); | 696 property_dictionary()->DetailsAtPut(entry, details); |
| 697 } else { | 697 } else { |
| 698 property_dictionary()->SetEntry(entry, name, value, details); | 698 property_dictionary()->SetEntry(entry, name, value, details); |
| 699 } | 699 } |
| 700 return value; | 700 return value; |
| 701 } | 701 } |
| 702 | 702 |
| 703 | 703 |
| 704 MaybeObject* JSObject::DeleteNormalizedProperty(Name* name, DeleteMode mode) { | 704 // TODO(mstarzinger): Temporary wrapper until target is handlified. |
| 705 ASSERT(!HasFastProperties()); | 705 Handle<NameDictionary> NameDictionaryShrink(Handle<NameDictionary> dict, |
| 706 NameDictionary* dictionary = property_dictionary(); | 706 Handle<Name> name) { |
| 707 int entry = dictionary->FindEntry(name); | 707 CALL_HEAP_FUNCTION(dict->GetIsolate(), dict->Shrink(*name), NameDictionary); |
| 708 } | |
| 709 | |
| 710 | |
| 711 Handle<Object> JSObject::DeleteNormalizedProperty(Handle<JSObject> object, | |
| 712 Handle<Name> name, | |
| 713 DeleteMode mode) { | |
| 714 ASSERT(!object->HasFastProperties()); | |
| 715 Isolate* isolate = object->GetIsolate(); | |
| 716 Handle<NameDictionary> dictionary = handle(object->property_dictionary()); | |
|
Toon Verwaest
2013/07/12 12:37:34
What about just Handle<NameDictionary> dictionary(
Michael Starzinger
2013/07/16 11:37:41
Done.
| |
| 717 int entry = dictionary->FindEntry(*name); | |
| 708 if (entry != NameDictionary::kNotFound) { | 718 if (entry != NameDictionary::kNotFound) { |
| 709 // If we have a global object set the cell to the hole. | 719 // If we have a global object set the cell to the hole. |
| 710 if (IsGlobalObject()) { | 720 if (object->IsGlobalObject()) { |
| 711 PropertyDetails details = dictionary->DetailsAt(entry); | 721 PropertyDetails details = dictionary->DetailsAt(entry); |
| 712 if (details.IsDontDelete()) { | 722 if (details.IsDontDelete()) { |
| 713 if (mode != FORCE_DELETION) return GetHeap()->false_value(); | 723 if (mode != FORCE_DELETION) return isolate->factory()->false_value(); |
| 714 // When forced to delete global properties, we have to make a | 724 // When forced to delete global properties, we have to make a |
| 715 // map change to invalidate any ICs that think they can load | 725 // map change to invalidate any ICs that think they can load |
| 716 // from the DontDelete cell without checking if it contains | 726 // from the DontDelete cell without checking if it contains |
| 717 // the hole value. | 727 // the hole value. |
| 718 Map* new_map; | 728 Handle<Map> new_map = Map::CopyDropDescriptors(handle(object->map())); |
| 719 MaybeObject* maybe_new_map = map()->CopyDropDescriptors(); | |
| 720 if (!maybe_new_map->To(&new_map)) return maybe_new_map; | |
| 721 | |
| 722 ASSERT(new_map->is_dictionary_map()); | 729 ASSERT(new_map->is_dictionary_map()); |
| 723 set_map(new_map); | 730 object->set_map(*new_map); |
| 724 } | 731 } |
| 725 PropertyCell* cell = PropertyCell::cast(dictionary->ValueAt(entry)); | 732 PropertyCell* cell = PropertyCell::cast(dictionary->ValueAt(entry)); |
| 726 cell->set_value(cell->GetHeap()->the_hole_value()); | 733 cell->set_value(isolate->heap()->the_hole_value()); |
| 727 dictionary->DetailsAtPut(entry, details.AsDeleted()); | 734 dictionary->DetailsAtPut(entry, details.AsDeleted()); |
| 728 } else { | 735 } else { |
| 729 Object* deleted = dictionary->DeleteProperty(entry, mode); | 736 Handle<Object> deleted(dictionary->DeleteProperty(entry, mode), isolate); |
| 730 if (deleted == GetHeap()->true_value()) { | 737 if (*deleted == isolate->heap()->true_value()) { |
| 731 FixedArray* new_properties = NULL; | 738 Handle<NameDictionary> new_properties = |
| 732 MaybeObject* maybe_properties = dictionary->Shrink(name); | 739 NameDictionaryShrink(dictionary, name); |
| 733 if (!maybe_properties->To(&new_properties)) { | 740 object->set_properties(*new_properties); |
| 734 return maybe_properties; | |
| 735 } | |
| 736 set_properties(new_properties); | |
| 737 } | 741 } |
| 738 return deleted; | 742 return deleted; |
| 739 } | 743 } |
| 740 } | 744 } |
| 741 return GetHeap()->true_value(); | 745 return isolate->factory()->true_value(); |
| 742 } | 746 } |
| 743 | 747 |
| 744 | 748 |
| 745 bool JSObject::IsDirty() { | 749 bool JSObject::IsDirty() { |
| 746 Object* cons_obj = map()->constructor(); | 750 Object* cons_obj = map()->constructor(); |
| 747 if (!cons_obj->IsJSFunction()) | 751 if (!cons_obj->IsJSFunction()) |
| 748 return true; | 752 return true; |
| 749 JSFunction* fun = JSFunction::cast(cons_obj); | 753 JSFunction* fun = JSFunction::cast(cons_obj); |
| 750 if (!fun->shared()->IsApiFunction()) | 754 if (!fun->shared()->IsApiFunction()) |
| 751 return true; | 755 return true; |
| (...skipping 2751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3503 } | 3507 } |
| 3504 | 3508 |
| 3505 if (strict_mode == kNonStrictMode) return *value; | 3509 if (strict_mode == kNonStrictMode) return *value; |
| 3506 Handle<Object> args2[] = { name, proxy }; | 3510 Handle<Object> args2[] = { name, proxy }; |
| 3507 Handle<Object> error = isolate->factory()->NewTypeError( | 3511 Handle<Object> error = isolate->factory()->NewTypeError( |
| 3508 "no_setter_in_callback", HandleVector(args2, ARRAY_SIZE(args2))); | 3512 "no_setter_in_callback", HandleVector(args2, ARRAY_SIZE(args2))); |
| 3509 return isolate->Throw(*error); | 3513 return isolate->Throw(*error); |
| 3510 } | 3514 } |
| 3511 | 3515 |
| 3512 | 3516 |
| 3513 MUST_USE_RESULT MaybeObject* JSProxy::DeletePropertyWithHandler( | 3517 Handle<Object> JSProxy::DeletePropertyWithHandler( |
| 3514 Name* name_raw, DeleteMode mode) { | 3518 Handle<JSProxy> object, Handle<Name> name, DeleteMode mode) { |
| 3515 Isolate* isolate = GetIsolate(); | 3519 Isolate* isolate = object->GetIsolate(); |
| 3516 HandleScope scope(isolate); | |
| 3517 Handle<JSProxy> receiver(this); | |
| 3518 Handle<Object> name(name_raw, isolate); | |
| 3519 | 3520 |
| 3520 // TODO(rossberg): adjust once there is a story for symbols vs proxies. | 3521 // TODO(rossberg): adjust once there is a story for symbols vs proxies. |
| 3521 if (name->IsSymbol()) return isolate->heap()->false_value(); | 3522 if (name->IsSymbol()) return isolate->factory()->false_value(); |
| 3522 | 3523 |
| 3523 Handle<Object> args[] = { name }; | 3524 Handle<Object> args[] = { name }; |
| 3524 Handle<Object> result = CallTrap( | 3525 Handle<Object> result = object->CallTrap( |
| 3525 "delete", Handle<Object>(), ARRAY_SIZE(args), args); | 3526 "delete", Handle<Object>(), ARRAY_SIZE(args), args); |
| 3526 if (isolate->has_pending_exception()) return Failure::Exception(); | 3527 if (isolate->has_pending_exception()) return Handle<Object>(); |
| 3527 | 3528 |
| 3528 bool result_bool = result->BooleanValue(); | 3529 bool result_bool = result->BooleanValue(); |
| 3529 if (mode == STRICT_DELETION && !result_bool) { | 3530 if (mode == STRICT_DELETION && !result_bool) { |
| 3530 Handle<Object> handler(receiver->handler(), isolate); | 3531 Handle<Object> handler(object->handler(), isolate); |
| 3531 Handle<String> trap_name = isolate->factory()->InternalizeOneByteString( | 3532 Handle<String> trap_name = isolate->factory()->InternalizeOneByteString( |
| 3532 STATIC_ASCII_VECTOR("delete")); | 3533 STATIC_ASCII_VECTOR("delete")); |
| 3533 Handle<Object> args[] = { handler, trap_name }; | 3534 Handle<Object> args[] = { handler, trap_name }; |
| 3534 Handle<Object> error = isolate->factory()->NewTypeError( | 3535 Handle<Object> error = isolate->factory()->NewTypeError( |
| 3535 "handler_failed", HandleVector(args, ARRAY_SIZE(args))); | 3536 "handler_failed", HandleVector(args, ARRAY_SIZE(args))); |
| 3536 isolate->Throw(*error); | 3537 isolate->Throw(*error); |
| 3537 return Failure::Exception(); | 3538 return Handle<Object>(); |
| 3538 } | 3539 } |
| 3539 return isolate->heap()->ToBoolean(result_bool); | 3540 return isolate->factory()->ToBoolean(result_bool); |
| 3540 } | 3541 } |
| 3541 | 3542 |
| 3542 | 3543 |
| 3543 MUST_USE_RESULT MaybeObject* JSProxy::DeleteElementWithHandler( | 3544 MUST_USE_RESULT MaybeObject* JSProxy::DeleteElementWithHandler( |
| 3544 uint32_t index, | 3545 uint32_t index, |
| 3545 DeleteMode mode) { | 3546 DeleteMode mode) { |
| 3546 Isolate* isolate = GetIsolate(); | 3547 Isolate* isolate = GetIsolate(); |
| 3547 HandleScope scope(isolate); | 3548 HandleScope scope(isolate); |
| 3549 Handle<JSProxy> object(this, isolate); | |
| 3548 Handle<String> name = isolate->factory()->Uint32ToString(index); | 3550 Handle<String> name = isolate->factory()->Uint32ToString(index); |
| 3549 return JSProxy::DeletePropertyWithHandler(*name, mode); | 3551 return *JSProxy::DeletePropertyWithHandler(object, name, mode); |
|
Toon Verwaest
2013/07/12 12:37:34
It seems a bit scary to call from non-handlified c
Michael Starzinger
2013/07/16 11:37:41
Done.
| |
| 3550 } | 3552 } |
| 3551 | 3553 |
| 3552 | 3554 |
| 3553 MUST_USE_RESULT PropertyAttributes JSProxy::GetPropertyAttributeWithHandler( | 3555 MUST_USE_RESULT PropertyAttributes JSProxy::GetPropertyAttributeWithHandler( |
| 3554 JSReceiver* receiver_raw, | 3556 JSReceiver* receiver_raw, |
| 3555 Name* name_raw) { | 3557 Name* name_raw) { |
| 3556 Isolate* isolate = GetIsolate(); | 3558 Isolate* isolate = GetIsolate(); |
| 3557 HandleScope scope(isolate); | 3559 HandleScope scope(isolate); |
| 3558 Handle<JSProxy> proxy(this); | 3560 Handle<JSProxy> proxy(this); |
| 3559 Handle<Object> handler(this->handler(), isolate); // Trap might morph proxy. | 3561 Handle<Object> handler(this->handler(), isolate); // Trap might morph proxy. |
| (...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4940 SetPropertyPostInterceptor(GetHeap()->hidden_string(), | 4942 SetPropertyPostInterceptor(GetHeap()->hidden_string(), |
| 4941 value, | 4943 value, |
| 4942 DONT_ENUM, | 4944 DONT_ENUM, |
| 4943 kNonStrictMode, | 4945 kNonStrictMode, |
| 4944 OMIT_EXTENSIBILITY_CHECK); | 4946 OMIT_EXTENSIBILITY_CHECK); |
| 4945 if (store_result->IsFailure()) return store_result; | 4947 if (store_result->IsFailure()) return store_result; |
| 4946 return this; | 4948 return this; |
| 4947 } | 4949 } |
| 4948 | 4950 |
| 4949 | 4951 |
| 4950 MaybeObject* JSObject::DeletePropertyPostInterceptor(Name* name, | 4952 Handle<Object> JSObject::DeletePropertyPostInterceptor(Handle<JSObject> object, |
| 4951 DeleteMode mode) { | 4953 Handle<Name> name, |
| 4954 DeleteMode mode) { | |
| 4952 // Check local property, ignore interceptor. | 4955 // Check local property, ignore interceptor. |
| 4953 LookupResult result(GetIsolate()); | 4956 Isolate* isolate = object->GetIsolate(); |
| 4954 LocalLookupRealNamedProperty(name, &result); | 4957 LookupResult result(isolate); |
| 4955 if (!result.IsFound()) return GetHeap()->true_value(); | 4958 object->LocalLookupRealNamedProperty(*name, &result); |
| 4959 if (!result.IsFound()) return isolate->factory()->true_value(); | |
| 4956 | 4960 |
| 4957 // Normalize object if needed. | 4961 // Normalize object if needed. |
| 4958 Object* obj; | 4962 NormalizeProperties(object, CLEAR_INOBJECT_PROPERTIES, 0); |
| 4959 { MaybeObject* maybe_obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); | |
| 4960 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | |
| 4961 } | |
| 4962 | 4963 |
| 4963 return DeleteNormalizedProperty(name, mode); | 4964 return DeleteNormalizedProperty(object, name, mode); |
| 4964 } | 4965 } |
| 4965 | 4966 |
| 4966 | 4967 |
| 4967 MaybeObject* JSObject::DeletePropertyWithInterceptor(Name* name) { | 4968 Handle<Object> JSObject::DeletePropertyWithInterceptor(Handle<JSObject> object, |
| 4969 Handle<Name> name) { | |
| 4970 Isolate* isolate = object->GetIsolate(); | |
| 4971 | |
| 4968 // TODO(rossberg): Support symbols in the API. | 4972 // TODO(rossberg): Support symbols in the API. |
| 4969 if (name->IsSymbol()) return GetHeap()->false_value(); | 4973 if (name->IsSymbol()) return isolate->factory()->false_value(); |
| 4970 | 4974 |
| 4971 Isolate* isolate = GetIsolate(); | 4975 Handle<InterceptorInfo> interceptor(object->GetNamedInterceptor()); |
| 4972 HandleScope scope(isolate); | |
| 4973 Handle<InterceptorInfo> interceptor(GetNamedInterceptor()); | |
| 4974 Handle<String> name_handle(String::cast(name)); | |
| 4975 Handle<JSObject> this_handle(this); | |
| 4976 if (!interceptor->deleter()->IsUndefined()) { | 4976 if (!interceptor->deleter()->IsUndefined()) { |
| 4977 v8::NamedPropertyDeleter deleter = | 4977 v8::NamedPropertyDeleter deleter = |
| 4978 v8::ToCData<v8::NamedPropertyDeleter>(interceptor->deleter()); | 4978 v8::ToCData<v8::NamedPropertyDeleter>(interceptor->deleter()); |
| 4979 LOG(isolate, | 4979 LOG(isolate, |
| 4980 ApiNamedPropertyAccess("interceptor-named-delete", *this_handle, name)); | 4980 ApiNamedPropertyAccess("interceptor-named-delete", *object, *name)); |
| 4981 PropertyCallbackArguments args(isolate, interceptor->data(), this, this); | 4981 PropertyCallbackArguments args( |
| 4982 isolate, interceptor->data(), *object, *object); | |
| 4982 v8::Handle<v8::Boolean> result = | 4983 v8::Handle<v8::Boolean> result = |
| 4983 args.Call(deleter, v8::Utils::ToLocal(name_handle)); | 4984 args.Call(deleter, v8::Utils::ToLocal(Handle<String>::cast(name))); |
| 4984 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 4985 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 4985 if (!result.IsEmpty()) { | 4986 if (!result.IsEmpty()) { |
| 4986 ASSERT(result->IsBoolean()); | 4987 ASSERT(result->IsBoolean()); |
| 4987 Handle<Object> result_internal = v8::Utils::OpenHandle(*result); | 4988 Handle<Object> result_internal = v8::Utils::OpenHandle(*result); |
| 4988 result_internal->VerifyApiCallResultType(); | 4989 result_internal->VerifyApiCallResultType(); |
| 4989 return *result_internal; | 4990 // Rebox CustomArguments::kReturnValueOffset before returning. |
| 4991 return handle(*result_internal, isolate); | |
| 4990 } | 4992 } |
| 4991 } | 4993 } |
| 4992 MaybeObject* raw_result = | 4994 Handle<Object> result = |
| 4993 this_handle->DeletePropertyPostInterceptor(*name_handle, NORMAL_DELETION); | 4995 DeletePropertyPostInterceptor(object, name, NORMAL_DELETION); |
| 4994 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 4996 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 4995 return raw_result; | 4997 return result; |
| 4996 } | 4998 } |
| 4997 | 4999 |
| 4998 | 5000 |
| 4999 MaybeObject* JSObject::DeleteElementWithInterceptor(uint32_t index) { | 5001 MaybeObject* JSObject::DeleteElementWithInterceptor(uint32_t index) { |
| 5000 Isolate* isolate = GetIsolate(); | 5002 Isolate* isolate = GetIsolate(); |
| 5001 Heap* heap = isolate->heap(); | 5003 Heap* heap = isolate->heap(); |
| 5002 // Make sure that the top context does not change when doing | 5004 // Make sure that the top context does not change when doing |
| 5003 // callbacks or interceptor calls. | 5005 // callbacks or interceptor calls. |
| 5004 AssertNoContextChange ncc; | 5006 AssertNoContextChange ncc; |
| 5005 HandleScope scope(isolate); | 5007 HandleScope scope(isolate); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5095 | 5097 |
| 5096 if (should_enqueue_change_record && !self->HasLocalElement(index)) { | 5098 if (should_enqueue_change_record && !self->HasLocalElement(index)) { |
| 5097 Handle<String> name = isolate->factory()->Uint32ToString(index); | 5099 Handle<String> name = isolate->factory()->Uint32ToString(index); |
| 5098 EnqueueChangeRecord(self, "deleted", name, old_value); | 5100 EnqueueChangeRecord(self, "deleted", name, old_value); |
| 5099 } | 5101 } |
| 5100 | 5102 |
| 5101 return *hresult; | 5103 return *hresult; |
| 5102 } | 5104 } |
| 5103 | 5105 |
| 5104 | 5106 |
| 5105 Handle<Object> JSObject::DeleteProperty(Handle<JSObject> obj, | 5107 Handle<Object> JSObject::DeleteProperty(Handle<JSObject> object, |
| 5106 Handle<Name> prop) { | 5108 Handle<Name> name, |
| 5107 CALL_HEAP_FUNCTION(obj->GetIsolate(), | 5109 DeleteMode mode) { |
| 5108 obj->DeleteProperty(*prop, JSObject::NORMAL_DELETION), | 5110 Isolate* isolate = object->GetIsolate(); |
| 5109 Object); | |
| 5110 } | |
| 5111 | |
| 5112 | |
| 5113 MaybeObject* JSObject::DeleteProperty(Name* name, DeleteMode mode) { | |
| 5114 Isolate* isolate = GetIsolate(); | |
| 5115 // ECMA-262, 3rd, 8.6.2.5 | 5111 // ECMA-262, 3rd, 8.6.2.5 |
| 5116 ASSERT(name->IsName()); | 5112 ASSERT(name->IsName()); |
| 5117 | 5113 |
| 5118 // Check access rights if needed. | 5114 // Check access rights if needed. |
| 5119 if (IsAccessCheckNeeded() && | 5115 if (object->IsAccessCheckNeeded() && |
| 5120 !isolate->MayNamedAccess(this, name, v8::ACCESS_DELETE)) { | 5116 !isolate->MayNamedAccess(*object, *name, v8::ACCESS_DELETE)) { |
| 5121 isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE); | 5117 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_DELETE); |
| 5122 return isolate->heap()->false_value(); | 5118 return isolate->factory()->false_value(); |
| 5123 } | 5119 } |
| 5124 | 5120 |
| 5125 if (IsJSGlobalProxy()) { | 5121 if (object->IsJSGlobalProxy()) { |
| 5126 Object* proto = GetPrototype(); | 5122 Object* proto = object->GetPrototype(); |
| 5127 if (proto->IsNull()) return isolate->heap()->false_value(); | 5123 if (proto->IsNull()) return isolate->factory()->false_value(); |
| 5128 ASSERT(proto->IsJSGlobalObject()); | 5124 ASSERT(proto->IsJSGlobalObject()); |
| 5129 return JSGlobalObject::cast(proto)->DeleteProperty(name, mode); | 5125 return JSGlobalObject::DeleteProperty( |
| 5126 handle(JSGlobalObject::cast(proto)), name, mode); | |
| 5130 } | 5127 } |
| 5131 | 5128 |
| 5132 uint32_t index = 0; | 5129 uint32_t index = 0; |
| 5133 if (name->AsArrayIndex(&index)) { | 5130 if (name->AsArrayIndex(&index)) { |
| 5134 return DeleteElement(index, mode); | 5131 CALL_HEAP_FUNCTION(isolate, object->DeleteElement(index, mode), Object); |
|
Toon Verwaest
2013/07/12 12:37:34
What about just calling into the handlified versio
Michael Starzinger
2013/07/16 11:37:41
Done.
| |
| 5135 } | 5132 } |
| 5136 | 5133 |
| 5137 LookupResult lookup(isolate); | 5134 LookupResult lookup(isolate); |
| 5138 LocalLookup(name, &lookup, true); | 5135 object->LocalLookup(*name, &lookup, true); |
| 5139 if (!lookup.IsFound()) return isolate->heap()->true_value(); | 5136 if (!lookup.IsFound()) return isolate->factory()->true_value(); |
| 5140 // Ignore attributes if forcing a deletion. | 5137 // Ignore attributes if forcing a deletion. |
| 5141 if (lookup.IsDontDelete() && mode != FORCE_DELETION) { | 5138 if (lookup.IsDontDelete() && mode != FORCE_DELETION) { |
| 5142 if (mode == STRICT_DELETION) { | 5139 if (mode == STRICT_DELETION) { |
| 5143 // Deleting a non-configurable property in strict mode. | 5140 // Deleting a non-configurable property in strict mode. |
| 5144 HandleScope scope(isolate); | 5141 Handle<Object> args[2] = { name, object }; |
| 5145 Handle<Object> args[2] = { Handle<Object>(name, isolate), | 5142 Handle<Object> error = isolate->factory()->NewTypeError( |
| 5146 Handle<Object>(this, isolate) }; | 5143 "strict_delete_property", HandleVector(args, ARRAY_SIZE(args))); |
| 5147 return isolate->Throw(*isolate->factory()->NewTypeError( | 5144 isolate->Throw(*error); |
| 5148 "strict_delete_property", HandleVector(args, 2))); | 5145 return Handle<Object>(); |
| 5149 } | 5146 } |
| 5150 return isolate->heap()->false_value(); | 5147 return isolate->factory()->false_value(); |
| 5151 } | 5148 } |
| 5152 | 5149 |
| 5153 // From this point on everything needs to be handlified. | |
| 5154 HandleScope scope(isolate); | |
| 5155 Handle<JSObject> self(this); | |
| 5156 Handle<Name> hname(name); | |
| 5157 | |
| 5158 Handle<Object> old_value = isolate->factory()->the_hole_value(); | 5150 Handle<Object> old_value = isolate->factory()->the_hole_value(); |
| 5159 bool is_observed = FLAG_harmony_observation && self->map()->is_observed(); | 5151 bool is_observed = FLAG_harmony_observation && object->map()->is_observed(); |
| 5160 if (is_observed && lookup.IsDataProperty()) { | 5152 if (is_observed && lookup.IsDataProperty()) { |
| 5161 old_value = Object::GetProperty(self, hname); | 5153 old_value = Object::GetProperty(object, name); |
| 5162 } | 5154 } |
| 5163 MaybeObject* result; | 5155 Handle<Object> result; |
| 5164 | 5156 |
| 5165 // Check for interceptor. | 5157 // Check for interceptor. |
| 5166 if (lookup.IsInterceptor()) { | 5158 if (lookup.IsInterceptor()) { |
| 5167 // Skip interceptor if forcing a deletion. | 5159 // Skip interceptor if forcing a deletion. |
| 5168 if (mode == FORCE_DELETION) { | 5160 if (mode == FORCE_DELETION) { |
| 5169 result = self->DeletePropertyPostInterceptor(*hname, mode); | 5161 result = DeletePropertyPostInterceptor(object, name, mode); |
| 5170 } else { | 5162 } else { |
| 5171 result = self->DeletePropertyWithInterceptor(*hname); | 5163 result = DeletePropertyWithInterceptor(object, name); |
| 5172 } | 5164 } |
| 5173 } else { | 5165 } else { |
| 5174 // Normalize object if needed. | 5166 // Normalize object if needed. |
| 5175 Object* obj; | 5167 NormalizeProperties(object, CLEAR_INOBJECT_PROPERTIES, 0); |
| 5176 result = self->NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); | |
| 5177 if (!result->To(&obj)) return result; | |
| 5178 // Make sure the properties are normalized before removing the entry. | 5168 // Make sure the properties are normalized before removing the entry. |
| 5179 result = self->DeleteNormalizedProperty(*hname, mode); | 5169 result = DeleteNormalizedProperty(object, name, mode); |
| 5180 } | 5170 } |
| 5181 | 5171 |
| 5182 Handle<Object> hresult; | 5172 if (is_observed && !object->HasLocalProperty(*name)) { |
| 5183 if (!result->ToHandle(&hresult, isolate)) return result; | 5173 EnqueueChangeRecord(object, "deleted", name, old_value); |
| 5184 | |
| 5185 if (is_observed && !self->HasLocalProperty(*hname)) { | |
| 5186 EnqueueChangeRecord(self, "deleted", hname, old_value); | |
| 5187 } | 5174 } |
| 5188 | 5175 |
| 5189 return *hresult; | 5176 return result; |
| 5190 } | 5177 } |
| 5191 | 5178 |
| 5192 | 5179 |
| 5193 MaybeObject* JSReceiver::DeleteElement(uint32_t index, DeleteMode mode) { | 5180 MaybeObject* JSReceiver::DeleteElement(uint32_t index, DeleteMode mode) { |
| 5194 if (IsJSProxy()) { | 5181 if (IsJSProxy()) { |
| 5195 return JSProxy::cast(this)->DeleteElementWithHandler(index, mode); | 5182 return JSProxy::cast(this)->DeleteElementWithHandler(index, mode); |
|
Toon Verwaest
2013/07/12 12:37:34
I'd keep this one handlified.
Michael Starzinger
2013/07/16 11:37:41
Done.
| |
| 5196 } | 5183 } |
| 5197 return JSObject::cast(this)->DeleteElement(index, mode); | 5184 return JSObject::cast(this)->DeleteElement(index, mode); |
|
Toon Verwaest
2013/07/12 12:37:34
... and use CALL_HEAP_FUNCTION here.
Michael Starzinger
2013/07/16 11:37:41
Done.
| |
| 5198 } | 5185 } |
| 5199 | 5186 |
| 5200 | 5187 |
| 5201 MaybeObject* JSReceiver::DeleteProperty(Name* name, DeleteMode mode) { | 5188 Handle<Object> JSReceiver::DeleteProperty(Handle<JSReceiver> object, |
| 5202 if (IsJSProxy()) { | 5189 Handle<Name> name, |
| 5203 return JSProxy::cast(this)->DeletePropertyWithHandler(name, mode); | 5190 DeleteMode mode) { |
| 5191 if (object->IsJSProxy()) { | |
| 5192 return JSProxy::DeletePropertyWithHandler( | |
| 5193 Handle<JSProxy>::cast(object), name, mode); | |
| 5204 } | 5194 } |
| 5205 return JSObject::cast(this)->DeleteProperty(name, mode); | 5195 return JSObject::DeleteProperty(Handle<JSObject>::cast(object), name, mode); |
| 5206 } | 5196 } |
| 5207 | 5197 |
| 5208 | 5198 |
| 5209 bool JSObject::ReferencesObjectFromElements(FixedArray* elements, | 5199 bool JSObject::ReferencesObjectFromElements(FixedArray* elements, |
| 5210 ElementsKind kind, | 5200 ElementsKind kind, |
| 5211 Object* object) { | 5201 Object* object) { |
| 5212 ASSERT(IsFastObjectElementsKind(kind) || | 5202 ASSERT(IsFastObjectElementsKind(kind) || |
| 5213 kind == DICTIONARY_ELEMENTS); | 5203 kind == DICTIONARY_ELEMENTS); |
| 5214 if (IsFastObjectElementsKind(kind)) { | 5204 if (IsFastObjectElementsKind(kind)) { |
| 5215 int length = IsJSArray() | 5205 int length = IsJSArray() |
| (...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6439 #ifdef VERIFY_HEAP | 6429 #ifdef VERIFY_HEAP |
| 6440 if (FLAG_verify_heap && result->is_shared()) { | 6430 if (FLAG_verify_heap && result->is_shared()) { |
| 6441 result->SharedMapVerify(); | 6431 result->SharedMapVerify(); |
| 6442 } | 6432 } |
| 6443 #endif | 6433 #endif |
| 6444 | 6434 |
| 6445 return result; | 6435 return result; |
| 6446 } | 6436 } |
| 6447 | 6437 |
| 6448 | 6438 |
| 6439 Handle<Map> Map::CopyDropDescriptors(Handle<Map> map) { | |
| 6440 CALL_HEAP_FUNCTION(map->GetIsolate(), map->CopyDropDescriptors(), Map); | |
| 6441 } | |
| 6442 | |
| 6443 | |
| 6449 MaybeObject* Map::CopyDropDescriptors() { | 6444 MaybeObject* Map::CopyDropDescriptors() { |
| 6450 Map* result; | 6445 Map* result; |
| 6451 MaybeObject* maybe_result = RawCopy(instance_size()); | 6446 MaybeObject* maybe_result = RawCopy(instance_size()); |
| 6452 if (!maybe_result->To(&result)) return maybe_result; | 6447 if (!maybe_result->To(&result)) return maybe_result; |
| 6453 | 6448 |
| 6454 // Please note instance_type and instance_size are set when allocated. | 6449 // Please note instance_type and instance_size are set when allocated. |
| 6455 result->set_inobject_properties(inobject_properties()); | 6450 result->set_inobject_properties(inobject_properties()); |
| 6456 result->set_unused_property_fields(unused_property_fields()); | 6451 result->set_unused_property_fields(unused_property_fields()); |
| 6457 | 6452 |
| 6458 result->set_pre_allocated_property_fields(pre_allocated_property_fields()); | 6453 result->set_pre_allocated_property_fields(pre_allocated_property_fields()); |
| (...skipping 9359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 15818 | 15813 |
| 15819 void PropertyCell::AddDependentCode(Handle<Code> code) { | 15814 void PropertyCell::AddDependentCode(Handle<Code> code) { |
| 15820 Handle<DependentCode> codes = DependentCode::Insert( | 15815 Handle<DependentCode> codes = DependentCode::Insert( |
| 15821 Handle<DependentCode>(dependent_code()), | 15816 Handle<DependentCode>(dependent_code()), |
| 15822 DependentCode::kPropertyCellChangedGroup, code); | 15817 DependentCode::kPropertyCellChangedGroup, code); |
| 15823 if (*codes != dependent_code()) set_dependent_code(*codes); | 15818 if (*codes != dependent_code()) set_dependent_code(*codes); |
| 15824 } | 15819 } |
| 15825 | 15820 |
| 15826 | 15821 |
| 15827 } } // namespace v8::internal | 15822 } } // namespace v8::internal |
| OLD | NEW |