 Chromium Code Reviews
 Chromium Code Reviews Issue 10238005:
  Use map transitions when defining accessor properties.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
    
  
    Issue 10238005:
  Use map transitions when defining accessor properties.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge| 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 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 DictionaryElementsAccessor; | 707 class DictionaryElementsAccessor; | 
| 708 class ElementsAccessor; | 708 class ElementsAccessor; | 
| 709 class FixedArrayBase; | 709 class FixedArrayBase; | 
| 710 class ObjectVisitor; | 710 class ObjectVisitor; | 
| 711 class StringStream; | 711 class StringStream; | 
| 712 class Failure; | 712 class Failure; | 
| 713 class AccessorPair; | |
| 
Michael Starzinger
2012/05/02 13:30:14
Can we alpha-sort this?
 
Sven Panne
2012/05/03 09:39:02
Done.
 | |
| 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); | |
| 1654 MUST_USE_RESULT MaybeObject* CreateFreshAccessor( | |
| 1655 String* name, | |
| 1656 AccessorComponent component, | |
| 1657 Object* accessor, | |
| 1658 PropertyAttributes attributes); | |
| 1659 MUST_USE_RESULT MaybeObject* NewCallbackTrans( | |
| 1660 String* name, | |
| 1661 AccessorComponent component, | |
| 1662 Object* accessor, | |
| 1663 PropertyAttributes attributes, | |
| 1664 AccessorPair* accessors2); | |
| 1645 Object* LookupAccessor(String* name, AccessorComponent component); | 1665 Object* LookupAccessor(String* name, AccessorComponent component); | 
| 1646 | 1666 | 
| 1647 MUST_USE_RESULT MaybeObject* DefineAccessor(AccessorInfo* info); | 1667 MUST_USE_RESULT MaybeObject* DefineAccessor(AccessorInfo* info); | 
| 1648 | 1668 | 
| 1649 // Used from Object::GetProperty(). | 1669 // Used from Object::GetProperty(). | 
| 1650 MUST_USE_RESULT MaybeObject* GetPropertyWithFailedAccessCheck( | 1670 MUST_USE_RESULT MaybeObject* GetPropertyWithFailedAccessCheck( | 
| 1651 Object* receiver, | 1671 Object* receiver, | 
| 1652 LookupResult* result, | 1672 LookupResult* result, | 
| 1653 String* name, | 1673 String* name, | 
| 1654 PropertyAttributes* attributes); | 1674 PropertyAttributes* attributes); | 
| (...skipping 6446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8101 // * a pointer to a map: a transition used to ensure map sharing | 8121 // * a pointer to a map: a transition used to ensure map sharing | 
| 8102 class AccessorPair: public Struct { | 8122 class AccessorPair: public Struct { | 
| 8103 public: | 8123 public: | 
| 8104 DECL_ACCESSORS(getter, Object) | 8124 DECL_ACCESSORS(getter, Object) | 
| 8105 DECL_ACCESSORS(setter, Object) | 8125 DECL_ACCESSORS(setter, Object) | 
| 8106 | 8126 | 
| 8107 static inline AccessorPair* cast(Object* obj); | 8127 static inline AccessorPair* cast(Object* obj); | 
| 8108 | 8128 | 
| 8109 MUST_USE_RESULT MaybeObject* CopyWithoutTransitions(); | 8129 MUST_USE_RESULT MaybeObject* CopyWithoutTransitions(); | 
| 8110 | 8130 | 
| 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 | |
| 8111 // Note: Returns undefined instead in case of a hole. | 8143 // Note: Returns undefined instead in case of a hole. | 
| 8112 Object* GetComponent(AccessorComponent component); | 8144 Object* GetComponent(AccessorComponent component); | 
| 8113 | 8145 | 
| 8114 // Set both components, skipping arguments which are a JavaScript null. | 8146 // Set both components, skipping arguments which are a JavaScript null. | 
| 8115 void SetComponents(Object* getter, Object* setter) { | 8147 void SetComponents(Object* getter, Object* setter) { | 
| 8116 if (!getter->IsNull()) set_getter(getter); | 8148 if (!getter->IsNull()) set_getter(getter); | 
| 8117 if (!setter->IsNull()) set_setter(setter); | 8149 if (!setter->IsNull()) set_setter(setter); | 
| 8118 } | 8150 } | 
| 8119 | 8151 | 
| 8120 bool ContainsAccessor() { | 8152 bool ContainsAccessor() { | 
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8636 } else { | 8668 } else { | 
| 8637 value &= ~(1 << bit_position); | 8669 value &= ~(1 << bit_position); | 
| 8638 } | 8670 } | 
| 8639 return value; | 8671 return value; | 
| 8640 } | 8672 } | 
| 8641 }; | 8673 }; | 
| 8642 | 8674 | 
| 8643 } } // namespace v8::internal | 8675 } } // namespace v8::internal | 
| 8644 | 8676 | 
| 8645 #endif // V8_OBJECTS_H_ | 8677 #endif // V8_OBJECTS_H_ | 
| OLD | NEW |