OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 inline bool name(); \ | 697 inline bool name(); \ |
698 inline void set_##name(bool value); \ | 698 inline void set_##name(bool value); \ |
699 | 699 |
700 | 700 |
701 #define DECL_ACCESSORS(name, type) \ | 701 #define DECL_ACCESSORS(name, type) \ |
702 inline type* name(); \ | 702 inline type* name(); \ |
703 inline void set_##name(type* value, \ | 703 inline void set_##name(type* value, \ |
704 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \ | 704 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \ |
705 | 705 |
706 | 706 |
707 class AccessorPair; | |
708 class DictionaryElementsAccessor; | 707 class DictionaryElementsAccessor; |
709 class ElementsAccessor; | 708 class ElementsAccessor; |
710 class Failure; | |
711 class FixedArrayBase; | 709 class FixedArrayBase; |
712 class ObjectVisitor; | 710 class ObjectVisitor; |
713 class StringStream; | 711 class StringStream; |
| 712 class Failure; |
714 | 713 |
715 struct ValueInfo : public Malloced { | 714 struct ValueInfo : public Malloced { |
716 ValueInfo() : type(FIRST_TYPE), ptr(NULL), str(NULL), number(0) { } | 715 ValueInfo() : type(FIRST_TYPE), ptr(NULL), str(NULL), number(0) { } |
717 InstanceType type; | 716 InstanceType type; |
718 Object* ptr; | 717 Object* ptr; |
719 const char* str; | 718 const char* str; |
720 double number; | 719 double number; |
721 }; | 720 }; |
722 | 721 |
723 | 722 |
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1636 | 1635 |
1637 static void DefineAccessor(Handle<JSObject> object, | 1636 static void DefineAccessor(Handle<JSObject> object, |
1638 Handle<String> name, | 1637 Handle<String> name, |
1639 Handle<Object> getter, | 1638 Handle<Object> getter, |
1640 Handle<Object> setter, | 1639 Handle<Object> setter, |
1641 PropertyAttributes attributes); | 1640 PropertyAttributes attributes); |
1642 MUST_USE_RESULT MaybeObject* DefineAccessor(String* name, | 1641 MUST_USE_RESULT MaybeObject* DefineAccessor(String* name, |
1643 Object* getter, | 1642 Object* getter, |
1644 Object* setter, | 1643 Object* setter, |
1645 PropertyAttributes attributes); | 1644 PropertyAttributes attributes); |
1646 // Try to define a single accessor paying attention to map transitions. | |
1647 // Returns a JavaScript null if this was not possible and we have to use the | |
1648 // slow case. Note that we can fail due to allocations, too. | |
1649 MUST_USE_RESULT MaybeObject* DefineFastAccessor( | |
1650 String* name, | |
1651 AccessorComponent component, | |
1652 Object* accessor, | |
1653 PropertyAttributes attributes); | |
1654 Object* LookupAccessor(String* name, AccessorComponent component); | 1645 Object* LookupAccessor(String* name, AccessorComponent component); |
1655 | 1646 |
1656 MUST_USE_RESULT MaybeObject* DefineAccessor(AccessorInfo* info); | 1647 MUST_USE_RESULT MaybeObject* DefineAccessor(AccessorInfo* info); |
1657 | 1648 |
1658 // Used from Object::GetProperty(). | 1649 // Used from Object::GetProperty(). |
1659 MUST_USE_RESULT MaybeObject* GetPropertyWithFailedAccessCheck( | 1650 MUST_USE_RESULT MaybeObject* GetPropertyWithFailedAccessCheck( |
1660 Object* receiver, | 1651 Object* receiver, |
1661 LookupResult* result, | 1652 LookupResult* result, |
1662 String* name, | 1653 String* name, |
1663 PropertyAttributes* attributes); | 1654 PropertyAttributes* attributes); |
(...skipping 6457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8121 // * a pointer to a map: a transition used to ensure map sharing | 8112 // * a pointer to a map: a transition used to ensure map sharing |
8122 class AccessorPair: public Struct { | 8113 class AccessorPair: public Struct { |
8123 public: | 8114 public: |
8124 DECL_ACCESSORS(getter, Object) | 8115 DECL_ACCESSORS(getter, Object) |
8125 DECL_ACCESSORS(setter, Object) | 8116 DECL_ACCESSORS(setter, Object) |
8126 | 8117 |
8127 static inline AccessorPair* cast(Object* obj); | 8118 static inline AccessorPair* cast(Object* obj); |
8128 | 8119 |
8129 MUST_USE_RESULT MaybeObject* CopyWithoutTransitions(); | 8120 MUST_USE_RESULT MaybeObject* CopyWithoutTransitions(); |
8130 | 8121 |
8131 Object* get(AccessorComponent component) { | |
8132 return component == ACCESSOR_GETTER ? getter() : setter(); | |
8133 } | |
8134 | |
8135 void set(AccessorComponent component, Object* value) { | |
8136 if (component == ACCESSOR_GETTER) { | |
8137 set_getter(value); | |
8138 } else { | |
8139 set_setter(value); | |
8140 } | |
8141 } | |
8142 | |
8143 // Note: Returns undefined instead in case of a hole. | 8122 // Note: Returns undefined instead in case of a hole. |
8144 Object* GetComponent(AccessorComponent component); | 8123 Object* GetComponent(AccessorComponent component); |
8145 | 8124 |
8146 // Set both components, skipping arguments which are a JavaScript null. | 8125 // Set both components, skipping arguments which are a JavaScript null. |
8147 void SetComponents(Object* getter, Object* setter) { | 8126 void SetComponents(Object* getter, Object* setter) { |
8148 if (!getter->IsNull()) set_getter(getter); | 8127 if (!getter->IsNull()) set_getter(getter); |
8149 if (!setter->IsNull()) set_setter(setter); | 8128 if (!setter->IsNull()) set_setter(setter); |
8150 } | 8129 } |
8151 | 8130 |
8152 bool ContainsAccessor() { | 8131 bool ContainsAccessor() { |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8668 } else { | 8647 } else { |
8669 value &= ~(1 << bit_position); | 8648 value &= ~(1 << bit_position); |
8670 } | 8649 } |
8671 return value; | 8650 return value; |
8672 } | 8651 } |
8673 }; | 8652 }; |
8674 | 8653 |
8675 } } // namespace v8::internal | 8654 } } // namespace v8::internal |
8676 | 8655 |
8677 #endif // V8_OBJECTS_H_ | 8656 #endif // V8_OBJECTS_H_ |
OLD | NEW |