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 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 inline bool name(); \ | 657 inline bool name(); \ |
658 inline void set_##name(bool value); \ | 658 inline void set_##name(bool value); \ |
659 | 659 |
660 | 660 |
661 #define DECL_ACCESSORS(name, type) \ | 661 #define DECL_ACCESSORS(name, type) \ |
662 inline type* name(); \ | 662 inline type* name(); \ |
663 inline void set_##name(type* value, \ | 663 inline void set_##name(type* value, \ |
664 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \ | 664 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \ |
665 | 665 |
666 | 666 |
| 667 class AccessorPair; |
667 class DictionaryElementsAccessor; | 668 class DictionaryElementsAccessor; |
668 class ElementsAccessor; | 669 class ElementsAccessor; |
| 670 class Failure; |
669 class FixedArrayBase; | 671 class FixedArrayBase; |
670 class ObjectVisitor; | 672 class ObjectVisitor; |
671 class StringStream; | 673 class StringStream; |
672 class Failure; | |
673 | 674 |
674 struct ValueInfo : public Malloced { | 675 struct ValueInfo : public Malloced { |
675 ValueInfo() : type(FIRST_TYPE), ptr(NULL), str(NULL), number(0) { } | 676 ValueInfo() : type(FIRST_TYPE), ptr(NULL), str(NULL), number(0) { } |
676 InstanceType type; | 677 InstanceType type; |
677 Object* ptr; | 678 Object* ptr; |
678 const char* str; | 679 const char* str; |
679 double number; | 680 double number; |
680 }; | 681 }; |
681 | 682 |
682 | 683 |
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1601 | 1602 |
1602 static void DefineAccessor(Handle<JSObject> object, | 1603 static void DefineAccessor(Handle<JSObject> object, |
1603 Handle<String> name, | 1604 Handle<String> name, |
1604 Handle<Object> getter, | 1605 Handle<Object> getter, |
1605 Handle<Object> setter, | 1606 Handle<Object> setter, |
1606 PropertyAttributes attributes); | 1607 PropertyAttributes attributes); |
1607 MUST_USE_RESULT MaybeObject* DefineAccessor(String* name, | 1608 MUST_USE_RESULT MaybeObject* DefineAccessor(String* name, |
1608 Object* getter, | 1609 Object* getter, |
1609 Object* setter, | 1610 Object* setter, |
1610 PropertyAttributes attributes); | 1611 PropertyAttributes attributes); |
| 1612 // Try to define a single accessor paying attention to map transitions. |
| 1613 // Returns a JavaScript null if this was not possible and we have to use the |
| 1614 // slow case. Note that we can fail due to allocations, too. |
| 1615 MUST_USE_RESULT MaybeObject* DefineFastAccessor( |
| 1616 String* name, |
| 1617 AccessorComponent component, |
| 1618 Object* accessor, |
| 1619 PropertyAttributes attributes); |
1611 Object* LookupAccessor(String* name, AccessorComponent component); | 1620 Object* LookupAccessor(String* name, AccessorComponent component); |
1612 | 1621 |
1613 MUST_USE_RESULT MaybeObject* DefineAccessor(AccessorInfo* info); | 1622 MUST_USE_RESULT MaybeObject* DefineAccessor(AccessorInfo* info); |
1614 | 1623 |
1615 // Used from Object::GetProperty(). | 1624 // Used from Object::GetProperty(). |
1616 MUST_USE_RESULT MaybeObject* GetPropertyWithFailedAccessCheck( | 1625 MUST_USE_RESULT MaybeObject* GetPropertyWithFailedAccessCheck( |
1617 Object* receiver, | 1626 Object* receiver, |
1618 LookupResult* result, | 1627 LookupResult* result, |
1619 String* name, | 1628 String* name, |
1620 PropertyAttributes* attributes); | 1629 PropertyAttributes* attributes); |
(...skipping 6472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8093 // * a pointer to a map: a transition used to ensure map sharing | 8102 // * a pointer to a map: a transition used to ensure map sharing |
8094 class AccessorPair: public Struct { | 8103 class AccessorPair: public Struct { |
8095 public: | 8104 public: |
8096 DECL_ACCESSORS(getter, Object) | 8105 DECL_ACCESSORS(getter, Object) |
8097 DECL_ACCESSORS(setter, Object) | 8106 DECL_ACCESSORS(setter, Object) |
8098 | 8107 |
8099 static inline AccessorPair* cast(Object* obj); | 8108 static inline AccessorPair* cast(Object* obj); |
8100 | 8109 |
8101 MUST_USE_RESULT MaybeObject* CopyWithoutTransitions(); | 8110 MUST_USE_RESULT MaybeObject* CopyWithoutTransitions(); |
8102 | 8111 |
| 8112 Object* get(AccessorComponent component) { |
| 8113 return component == ACCESSOR_GETTER ? getter() : setter(); |
| 8114 } |
| 8115 |
| 8116 void set(AccessorComponent component, Object* value) { |
| 8117 if (component == ACCESSOR_GETTER) { |
| 8118 set_getter(value); |
| 8119 } else { |
| 8120 set_setter(value); |
| 8121 } |
| 8122 } |
| 8123 |
8103 // Note: Returns undefined instead in case of a hole. | 8124 // Note: Returns undefined instead in case of a hole. |
8104 Object* GetComponent(AccessorComponent component); | 8125 Object* GetComponent(AccessorComponent component); |
8105 | 8126 |
8106 // Set both components, skipping arguments which are a JavaScript null. | 8127 // Set both components, skipping arguments which are a JavaScript null. |
8107 void SetComponents(Object* getter, Object* setter) { | 8128 void SetComponents(Object* getter, Object* setter) { |
8108 if (!getter->IsNull()) set_getter(getter); | 8129 if (!getter->IsNull()) set_getter(getter); |
8109 if (!setter->IsNull()) set_setter(setter); | 8130 if (!setter->IsNull()) set_setter(setter); |
8110 } | 8131 } |
8111 | 8132 |
8112 bool ContainsAccessor() { | 8133 bool ContainsAccessor() { |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8628 } else { | 8649 } else { |
8629 value &= ~(1 << bit_position); | 8650 value &= ~(1 << bit_position); |
8630 } | 8651 } |
8631 return value; | 8652 return value; |
8632 } | 8653 } |
8633 }; | 8654 }; |
8634 | 8655 |
8635 } } // namespace v8::internal | 8656 } } // namespace v8::internal |
8636 | 8657 |
8637 #endif // V8_OBJECTS_H_ | 8658 #endif // V8_OBJECTS_H_ |
OLD | NEW |