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

Side by Side Diff: src/objects.cc

Issue 6451004: Propagate exceptions thrown when setting elements. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Better way to communicate back absence of setter Created 9 years, 10 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 | « src/objects.h ('k') | test/mjsunit/getter-in-prototype.js » ('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 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
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 bool* found) {
1712 for (Object* pt = GetPrototype(); 1713 for (Object* pt = GetPrototype();
1713 pt != Heap::null_value(); 1714 pt != Heap::null_value();
1714 pt = pt->GetPrototype()) { 1715 pt = pt->GetPrototype()) {
1715 if (!JSObject::cast(pt)->HasDictionaryElements()) { 1716 if (!JSObject::cast(pt)->HasDictionaryElements()) {
1716 continue; 1717 continue;
1717 } 1718 }
1718 NumberDictionary* dictionary = JSObject::cast(pt)->element_dictionary(); 1719 NumberDictionary* dictionary = JSObject::cast(pt)->element_dictionary();
1719 int entry = dictionary->FindEntry(index); 1720 int entry = dictionary->FindEntry(index);
1720 if (entry != NumberDictionary::kNotFound) { 1721 if (entry != NumberDictionary::kNotFound) {
1721 Object* element = dictionary->ValueAt(entry);
1722 PropertyDetails details = dictionary->DetailsAt(entry); 1722 PropertyDetails details = dictionary->DetailsAt(entry);
1723 if (details.type() == CALLBACKS) { 1723 if (details.type() == CALLBACKS) {
1724 SetElementWithCallback(element, index, value, JSObject::cast(pt)); 1724 *found = true;
1725 return true; 1725 return SetElementWithCallback(
1726 dictionary->ValueAt(entry), index, value, JSObject::cast(pt));
1726 } 1727 }
1727 } 1728 }
1728 } 1729 }
1729 return false; 1730 *found = false;
1731 return Heap::the_hole_value();
1730 } 1732 }
1731 1733
1732 1734
1733 void JSObject::LookupInDescriptor(String* name, LookupResult* result) { 1735 void JSObject::LookupInDescriptor(String* name, LookupResult* result) {
1734 DescriptorArray* descriptors = map()->instance_descriptors(); 1736 DescriptorArray* descriptors = map()->instance_descriptors();
1735 int number = descriptors->SearchWithCache(name); 1737 int number = descriptors->SearchWithCache(name);
1736 if (number != DescriptorArray::kNotFound) { 1738 if (number != DescriptorArray::kNotFound) {
1737 result->DescriptorResult(this, descriptors->GetDetails(number), number); 1739 result->DescriptorResult(this, descriptors->GetDetails(number), number);
1738 } else { 1740 } else {
1739 result->NotFound(); 1741 result->NotFound();
(...skipping 5222 matching lines...) Expand 10 before | Expand all | Expand 10 after
6962 ASSERT(HasFastElements()); 6964 ASSERT(HasFastElements());
6963 6965
6964 Object* elms_obj; 6966 Object* elms_obj;
6965 { MaybeObject* maybe_elms_obj = EnsureWritableFastElements(); 6967 { MaybeObject* maybe_elms_obj = EnsureWritableFastElements();
6966 if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj; 6968 if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj;
6967 } 6969 }
6968 FixedArray* elms = FixedArray::cast(elms_obj); 6970 FixedArray* elms = FixedArray::cast(elms_obj);
6969 uint32_t elms_length = static_cast<uint32_t>(elms->length()); 6971 uint32_t elms_length = static_cast<uint32_t>(elms->length());
6970 6972
6971 if (check_prototype && 6973 if (check_prototype &&
6972 (index >= elms_length || elms->get(index)->IsTheHole()) && 6974 (index >= elms_length || elms->get(index)->IsTheHole())) {
6973 SetElementWithCallbackSetterInPrototypes(index, value)) { 6975 bool found;
6974 return value; 6976 MaybeObject* result =
6977 SetElementWithCallbackSetterInPrototypes(index, value, &found);
6978 if (found) return result;
6975 } 6979 }
6976 6980
6977 6981
6978 // Check whether there is extra space in fixed array.. 6982 // Check whether there is extra space in fixed array..
6979 if (index < elms_length) { 6983 if (index < elms_length) {
6980 elms->set(index, value); 6984 elms->set(index, value);
6981 if (IsJSArray()) { 6985 if (IsJSArray()) {
6982 // Update the length of the array if needed. 6986 // Update the length of the array if needed.
6983 uint32_t array_length = 0; 6987 uint32_t array_length = 0;
6984 CHECK(JSArray::cast(this)->length()->ToArrayIndex(&array_length)); 6988 CHECK(JSArray::cast(this)->length()->ToArrayIndex(&array_length));
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
7096 Object* element = dictionary->ValueAt(entry); 7100 Object* element = dictionary->ValueAt(entry);
7097 PropertyDetails details = dictionary->DetailsAt(entry); 7101 PropertyDetails details = dictionary->DetailsAt(entry);
7098 if (details.type() == CALLBACKS) { 7102 if (details.type() == CALLBACKS) {
7099 return SetElementWithCallback(element, index, value, this); 7103 return SetElementWithCallback(element, index, value, this);
7100 } else { 7104 } else {
7101 dictionary->UpdateMaxNumberKey(index); 7105 dictionary->UpdateMaxNumberKey(index);
7102 dictionary->ValueAtPut(entry, value); 7106 dictionary->ValueAtPut(entry, value);
7103 } 7107 }
7104 } else { 7108 } else {
7105 // Index not already used. Look for an accessor in the prototype chain. 7109 // Index not already used. Look for an accessor in the prototype chain.
7106 if (check_prototype && 7110 if (check_prototype) {
7107 SetElementWithCallbackSetterInPrototypes(index, value)) { 7111 bool found;
7108 return value; 7112 MaybeObject* result =
7113 SetElementWithCallbackSetterInPrototypes(index, value, &found);
7114 if (found) return result;
7109 } 7115 }
7110 // When we set the is_extensible flag to false we always force 7116 // When we set the is_extensible flag to false we always force
7111 // the element into dictionary mode (and force them to stay there). 7117 // the element into dictionary mode (and force them to stay there).
7112 if (!map()->is_extensible()) { 7118 if (!map()->is_extensible()) {
7113 Handle<Object> number(Factory::NewNumberFromUint(index)); 7119 Handle<Object> number(Factory::NewNumberFromUint(index));
7114 Handle<String> index_string(Factory::NumberToString(number)); 7120 Handle<String> index_string(Factory::NumberToString(number));
7115 Handle<Object> args[1] = { index_string }; 7121 Handle<Object> args[1] = { index_string };
7116 return Top::Throw(*Factory::NewTypeError("object_not_extensible", 7122 return Top::Throw(*Factory::NewTypeError("object_not_extensible",
7117 HandleVector(args, 1))); 7123 HandleVector(args, 1)));
7118 } 7124 }
(...skipping 2788 matching lines...) Expand 10 before | Expand all | Expand 10 after
9907 if (break_point_objects()->IsUndefined()) return 0; 9913 if (break_point_objects()->IsUndefined()) return 0;
9908 // Single beak point. 9914 // Single beak point.
9909 if (!break_point_objects()->IsFixedArray()) return 1; 9915 if (!break_point_objects()->IsFixedArray()) return 1;
9910 // Multiple break points. 9916 // Multiple break points.
9911 return FixedArray::cast(break_point_objects())->length(); 9917 return FixedArray::cast(break_point_objects())->length();
9912 } 9918 }
9913 #endif 9919 #endif
9914 9920
9915 9921
9916 } } // namespace v8::internal 9922 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | test/mjsunit/getter-in-prototype.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698