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

Side by Side Diff: src/objects.cc

Issue 11233033: Fix deletion of hidden property with inline-stored hash. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Yang Guo. Created 8 years, 2 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 | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 3560 matching lines...) Expand 10 before | Expand all | Expand 10 after
3571 // For a proxy, use the prototype as target object. 3571 // For a proxy, use the prototype as target object.
3572 Object* proxy_parent = GetPrototype(); 3572 Object* proxy_parent = GetPrototype();
3573 // If the proxy is detached, return undefined. 3573 // If the proxy is detached, return undefined.
3574 if (proxy_parent->IsNull()) return GetHeap()->undefined_value(); 3574 if (proxy_parent->IsNull()) return GetHeap()->undefined_value();
3575 ASSERT(proxy_parent->IsJSGlobalObject()); 3575 ASSERT(proxy_parent->IsJSGlobalObject());
3576 return JSObject::cast(proxy_parent)->GetHiddenProperty(key); 3576 return JSObject::cast(proxy_parent)->GetHiddenProperty(key);
3577 } 3577 }
3578 ASSERT(!IsJSGlobalProxy()); 3578 ASSERT(!IsJSGlobalProxy());
3579 MaybeObject* hidden_lookup = 3579 MaybeObject* hidden_lookup =
3580 GetHiddenPropertiesHashTable(ONLY_RETURN_INLINE_VALUE); 3580 GetHiddenPropertiesHashTable(ONLY_RETURN_INLINE_VALUE);
3581 ASSERT(!hidden_lookup->IsFailure()); // No failure when passing false as arg.
3582 Object* inline_value = hidden_lookup->ToObjectUnchecked(); 3581 Object* inline_value = hidden_lookup->ToObjectUnchecked();
3583 3582
3584 if (inline_value->IsSmi()) { 3583 if (inline_value->IsSmi()) {
3585 // Handle inline-stored identity hash. 3584 // Handle inline-stored identity hash.
3586 if (key == GetHeap()->identity_hash_symbol()) { 3585 if (key == GetHeap()->identity_hash_symbol()) {
3587 return inline_value; 3586 return inline_value;
3588 } else { 3587 } else {
3589 return GetHeap()->undefined_value(); 3588 return GetHeap()->undefined_value();
3590 } 3589 }
3591 } 3590 }
(...skipping 20 matching lines...) Expand all
3612 ASSERT(key->IsSymbol()); 3611 ASSERT(key->IsSymbol());
3613 if (IsJSGlobalProxy()) { 3612 if (IsJSGlobalProxy()) {
3614 // For a proxy, use the prototype as target object. 3613 // For a proxy, use the prototype as target object.
3615 Object* proxy_parent = GetPrototype(); 3614 Object* proxy_parent = GetPrototype();
3616 // If the proxy is detached, return undefined. 3615 // If the proxy is detached, return undefined.
3617 if (proxy_parent->IsNull()) return GetHeap()->undefined_value(); 3616 if (proxy_parent->IsNull()) return GetHeap()->undefined_value();
3618 ASSERT(proxy_parent->IsJSGlobalObject()); 3617 ASSERT(proxy_parent->IsJSGlobalObject());
3619 return JSObject::cast(proxy_parent)->SetHiddenProperty(key, value); 3618 return JSObject::cast(proxy_parent)->SetHiddenProperty(key, value);
3620 } 3619 }
3621 ASSERT(!IsJSGlobalProxy()); 3620 ASSERT(!IsJSGlobalProxy());
3621 MaybeObject* hidden_lookup =
3622 GetHiddenPropertiesHashTable(ONLY_RETURN_INLINE_VALUE);
3623 Object* inline_value = hidden_lookup->ToObjectUnchecked();
3622 3624
3623 // If there is no backing store yet, store the identity hash inline. 3625 // If there is no backing store yet, store the identity hash inline.
3624 MaybeObject* hidden_lookup =
3625 GetHiddenPropertiesHashTable(ONLY_RETURN_INLINE_VALUE);
3626 ASSERT(!hidden_lookup->IsFailure());
3627 Object* inline_value = hidden_lookup->ToObjectUnchecked();
3628
3629 if (value->IsSmi() && 3626 if (value->IsSmi() &&
3630 key == GetHeap()->identity_hash_symbol() && 3627 key == GetHeap()->identity_hash_symbol() &&
3631 (inline_value->IsUndefined() || inline_value->IsSmi())) { 3628 (inline_value->IsUndefined() || inline_value->IsSmi())) {
3632 return SetHiddenPropertiesHashTable(value); 3629 return SetHiddenPropertiesHashTable(value);
3633 } 3630 }
3634 3631
3635 hidden_lookup = GetHiddenPropertiesHashTable(CREATE_NEW_IF_ABSENT); 3632 hidden_lookup = GetHiddenPropertiesHashTable(CREATE_NEW_IF_ABSENT);
3636 ObjectHashTable* hashtable; 3633 ObjectHashTable* hashtable;
3637 if (!hidden_lookup->To(&hashtable)) return hidden_lookup; 3634 if (!hidden_lookup->To(&hashtable)) return hidden_lookup;
3638 3635
(...skipping 16 matching lines...) Expand all
3655 ASSERT(key->IsSymbol()); 3652 ASSERT(key->IsSymbol());
3656 if (IsJSGlobalProxy()) { 3653 if (IsJSGlobalProxy()) {
3657 // For a proxy, use the prototype as target object. 3654 // For a proxy, use the prototype as target object.
3658 Object* proxy_parent = GetPrototype(); 3655 Object* proxy_parent = GetPrototype();
3659 // If the proxy is detached, return immediately. 3656 // If the proxy is detached, return immediately.
3660 if (proxy_parent->IsNull()) return; 3657 if (proxy_parent->IsNull()) return;
3661 ASSERT(proxy_parent->IsJSGlobalObject()); 3658 ASSERT(proxy_parent->IsJSGlobalObject());
3662 JSObject::cast(proxy_parent)->DeleteHiddenProperty(key); 3659 JSObject::cast(proxy_parent)->DeleteHiddenProperty(key);
3663 return; 3660 return;
3664 } 3661 }
3662 ASSERT(!IsJSGlobalProxy());
3665 MaybeObject* hidden_lookup = 3663 MaybeObject* hidden_lookup =
3666 GetHiddenPropertiesHashTable(ONLY_RETURN_INLINE_VALUE); 3664 GetHiddenPropertiesHashTable(ONLY_RETURN_INLINE_VALUE);
3667 ASSERT(!hidden_lookup->IsFailure()); // No failure when passing false as arg. 3665 Object* inline_value = hidden_lookup->ToObjectUnchecked();
3668 if (hidden_lookup->ToObjectUnchecked()->IsUndefined()) return; 3666
3669 // We never delete (inline-stored) identity hashes. 3667 // We never delete (inline-stored) identity hashes.
3670 ASSERT(!hidden_lookup->ToObjectUnchecked()->IsSmi()); 3668 ASSERT(key != GetHeap()->identity_hash_symbol());
3669 if (inline_value->IsUndefined() || inline_value->IsSmi()) return;
3671 3670
3672 ObjectHashTable* hashtable = 3671 ObjectHashTable* hashtable = ObjectHashTable::cast(inline_value);
3673 ObjectHashTable::cast(hidden_lookup->ToObjectUnchecked());
3674 MaybeObject* delete_result = hashtable->Put(key, GetHeap()->the_hole_value()); 3672 MaybeObject* delete_result = hashtable->Put(key, GetHeap()->the_hole_value());
3675 USE(delete_result); 3673 USE(delete_result);
3676 ASSERT(!delete_result->IsFailure()); // Delete does not cause GC. 3674 ASSERT(!delete_result->IsFailure()); // Delete does not cause GC.
3677 } 3675 }
3678 3676
3679 3677
3680 bool JSObject::HasHiddenProperties() { 3678 bool JSObject::HasHiddenProperties() {
3681 return GetPropertyAttributePostInterceptor(this, 3679 return GetPropertyAttributePostInterceptor(this,
3682 GetHeap()->hidden_symbol(), 3680 GetHeap()->hidden_symbol(),
3683 false) != ABSENT; 3681 false) != ABSENT;
(...skipping 9791 matching lines...) Expand 10 before | Expand all | Expand 10 after
13475 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13473 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13476 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13474 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13477 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13475 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13478 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13476 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13479 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 13477 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13480 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 13478 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13481 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 13479 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13482 } 13480 }
13483 13481
13484 } } // namespace v8::internal 13482 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698