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; |
707 class DictionaryElementsAccessor; | 708 class DictionaryElementsAccessor; |
708 class ElementsAccessor; | 709 class ElementsAccessor; |
| 710 class Failure; |
709 class FixedArrayBase; | 711 class FixedArrayBase; |
710 class ObjectVisitor; | 712 class ObjectVisitor; |
711 class StringStream; | 713 class StringStream; |
712 class Failure; | |
713 | 714 |
714 struct ValueInfo : public Malloced { | 715 struct ValueInfo : public Malloced { |
715 ValueInfo() : type(FIRST_TYPE), ptr(NULL), str(NULL), number(0) { } | 716 ValueInfo() : type(FIRST_TYPE), ptr(NULL), str(NULL), number(0) { } |
716 InstanceType type; | 717 InstanceType type; |
717 Object* ptr; | 718 Object* ptr; |
718 const char* str; | 719 const char* str; |
719 double number; | 720 double number; |
720 }; | 721 }; |
721 | 722 |
722 | 723 |
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1635 | 1636 |
1636 static void DefineAccessor(Handle<JSObject> object, | 1637 static void DefineAccessor(Handle<JSObject> object, |
1637 Handle<String> name, | 1638 Handle<String> name, |
1638 Handle<Object> getter, | 1639 Handle<Object> getter, |
1639 Handle<Object> setter, | 1640 Handle<Object> setter, |
1640 PropertyAttributes attributes); | 1641 PropertyAttributes attributes); |
1641 MUST_USE_RESULT MaybeObject* DefineAccessor(String* name, | 1642 MUST_USE_RESULT MaybeObject* DefineAccessor(String* name, |
1642 Object* getter, | 1643 Object* getter, |
1643 Object* setter, | 1644 Object* setter, |
1644 PropertyAttributes attributes); | 1645 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); |
1645 Object* LookupAccessor(String* name, AccessorComponent component); | 1654 Object* LookupAccessor(String* name, AccessorComponent component); |
1646 | 1655 |
1647 MUST_USE_RESULT MaybeObject* DefineAccessor(AccessorInfo* info); | 1656 MUST_USE_RESULT MaybeObject* DefineAccessor(AccessorInfo* info); |
1648 | 1657 |
1649 // Used from Object::GetProperty(). | 1658 // Used from Object::GetProperty(). |
1650 MUST_USE_RESULT MaybeObject* GetPropertyWithFailedAccessCheck( | 1659 MUST_USE_RESULT MaybeObject* GetPropertyWithFailedAccessCheck( |
1651 Object* receiver, | 1660 Object* receiver, |
1652 LookupResult* result, | 1661 LookupResult* result, |
1653 String* name, | 1662 String* name, |
1654 PropertyAttributes* attributes); | 1663 PropertyAttributes* attributes); |
(...skipping 6439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8094 // * a pointer to a map: a transition used to ensure map sharing | 8103 // * a pointer to a map: a transition used to ensure map sharing |
8095 class AccessorPair: public Struct { | 8104 class AccessorPair: public Struct { |
8096 public: | 8105 public: |
8097 DECL_ACCESSORS(getter, Object) | 8106 DECL_ACCESSORS(getter, Object) |
8098 DECL_ACCESSORS(setter, Object) | 8107 DECL_ACCESSORS(setter, Object) |
8099 | 8108 |
8100 static inline AccessorPair* cast(Object* obj); | 8109 static inline AccessorPair* cast(Object* obj); |
8101 | 8110 |
8102 MUST_USE_RESULT MaybeObject* CopyWithoutTransitions(); | 8111 MUST_USE_RESULT MaybeObject* CopyWithoutTransitions(); |
8103 | 8112 |
| 8113 Object* get(AccessorComponent component) { |
| 8114 return component == ACCESSOR_GETTER ? getter() : setter(); |
| 8115 } |
| 8116 |
| 8117 void set(AccessorComponent component, Object* value) { |
| 8118 if (component == ACCESSOR_GETTER) { |
| 8119 set_getter(value); |
| 8120 } else { |
| 8121 set_setter(value); |
| 8122 } |
| 8123 } |
| 8124 |
8104 // Note: Returns undefined instead in case of a hole. | 8125 // Note: Returns undefined instead in case of a hole. |
8105 Object* GetComponent(AccessorComponent component); | 8126 Object* GetComponent(AccessorComponent component); |
8106 | 8127 |
8107 // Set both components, skipping arguments which are a JavaScript null. | 8128 // Set both components, skipping arguments which are a JavaScript null. |
8108 void SetComponents(Object* getter, Object* setter) { | 8129 void SetComponents(Object* getter, Object* setter) { |
8109 if (!getter->IsNull()) set_getter(getter); | 8130 if (!getter->IsNull()) set_getter(getter); |
8110 if (!setter->IsNull()) set_setter(setter); | 8131 if (!setter->IsNull()) set_setter(setter); |
8111 } | 8132 } |
8112 | 8133 |
8113 bool ContainsAccessor() { | 8134 bool ContainsAccessor() { |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8629 } else { | 8650 } else { |
8630 value &= ~(1 << bit_position); | 8651 value &= ~(1 << bit_position); |
8631 } | 8652 } |
8632 return value; | 8653 return value; |
8633 } | 8654 } |
8634 }; | 8655 }; |
8635 | 8656 |
8636 } } // namespace v8::internal | 8657 } } // namespace v8::internal |
8637 | 8658 |
8638 #endif // V8_OBJECTS_H_ | 8659 #endif // V8_OBJECTS_H_ |
OLD | NEW |