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 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 ASSERT(!HasFastProperties()); | 688 ASSERT(!HasFastProperties()); |
689 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); | 689 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); |
690 if (IsGlobalObject()) { | 690 if (IsGlobalObject()) { |
691 value = PropertyCell::cast(value)->value(); | 691 value = PropertyCell::cast(value)->value(); |
692 } | 692 } |
693 ASSERT(!value->IsPropertyCell() && !value->IsCell()); | 693 ASSERT(!value->IsPropertyCell() && !value->IsCell()); |
694 return value; | 694 return value; |
695 } | 695 } |
696 | 696 |
697 | 697 |
| 698 Handle<Object> JSObject::GetNormalizedProperty(Handle<JSObject> object, |
| 699 const LookupResult* result) { |
| 700 ASSERT(!object->HasFastProperties()); |
| 701 Isolate* isolate = object->GetIsolate(); |
| 702 Handle<Object> value(object->property_dictionary()->ValueAt( |
| 703 result->GetDictionaryEntry()), isolate); |
| 704 if (object->IsGlobalObject()) { |
| 705 value = Handle<Object>(Handle<PropertyCell>::cast(value)->value(), isolate); |
| 706 } |
| 707 ASSERT(!value->IsPropertyCell() && !value->IsCell()); |
| 708 return value; |
| 709 } |
| 710 |
| 711 |
698 void JSObject::SetNormalizedProperty(Handle<JSObject> object, | 712 void JSObject::SetNormalizedProperty(Handle<JSObject> object, |
699 const LookupResult* result, | 713 const LookupResult* result, |
700 Handle<Object> value) { | 714 Handle<Object> value) { |
701 ASSERT(!object->HasFastProperties()); | 715 ASSERT(!object->HasFastProperties()); |
702 NameDictionary* property_dictionary = object->property_dictionary(); | 716 NameDictionary* property_dictionary = object->property_dictionary(); |
703 if (object->IsGlobalObject()) { | 717 if (object->IsGlobalObject()) { |
704 Handle<PropertyCell> cell(PropertyCell::cast( | 718 Handle<PropertyCell> cell(PropertyCell::cast( |
705 property_dictionary->ValueAt(result->GetDictionaryEntry()))); | 719 property_dictionary->ValueAt(result->GetDictionaryEntry()))); |
706 PropertyCell::SetValueInferType(cell, value); | 720 PropertyCell::SetValueInferType(cell, value); |
707 } else { | 721 } else { |
(...skipping 5218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5926 Handle<JSObject> JSObject::DeepCopy(Handle<JSObject> object, | 5940 Handle<JSObject> JSObject::DeepCopy(Handle<JSObject> object, |
5927 AllocationSiteUsageContext* site_context, | 5941 AllocationSiteUsageContext* site_context, |
5928 DeepCopyHints hints) { | 5942 DeepCopyHints hints) { |
5929 JSObjectWalkVisitor<AllocationSiteUsageContext> v(site_context, true, hints); | 5943 JSObjectWalkVisitor<AllocationSiteUsageContext> v(site_context, true, hints); |
5930 Handle<JSObject> copy = v.StructureWalk(object); | 5944 Handle<JSObject> copy = v.StructureWalk(object); |
5931 ASSERT(!copy.is_identical_to(object)); | 5945 ASSERT(!copy.is_identical_to(object)); |
5932 return copy; | 5946 return copy; |
5933 } | 5947 } |
5934 | 5948 |
5935 | 5949 |
| 5950 Handle<Object> JSObject::GetDataProperty(Handle<JSObject> object, |
| 5951 Handle<Name> key) { |
| 5952 Isolate* isolate = object->GetIsolate(); |
| 5953 LookupResult lookup(isolate); |
| 5954 { |
| 5955 DisallowHeapAllocation no_allocation; |
| 5956 object->LookupRealNamedProperty(*key, &lookup); |
| 5957 } |
| 5958 Handle<Object> result = isolate->factory()->undefined_value(); |
| 5959 if (lookup.IsFound() && !lookup.IsTransition()) { |
| 5960 switch (lookup.type()) { |
| 5961 case NORMAL: |
| 5962 result = GetNormalizedProperty( |
| 5963 Handle<JSObject>(lookup.holder(), isolate), &lookup); |
| 5964 break; |
| 5965 case FIELD: |
| 5966 result = FastPropertyAt(Handle<JSObject>(lookup.holder(), isolate), |
| 5967 lookup.representation(), |
| 5968 lookup.GetFieldIndex().field_index()); |
| 5969 break; |
| 5970 case CONSTANT: |
| 5971 result = Handle<Object>(lookup.GetConstant(), isolate); |
| 5972 break; |
| 5973 case CALLBACKS: |
| 5974 case HANDLER: |
| 5975 case INTERCEPTOR: |
| 5976 break; |
| 5977 case NONEXISTENT: |
| 5978 UNREACHABLE(); |
| 5979 } |
| 5980 } |
| 5981 return result; |
| 5982 } |
| 5983 |
| 5984 |
5936 // Tests for the fast common case for property enumeration: | 5985 // Tests for the fast common case for property enumeration: |
5937 // - This object and all prototypes has an enum cache (which means that | 5986 // - This object and all prototypes has an enum cache (which means that |
5938 // it is no proxy, has no interceptors and needs no access checks). | 5987 // it is no proxy, has no interceptors and needs no access checks). |
5939 // - This object has no elements. | 5988 // - This object has no elements. |
5940 // - No prototype has enumerable properties/elements. | 5989 // - No prototype has enumerable properties/elements. |
5941 bool JSReceiver::IsSimpleEnum() { | 5990 bool JSReceiver::IsSimpleEnum() { |
5942 Heap* heap = GetHeap(); | 5991 Heap* heap = GetHeap(); |
5943 for (Object* o = this; | 5992 for (Object* o = this; |
5944 o != heap->null_value(); | 5993 o != heap->null_value(); |
5945 o = JSObject::cast(o)->GetPrototype()) { | 5994 o = JSObject::cast(o)->GetPrototype()) { |
(...skipping 10662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16608 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16657 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16609 static const char* error_messages_[] = { | 16658 static const char* error_messages_[] = { |
16610 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16659 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16611 }; | 16660 }; |
16612 #undef ERROR_MESSAGES_TEXTS | 16661 #undef ERROR_MESSAGES_TEXTS |
16613 return error_messages_[reason]; | 16662 return error_messages_[reason]; |
16614 } | 16663 } |
16615 | 16664 |
16616 | 16665 |
16617 } } // namespace v8::internal | 16666 } } // namespace v8::internal |
OLD | NEW |