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 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 if (object->IsGlobalObject()) { | 626 if (object->IsGlobalObject()) { |
627 Handle<PropertyCell> cell(PropertyCell::cast( | 627 Handle<PropertyCell> cell(PropertyCell::cast( |
628 property_dictionary->ValueAt(result->GetDictionaryEntry()))); | 628 property_dictionary->ValueAt(result->GetDictionaryEntry()))); |
629 PropertyCell::SetValueInferType(cell, value); | 629 PropertyCell::SetValueInferType(cell, value); |
630 } else { | 630 } else { |
631 property_dictionary->ValueAtPut(result->GetDictionaryEntry(), *value); | 631 property_dictionary->ValueAtPut(result->GetDictionaryEntry(), *value); |
632 } | 632 } |
633 } | 633 } |
634 | 634 |
635 | 635 |
636 // TODO(mstarzinger): Temporary wrapper until handlified. | |
637 static Handle<NameDictionary> NameDictionaryAdd(Handle<NameDictionary> dict, | |
638 Handle<Name> name, | |
639 Handle<Object> value, | |
640 PropertyDetails details) { | |
641 CALL_HEAP_FUNCTION(dict->GetIsolate(), | |
642 dict->Add(*name, *value, details), | |
643 NameDictionary); | |
644 } | |
645 | |
646 | |
647 void JSObject::SetNormalizedProperty(Handle<JSObject> object, | 636 void JSObject::SetNormalizedProperty(Handle<JSObject> object, |
648 Handle<Name> name, | 637 Handle<Name> name, |
649 Handle<Object> value, | 638 Handle<Object> value, |
650 PropertyDetails details) { | 639 PropertyDetails details) { |
651 ASSERT(!object->HasFastProperties()); | 640 ASSERT(!object->HasFastProperties()); |
652 Handle<NameDictionary> property_dictionary(object->property_dictionary()); | 641 Handle<NameDictionary> property_dictionary(object->property_dictionary()); |
653 | 642 |
654 if (!name->IsUniqueName()) { | 643 if (!name->IsUniqueName()) { |
655 name = object->GetIsolate()->factory()->InternalizeString( | 644 name = object->GetIsolate()->factory()->InternalizeString( |
656 Handle<String>::cast(name)); | 645 Handle<String>::cast(name)); |
657 } | 646 } |
658 | 647 |
659 int entry = property_dictionary->FindEntry(*name); | 648 int entry = property_dictionary->FindEntry(*name); |
660 if (entry == NameDictionary::kNotFound) { | 649 if (entry == NameDictionary::kNotFound) { |
661 Handle<Object> store_value = value; | 650 Handle<Object> store_value = value; |
662 if (object->IsGlobalObject()) { | 651 if (object->IsGlobalObject()) { |
663 store_value = object->GetIsolate()->factory()->NewPropertyCell(value); | 652 store_value = object->GetIsolate()->factory()->NewPropertyCell(value); |
664 } | 653 } |
665 | 654 |
666 property_dictionary = | 655 property_dictionary = |
667 NameDictionaryAdd(property_dictionary, name, store_value, details); | 656 NameDictionary::Add(property_dictionary, name, store_value, details); |
668 object->set_properties(*property_dictionary); | 657 object->set_properties(*property_dictionary); |
669 return; | 658 return; |
670 } | 659 } |
671 | 660 |
672 PropertyDetails original_details = property_dictionary->DetailsAt(entry); | 661 PropertyDetails original_details = property_dictionary->DetailsAt(entry); |
673 int enumeration_index; | 662 int enumeration_index; |
674 // Preserve the enumeration index unless the property was deleted. | 663 // Preserve the enumeration index unless the property was deleted. |
675 if (original_details.IsDeleted()) { | 664 if (original_details.IsDeleted()) { |
676 enumeration_index = property_dictionary->NextEnumerationIndex(); | 665 enumeration_index = property_dictionary->NextEnumerationIndex(); |
677 property_dictionary->SetNextEnumerationIndex(enumeration_index + 1); | 666 property_dictionary->SetNextEnumerationIndex(enumeration_index + 1); |
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1937 PropertyDetails details = PropertyDetails(attributes, NORMAL, index); | 1926 PropertyDetails details = PropertyDetails(attributes, NORMAL, index); |
1938 dict->SetNextEnumerationIndex(index + 1); | 1927 dict->SetNextEnumerationIndex(index + 1); |
1939 dict->SetEntry(entry, *name, *cell, details); | 1928 dict->SetEntry(entry, *name, *cell, details); |
1940 return; | 1929 return; |
1941 } | 1930 } |
1942 Handle<PropertyCell> cell = isolate->factory()->NewPropertyCell(value); | 1931 Handle<PropertyCell> cell = isolate->factory()->NewPropertyCell(value); |
1943 PropertyCell::SetValueInferType(cell, value); | 1932 PropertyCell::SetValueInferType(cell, value); |
1944 value = cell; | 1933 value = cell; |
1945 } | 1934 } |
1946 PropertyDetails details = PropertyDetails(attributes, NORMAL, 0); | 1935 PropertyDetails details = PropertyDetails(attributes, NORMAL, 0); |
1947 Handle<NameDictionary> result = NameDictionaryAdd(dict, name, value, details); | 1936 Handle<NameDictionary> result = |
| 1937 NameDictionary::Add(dict, name, value, details); |
1948 if (*dict != *result) object->set_properties(*result); | 1938 if (*dict != *result) object->set_properties(*result); |
1949 } | 1939 } |
1950 | 1940 |
1951 | 1941 |
1952 MaybeHandle<Object> JSObject::AddProperty( | 1942 MaybeHandle<Object> JSObject::AddProperty( |
1953 Handle<JSObject> object, | 1943 Handle<JSObject> object, |
1954 Handle<Name> name, | 1944 Handle<Name> name, |
1955 Handle<Object> value, | 1945 Handle<Object> value, |
1956 PropertyAttributes attributes, | 1946 PropertyAttributes attributes, |
1957 StrictMode strict_mode, | 1947 StrictMode strict_mode, |
(...skipping 2538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4496 | 4486 |
4497 Handle<DescriptorArray> descs(map->instance_descriptors()); | 4487 Handle<DescriptorArray> descs(map->instance_descriptors()); |
4498 for (int i = 0; i < real_size; i++) { | 4488 for (int i = 0; i < real_size; i++) { |
4499 PropertyDetails details = descs->GetDetails(i); | 4489 PropertyDetails details = descs->GetDetails(i); |
4500 switch (details.type()) { | 4490 switch (details.type()) { |
4501 case CONSTANT: { | 4491 case CONSTANT: { |
4502 Handle<Name> key(descs->GetKey(i)); | 4492 Handle<Name> key(descs->GetKey(i)); |
4503 Handle<Object> value(descs->GetConstant(i), isolate); | 4493 Handle<Object> value(descs->GetConstant(i), isolate); |
4504 PropertyDetails d = PropertyDetails( | 4494 PropertyDetails d = PropertyDetails( |
4505 details.attributes(), NORMAL, i + 1); | 4495 details.attributes(), NORMAL, i + 1); |
4506 dictionary = NameDictionaryAdd(dictionary, key, value, d); | 4496 dictionary = NameDictionary::Add(dictionary, key, value, d); |
4507 break; | 4497 break; |
4508 } | 4498 } |
4509 case FIELD: { | 4499 case FIELD: { |
4510 Handle<Name> key(descs->GetKey(i)); | 4500 Handle<Name> key(descs->GetKey(i)); |
4511 Handle<Object> value( | 4501 Handle<Object> value( |
4512 object->RawFastPropertyAt(descs->GetFieldIndex(i)), isolate); | 4502 object->RawFastPropertyAt(descs->GetFieldIndex(i)), isolate); |
4513 PropertyDetails d = | 4503 PropertyDetails d = |
4514 PropertyDetails(details.attributes(), NORMAL, i + 1); | 4504 PropertyDetails(details.attributes(), NORMAL, i + 1); |
4515 dictionary = NameDictionaryAdd(dictionary, key, value, d); | 4505 dictionary = NameDictionary::Add(dictionary, key, value, d); |
4516 break; | 4506 break; |
4517 } | 4507 } |
4518 case CALLBACKS: { | 4508 case CALLBACKS: { |
4519 Handle<Name> key(descs->GetKey(i)); | 4509 Handle<Name> key(descs->GetKey(i)); |
4520 Handle<Object> value(descs->GetCallbacksObject(i), isolate); | 4510 Handle<Object> value(descs->GetCallbacksObject(i), isolate); |
4521 PropertyDetails d = PropertyDetails( | 4511 PropertyDetails d = PropertyDetails( |
4522 details.attributes(), CALLBACKS, i + 1); | 4512 details.attributes(), CALLBACKS, i + 1); |
4523 dictionary = NameDictionaryAdd(dictionary, key, value, d); | 4513 dictionary = NameDictionary::Add(dictionary, key, value, d); |
4524 break; | 4514 break; |
4525 } | 4515 } |
4526 case INTERCEPTOR: | 4516 case INTERCEPTOR: |
4527 break; | 4517 break; |
4528 case HANDLER: | 4518 case HANDLER: |
4529 case NORMAL: | 4519 case NORMAL: |
4530 case NONEXISTENT: | 4520 case NONEXISTENT: |
4531 UNREACHABLE(); | 4521 UNREACHABLE(); |
4532 break; | 4522 break; |
4533 } | 4523 } |
(...skipping 9762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14296 template | 14286 template |
14297 int Dictionary<SeededNumberDictionaryShape, uint32_t>::NumberOfEnumElements(); | 14287 int Dictionary<SeededNumberDictionaryShape, uint32_t>::NumberOfEnumElements(); |
14298 | 14288 |
14299 template | 14289 template |
14300 int Dictionary<NameDictionaryShape, Name*>::NumberOfEnumElements(); | 14290 int Dictionary<NameDictionaryShape, Name*>::NumberOfEnumElements(); |
14301 | 14291 |
14302 template | 14292 template |
14303 int HashTable<SeededNumberDictionaryShape, uint32_t>::FindEntry(uint32_t); | 14293 int HashTable<SeededNumberDictionaryShape, uint32_t>::FindEntry(uint32_t); |
14304 | 14294 |
14305 | 14295 |
| 14296 Handle<NameDictionary> NameDictionary::Add(Handle<NameDictionary> dict, |
| 14297 Handle<Name> name, |
| 14298 Handle<Object> value, |
| 14299 PropertyDetails details) { |
| 14300 CALL_HEAP_FUNCTION(dict->GetIsolate(), |
| 14301 Handle<Dictionary>::cast(dict)->Add( |
| 14302 *name, *value, details), |
| 14303 NameDictionary); |
| 14304 } |
| 14305 |
| 14306 |
14306 Handle<Object> JSObject::PrepareSlowElementsForSort( | 14307 Handle<Object> JSObject::PrepareSlowElementsForSort( |
14307 Handle<JSObject> object, uint32_t limit) { | 14308 Handle<JSObject> object, uint32_t limit) { |
14308 CALL_HEAP_FUNCTION(object->GetIsolate(), | 14309 CALL_HEAP_FUNCTION(object->GetIsolate(), |
14309 object->PrepareSlowElementsForSort(limit), | 14310 object->PrepareSlowElementsForSort(limit), |
14310 Object); | 14311 Object); |
14311 } | 14312 } |
14312 | 14313 |
14313 | 14314 |
14314 // Collates undefined and unexisting elements below limit from position | 14315 // Collates undefined and unexisting elements below limit from position |
14315 // zero of the elements. The object stays in Dictionary mode. | 14316 // zero of the elements. The object stays in Dictionary mode. |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14827 Handle<JSGlobalObject> global, | 14828 Handle<JSGlobalObject> global, |
14828 Handle<Name> name) { | 14829 Handle<Name> name) { |
14829 ASSERT(!global->HasFastProperties()); | 14830 ASSERT(!global->HasFastProperties()); |
14830 int entry = global->property_dictionary()->FindEntry(*name); | 14831 int entry = global->property_dictionary()->FindEntry(*name); |
14831 if (entry == NameDictionary::kNotFound) { | 14832 if (entry == NameDictionary::kNotFound) { |
14832 Isolate* isolate = global->GetIsolate(); | 14833 Isolate* isolate = global->GetIsolate(); |
14833 Handle<PropertyCell> cell = isolate->factory()->NewPropertyCell( | 14834 Handle<PropertyCell> cell = isolate->factory()->NewPropertyCell( |
14834 isolate->factory()->the_hole_value()); | 14835 isolate->factory()->the_hole_value()); |
14835 PropertyDetails details(NONE, NORMAL, 0); | 14836 PropertyDetails details(NONE, NORMAL, 0); |
14836 details = details.AsDeleted(); | 14837 details = details.AsDeleted(); |
14837 Handle<NameDictionary> dictionary = NameDictionaryAdd( | 14838 Handle<NameDictionary> dictionary = NameDictionary::Add( |
14838 handle(global->property_dictionary()), name, cell, details); | 14839 handle(global->property_dictionary()), name, cell, details); |
14839 global->set_properties(*dictionary); | 14840 global->set_properties(*dictionary); |
14840 return cell; | 14841 return cell; |
14841 } else { | 14842 } else { |
14842 Object* value = global->property_dictionary()->ValueAt(entry); | 14843 Object* value = global->property_dictionary()->ValueAt(entry); |
14843 ASSERT(value->IsPropertyCell()); | 14844 ASSERT(value->IsPropertyCell()); |
14844 return handle(PropertyCell::cast(value)); | 14845 return handle(PropertyCell::cast(value)); |
14845 } | 14846 } |
14846 } | 14847 } |
14847 | 14848 |
(...skipping 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16494 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16495 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16495 static const char* error_messages_[] = { | 16496 static const char* error_messages_[] = { |
16496 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16497 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16497 }; | 16498 }; |
16498 #undef ERROR_MESSAGES_TEXTS | 16499 #undef ERROR_MESSAGES_TEXTS |
16499 return error_messages_[reason]; | 16500 return error_messages_[reason]; |
16500 } | 16501 } |
16501 | 16502 |
16502 | 16503 |
16503 } } // namespace v8::internal | 16504 } } // namespace v8::internal |
OLD | NEW |