| 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 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1548 DICTIONARY_ELEMENT | 1548 DICTIONARY_ELEMENT |
| 1549 }; | 1549 }; |
| 1550 | 1550 |
| 1551 LocalElementType HasLocalElement(uint32_t index); | 1551 LocalElementType HasLocalElement(uint32_t index); |
| 1552 | 1552 |
| 1553 bool HasElementWithInterceptor(JSObject* receiver, uint32_t index); | 1553 bool HasElementWithInterceptor(JSObject* receiver, uint32_t index); |
| 1554 bool HasElementPostInterceptor(JSObject* receiver, uint32_t index); | 1554 bool HasElementPostInterceptor(JSObject* receiver, uint32_t index); |
| 1555 | 1555 |
| 1556 MUST_USE_RESULT MaybeObject* SetFastElement(uint32_t index, | 1556 MUST_USE_RESULT MaybeObject* SetFastElement(uint32_t index, |
| 1557 Object* value, | 1557 Object* value, |
| 1558 StrictModeFlag strict_mode, |
| 1558 bool check_prototype = true); | 1559 bool check_prototype = true); |
| 1559 | 1560 |
| 1560 // Set the index'th array element. | 1561 // Set the index'th array element. |
| 1561 // A Failure object is returned if GC is needed. | 1562 // A Failure object is returned if GC is needed. |
| 1562 MUST_USE_RESULT MaybeObject* SetElement(uint32_t index, | 1563 MUST_USE_RESULT MaybeObject* SetElement(uint32_t index, |
| 1563 Object* value, | 1564 Object* value, |
| 1565 StrictModeFlag strict_mode, |
| 1564 bool check_prototype = true); | 1566 bool check_prototype = true); |
| 1565 | 1567 |
| 1566 // Returns the index'th element. | 1568 // Returns the index'th element. |
| 1567 // The undefined object if index is out of bounds. | 1569 // The undefined object if index is out of bounds. |
| 1568 MaybeObject* GetElementWithReceiver(Object* receiver, uint32_t index); | 1570 MaybeObject* GetElementWithReceiver(Object* receiver, uint32_t index); |
| 1569 MaybeObject* GetElementWithInterceptor(Object* receiver, uint32_t index); | 1571 MaybeObject* GetElementWithInterceptor(Object* receiver, uint32_t index); |
| 1570 | 1572 |
| 1571 // Get external element value at index if there is one and undefined | 1573 // Get external element value at index if there is one and undefined |
| 1572 // otherwise. Can return a failure if allocation of a heap number | 1574 // otherwise. Can return a failure if allocation of a heap number |
| 1573 // failed. | 1575 // failed. |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1813 | 1815 |
| 1814 private: | 1816 private: |
| 1815 MUST_USE_RESULT MaybeObject* GetElementWithCallback(Object* receiver, | 1817 MUST_USE_RESULT MaybeObject* GetElementWithCallback(Object* receiver, |
| 1816 Object* structure, | 1818 Object* structure, |
| 1817 uint32_t index, | 1819 uint32_t index, |
| 1818 Object* holder); | 1820 Object* holder); |
| 1819 MaybeObject* SetElementWithCallback(Object* structure, | 1821 MaybeObject* SetElementWithCallback(Object* structure, |
| 1820 uint32_t index, | 1822 uint32_t index, |
| 1821 Object* value, | 1823 Object* value, |
| 1822 JSObject* holder); | 1824 JSObject* holder); |
| 1823 MUST_USE_RESULT MaybeObject* SetElementWithInterceptor(uint32_t index, | 1825 MUST_USE_RESULT MaybeObject* SetElementWithInterceptor( |
| 1824 Object* value, | 1826 uint32_t index, |
| 1825 bool check_prototype); | 1827 Object* value, |
| 1828 StrictModeFlag strict_mode, |
| 1829 bool check_prototype); |
| 1826 MUST_USE_RESULT MaybeObject* SetElementWithoutInterceptor( | 1830 MUST_USE_RESULT MaybeObject* SetElementWithoutInterceptor( |
| 1827 uint32_t index, | 1831 uint32_t index, |
| 1828 Object* value, | 1832 Object* value, |
| 1833 StrictModeFlag strict_mode, |
| 1829 bool check_prototype); | 1834 bool check_prototype); |
| 1830 | 1835 |
| 1831 MaybeObject* GetElementPostInterceptor(Object* receiver, uint32_t index); | 1836 MaybeObject* GetElementPostInterceptor(Object* receiver, uint32_t index); |
| 1832 | 1837 |
| 1833 MUST_USE_RESULT MaybeObject* DeletePropertyPostInterceptor(String* name, | 1838 MUST_USE_RESULT MaybeObject* DeletePropertyPostInterceptor(String* name, |
| 1834 DeleteMode mode); | 1839 DeleteMode mode); |
| 1835 MUST_USE_RESULT MaybeObject* DeletePropertyWithInterceptor(String* name); | 1840 MUST_USE_RESULT MaybeObject* DeletePropertyWithInterceptor(String* name); |
| 1836 | 1841 |
| 1837 MUST_USE_RESULT MaybeObject* DeleteElementPostInterceptor(uint32_t index, | 1842 MUST_USE_RESULT MaybeObject* DeleteElementPostInterceptor(uint32_t index, |
| 1838 DeleteMode mode); | 1843 DeleteMode mode); |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2463 static inline Dictionary<Shape, Key>* cast(Object* obj) { | 2468 static inline Dictionary<Shape, Key>* cast(Object* obj) { |
| 2464 return reinterpret_cast<Dictionary<Shape, Key>*>(obj); | 2469 return reinterpret_cast<Dictionary<Shape, Key>*>(obj); |
| 2465 } | 2470 } |
| 2466 | 2471 |
| 2467 // Returns the value at entry. | 2472 // Returns the value at entry. |
| 2468 Object* ValueAt(int entry) { | 2473 Object* ValueAt(int entry) { |
| 2469 return this->get(HashTable<Shape, Key>::EntryToIndex(entry)+1); | 2474 return this->get(HashTable<Shape, Key>::EntryToIndex(entry)+1); |
| 2470 } | 2475 } |
| 2471 | 2476 |
| 2472 // Set the value for entry. | 2477 // Set the value for entry. |
| 2473 void ValueAtPut(int entry, Object* value) { | 2478 // Returns false if the put wasn't performed due to property being read only. |
| 2479 // Returns true on successful put. |
| 2480 bool ValueAtPut(int entry, Object* value) { |
| 2474 // Check that this value can actually be written. | 2481 // Check that this value can actually be written. |
| 2475 PropertyDetails details = DetailsAt(entry); | 2482 PropertyDetails details = DetailsAt(entry); |
| 2476 // If a value has not been initilized we allow writing to it even if | 2483 // If a value has not been initilized we allow writing to it even if |
| 2477 // it is read only (a declared const that has not been initialized). | 2484 // it is read only (a declared const that has not been initialized). |
| 2478 if (details.IsReadOnly() && !ValueAt(entry)->IsTheHole()) return; | 2485 if (details.IsReadOnly() && !ValueAt(entry)->IsTheHole()) { |
| 2479 this->set(HashTable<Shape, Key>::EntryToIndex(entry)+1, value); | 2486 return false; |
| 2487 } |
| 2488 this->set(HashTable<Shape, Key>::EntryToIndex(entry) + 1, value); |
| 2489 return true; |
| 2480 } | 2490 } |
| 2481 | 2491 |
| 2482 // Returns the property details for the property at entry. | 2492 // Returns the property details for the property at entry. |
| 2483 PropertyDetails DetailsAt(int entry) { | 2493 PropertyDetails DetailsAt(int entry) { |
| 2484 ASSERT(entry >= 0); // Not found is -1, which is not caught by get(). | 2494 ASSERT(entry >= 0); // Not found is -1, which is not caught by get(). |
| 2485 return PropertyDetails( | 2495 return PropertyDetails( |
| 2486 Smi::cast(this->get(HashTable<Shape, Key>::EntryToIndex(entry) + 2))); | 2496 Smi::cast(this->get(HashTable<Shape, Key>::EntryToIndex(entry) + 2))); |
| 2487 } | 2497 } |
| 2488 | 2498 |
| 2489 // Set the details for entry. | 2499 // Set the details for entry. |
| (...skipping 4109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6599 } else { | 6609 } else { |
| 6600 value &= ~(1 << bit_position); | 6610 value &= ~(1 << bit_position); |
| 6601 } | 6611 } |
| 6602 return value; | 6612 return value; |
| 6603 } | 6613 } |
| 6604 }; | 6614 }; |
| 6605 | 6615 |
| 6606 } } // namespace v8::internal | 6616 } } // namespace v8::internal |
| 6607 | 6617 |
| 6608 #endif // V8_OBJECTS_H_ | 6618 #endif // V8_OBJECTS_H_ |
| OLD | NEW |