Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 1689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1700 } | 1700 } |
| 1701 if (result->type() == CALLBACKS) { | 1701 if (result->type() == CALLBACKS) { |
| 1702 return; | 1702 return; |
| 1703 } | 1703 } |
| 1704 } | 1704 } |
| 1705 } | 1705 } |
| 1706 result->NotFound(); | 1706 result->NotFound(); |
| 1707 } | 1707 } |
| 1708 | 1708 |
| 1709 | 1709 |
| 1710 bool JSObject::SetElementWithCallbackSetterInPrototypes(uint32_t index, | 1710 MaybeObject* JSObject::SetElementWithCallbackSetterInPrototypes(uint32_t index, |
| 1711 Object* value) { | 1711 Object* value) { |
| 1712 for (Object* pt = GetPrototype(); | 1712 for (Object* pt = GetPrototype(); |
| 1713 pt != Heap::null_value(); | 1713 pt != Heap::null_value(); |
| 1714 pt = pt->GetPrototype()) { | 1714 pt = pt->GetPrototype()) { |
| 1715 if (!JSObject::cast(pt)->HasDictionaryElements()) { | 1715 if (!JSObject::cast(pt)->HasDictionaryElements()) { |
| 1716 continue; | 1716 continue; |
| 1717 } | 1717 } |
| 1718 NumberDictionary* dictionary = JSObject::cast(pt)->element_dictionary(); | 1718 NumberDictionary* dictionary = JSObject::cast(pt)->element_dictionary(); |
| 1719 int entry = dictionary->FindEntry(index); | 1719 int entry = dictionary->FindEntry(index); |
| 1720 if (entry != NumberDictionary::kNotFound) { | 1720 if (entry != NumberDictionary::kNotFound) { |
| 1721 Object* element = dictionary->ValueAt(entry); | |
| 1722 PropertyDetails details = dictionary->DetailsAt(entry); | 1721 PropertyDetails details = dictionary->DetailsAt(entry); |
| 1723 if (details.type() == CALLBACKS) { | 1722 if (details.type() == CALLBACKS) { |
| 1724 SetElementWithCallback(element, index, value, JSObject::cast(pt)); | 1723 return SetElementWithCallback( |
| 1725 return true; | 1724 dictionary->ValueAt(entry), index, value, JSObject::cast(pt)); |
| 1726 } | 1725 } |
| 1727 } | 1726 } |
| 1728 } | 1727 } |
| 1729 return false; | 1728 return Heap::the_hole_value(); |
|
Mads Ager (chromium)
2011/02/08 18:59:11
Can we do an output parameter called something lik
antonm
2011/02/08 19:36:03
Done.
| |
| 1730 } | 1729 } |
| 1731 | 1730 |
| 1732 | 1731 |
| 1733 void JSObject::LookupInDescriptor(String* name, LookupResult* result) { | 1732 void JSObject::LookupInDescriptor(String* name, LookupResult* result) { |
| 1734 DescriptorArray* descriptors = map()->instance_descriptors(); | 1733 DescriptorArray* descriptors = map()->instance_descriptors(); |
| 1735 int number = descriptors->SearchWithCache(name); | 1734 int number = descriptors->SearchWithCache(name); |
| 1736 if (number != DescriptorArray::kNotFound) { | 1735 if (number != DescriptorArray::kNotFound) { |
| 1737 result->DescriptorResult(this, descriptors->GetDetails(number), number); | 1736 result->DescriptorResult(this, descriptors->GetDetails(number), number); |
| 1738 } else { | 1737 } else { |
| 1739 result->NotFound(); | 1738 result->NotFound(); |
| (...skipping 5215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6955 ASSERT(HasFastElements()); | 6954 ASSERT(HasFastElements()); |
| 6956 | 6955 |
| 6957 Object* elms_obj; | 6956 Object* elms_obj; |
| 6958 { MaybeObject* maybe_elms_obj = EnsureWritableFastElements(); | 6957 { MaybeObject* maybe_elms_obj = EnsureWritableFastElements(); |
| 6959 if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj; | 6958 if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj; |
| 6960 } | 6959 } |
| 6961 FixedArray* elms = FixedArray::cast(elms_obj); | 6960 FixedArray* elms = FixedArray::cast(elms_obj); |
| 6962 uint32_t elms_length = static_cast<uint32_t>(elms->length()); | 6961 uint32_t elms_length = static_cast<uint32_t>(elms->length()); |
| 6963 | 6962 |
| 6964 if (check_prototype && | 6963 if (check_prototype && |
| 6965 (index >= elms_length || elms->get(index)->IsTheHole()) && | 6964 (index >= elms_length || elms->get(index)->IsTheHole())) { |
| 6966 SetElementWithCallbackSetterInPrototypes(index, value)) { | 6965 MaybeObject* result = |
| 6967 return value; | 6966 SetElementWithCallbackSetterInPrototypes(index, value); |
| 6967 if (result != Heap::the_hole_value()) return result; | |
| 6968 } | 6968 } |
| 6969 | 6969 |
| 6970 | 6970 |
| 6971 // Check whether there is extra space in fixed array.. | 6971 // Check whether there is extra space in fixed array.. |
| 6972 if (index < elms_length) { | 6972 if (index < elms_length) { |
| 6973 elms->set(index, value); | 6973 elms->set(index, value); |
| 6974 if (IsJSArray()) { | 6974 if (IsJSArray()) { |
| 6975 // Update the length of the array if needed. | 6975 // Update the length of the array if needed. |
| 6976 uint32_t array_length = 0; | 6976 uint32_t array_length = 0; |
| 6977 CHECK(JSArray::cast(this)->length()->ToArrayIndex(&array_length)); | 6977 CHECK(JSArray::cast(this)->length()->ToArrayIndex(&array_length)); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7089 Object* element = dictionary->ValueAt(entry); | 7089 Object* element = dictionary->ValueAt(entry); |
| 7090 PropertyDetails details = dictionary->DetailsAt(entry); | 7090 PropertyDetails details = dictionary->DetailsAt(entry); |
| 7091 if (details.type() == CALLBACKS) { | 7091 if (details.type() == CALLBACKS) { |
| 7092 return SetElementWithCallback(element, index, value, this); | 7092 return SetElementWithCallback(element, index, value, this); |
| 7093 } else { | 7093 } else { |
| 7094 dictionary->UpdateMaxNumberKey(index); | 7094 dictionary->UpdateMaxNumberKey(index); |
| 7095 dictionary->ValueAtPut(entry, value); | 7095 dictionary->ValueAtPut(entry, value); |
| 7096 } | 7096 } |
| 7097 } else { | 7097 } else { |
| 7098 // Index not already used. Look for an accessor in the prototype chain. | 7098 // Index not already used. Look for an accessor in the prototype chain. |
| 7099 if (check_prototype && | 7099 if (check_prototype) { |
| 7100 SetElementWithCallbackSetterInPrototypes(index, value)) { | 7100 MaybeObject* result = |
| 7101 return value; | 7101 SetElementWithCallbackSetterInPrototypes(index, value); |
| 7102 if (result != Heap::the_hole_value()) return result; | |
| 7102 } | 7103 } |
| 7103 // When we set the is_extensible flag to false we always force | 7104 // When we set the is_extensible flag to false we always force |
| 7104 // the element into dictionary mode (and force them to stay there). | 7105 // the element into dictionary mode (and force them to stay there). |
| 7105 if (!map()->is_extensible()) { | 7106 if (!map()->is_extensible()) { |
| 7106 Handle<Object> number(Factory::NewNumberFromUint(index)); | 7107 Handle<Object> number(Factory::NewNumberFromUint(index)); |
| 7107 Handle<String> index_string(Factory::NumberToString(number)); | 7108 Handle<String> index_string(Factory::NumberToString(number)); |
| 7108 Handle<Object> args[1] = { index_string }; | 7109 Handle<Object> args[1] = { index_string }; |
| 7109 return Top::Throw(*Factory::NewTypeError("object_not_extensible", | 7110 return Top::Throw(*Factory::NewTypeError("object_not_extensible", |
| 7110 HandleVector(args, 1))); | 7111 HandleVector(args, 1))); |
| 7111 } | 7112 } |
| (...skipping 2788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9900 if (break_point_objects()->IsUndefined()) return 0; | 9901 if (break_point_objects()->IsUndefined()) return 0; |
| 9901 // Single beak point. | 9902 // Single beak point. |
| 9902 if (!break_point_objects()->IsFixedArray()) return 1; | 9903 if (!break_point_objects()->IsFixedArray()) return 1; |
| 9903 // Multiple break points. | 9904 // Multiple break points. |
| 9904 return FixedArray::cast(break_point_objects())->length(); | 9905 return FixedArray::cast(break_point_objects())->length(); |
| 9905 } | 9906 } |
| 9906 #endif | 9907 #endif |
| 9907 | 9908 |
| 9908 | 9909 |
| 9909 } } // namespace v8::internal | 9910 } } // namespace v8::internal |
| OLD | NEW |