| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
| 6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
| 7 | 7 |
| 8 #include "allocation.h" | 8 #include "allocation.h" |
| 9 #include "assert-scope.h" | 9 #include "assert-scope.h" |
| 10 #include "builtins.h" | 10 #include "builtins.h" |
| (...skipping 2423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2434 inline int GetInternalFieldOffset(int index); | 2434 inline int GetInternalFieldOffset(int index); |
| 2435 inline Object* GetInternalField(int index); | 2435 inline Object* GetInternalField(int index); |
| 2436 inline void SetInternalField(int index, Object* value); | 2436 inline void SetInternalField(int index, Object* value); |
| 2437 inline void SetInternalField(int index, Smi* value); | 2437 inline void SetInternalField(int index, Smi* value); |
| 2438 | 2438 |
| 2439 // The following lookup functions skip interceptors. | 2439 // The following lookup functions skip interceptors. |
| 2440 void LookupOwnRealNamedProperty(Handle<Name> name, LookupResult* result); | 2440 void LookupOwnRealNamedProperty(Handle<Name> name, LookupResult* result); |
| 2441 void LookupRealNamedProperty(Handle<Name> name, LookupResult* result); | 2441 void LookupRealNamedProperty(Handle<Name> name, LookupResult* result); |
| 2442 void LookupRealNamedPropertyInPrototypes(Handle<Name> name, | 2442 void LookupRealNamedPropertyInPrototypes(Handle<Name> name, |
| 2443 LookupResult* result); | 2443 LookupResult* result); |
| 2444 void LookupCallbackProperty(Handle<Name> name, LookupResult* result); | |
| 2445 | 2444 |
| 2446 // Returns the number of properties on this object filtering out properties | 2445 // Returns the number of properties on this object filtering out properties |
| 2447 // with the specified attributes (ignoring interceptors). | 2446 // with the specified attributes (ignoring interceptors). |
| 2448 int NumberOfOwnProperties(PropertyAttributes filter = NONE); | 2447 int NumberOfOwnProperties(PropertyAttributes filter = NONE); |
| 2449 // Fill in details for properties into storage starting at the specified | 2448 // Fill in details for properties into storage starting at the specified |
| 2450 // index. | 2449 // index. |
| 2451 void GetOwnPropertyNames( | 2450 void GetOwnPropertyNames( |
| 2452 FixedArray* storage, int index, PropertyAttributes filter = NONE); | 2451 FixedArray* storage, int index, PropertyAttributes filter = NONE); |
| 2453 | 2452 |
| 2454 // Returns the number of properties on this object filtering out properties | 2453 // Returns the number of properties on this object filtering out properties |
| (...skipping 7911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10366 DECL_ACCESSORS(name, Object) | 10365 DECL_ACCESSORS(name, Object) |
| 10367 DECL_ACCESSORS(flag, Smi) | 10366 DECL_ACCESSORS(flag, Smi) |
| 10368 DECL_ACCESSORS(expected_receiver_type, Object) | 10367 DECL_ACCESSORS(expected_receiver_type, Object) |
| 10369 | 10368 |
| 10370 inline bool all_can_read(); | 10369 inline bool all_can_read(); |
| 10371 inline void set_all_can_read(bool value); | 10370 inline void set_all_can_read(bool value); |
| 10372 | 10371 |
| 10373 inline bool all_can_write(); | 10372 inline bool all_can_write(); |
| 10374 inline void set_all_can_write(bool value); | 10373 inline void set_all_can_write(bool value); |
| 10375 | 10374 |
| 10376 inline bool prohibits_overwriting(); | |
| 10377 inline void set_prohibits_overwriting(bool value); | |
| 10378 | |
| 10379 inline PropertyAttributes property_attributes(); | 10375 inline PropertyAttributes property_attributes(); |
| 10380 inline void set_property_attributes(PropertyAttributes attributes); | 10376 inline void set_property_attributes(PropertyAttributes attributes); |
| 10381 | 10377 |
| 10382 // Checks whether the given receiver is compatible with this accessor. | 10378 // Checks whether the given receiver is compatible with this accessor. |
| 10383 inline bool IsCompatibleReceiver(Object* receiver); | 10379 inline bool IsCompatibleReceiver(Object* receiver); |
| 10384 | 10380 |
| 10385 static inline AccessorInfo* cast(Object* obj); | 10381 static inline AccessorInfo* cast(Object* obj); |
| 10386 | 10382 |
| 10387 // Dispatched behavior. | 10383 // Dispatched behavior. |
| 10388 DECLARE_VERIFIER(AccessorInfo) | 10384 DECLARE_VERIFIER(AccessorInfo) |
| 10389 | 10385 |
| 10390 // Append all descriptors to the array that are not already there. | 10386 // Append all descriptors to the array that are not already there. |
| 10391 // Return number added. | 10387 // Return number added. |
| 10392 static int AppendUnique(Handle<Object> descriptors, | 10388 static int AppendUnique(Handle<Object> descriptors, |
| 10393 Handle<FixedArray> array, | 10389 Handle<FixedArray> array, |
| 10394 int valid_descriptors); | 10390 int valid_descriptors); |
| 10395 | 10391 |
| 10396 static const int kNameOffset = HeapObject::kHeaderSize; | 10392 static const int kNameOffset = HeapObject::kHeaderSize; |
| 10397 static const int kFlagOffset = kNameOffset + kPointerSize; | 10393 static const int kFlagOffset = kNameOffset + kPointerSize; |
| 10398 static const int kExpectedReceiverTypeOffset = kFlagOffset + kPointerSize; | 10394 static const int kExpectedReceiverTypeOffset = kFlagOffset + kPointerSize; |
| 10399 static const int kSize = kExpectedReceiverTypeOffset + kPointerSize; | 10395 static const int kSize = kExpectedReceiverTypeOffset + kPointerSize; |
| 10400 | 10396 |
| 10401 private: | 10397 private: |
| 10402 // Bit positions in flag. | 10398 // Bit positions in flag. |
| 10403 static const int kAllCanReadBit = 0; | 10399 static const int kAllCanReadBit = 0; |
| 10404 static const int kAllCanWriteBit = 1; | 10400 static const int kAllCanWriteBit = 1; |
| 10405 static const int kProhibitsOverwritingBit = 2; | 10401 class AttributesField: public BitField<PropertyAttributes, 2, 3> {}; |
| 10406 class AttributesField: public BitField<PropertyAttributes, 3, 3> {}; | |
| 10407 | 10402 |
| 10408 DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorInfo); | 10403 DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorInfo); |
| 10409 }; | 10404 }; |
| 10410 | 10405 |
| 10411 | 10406 |
| 10412 enum AccessorDescriptorType { | 10407 enum AccessorDescriptorType { |
| 10413 kDescriptorBitmaskCompare, | 10408 kDescriptorBitmaskCompare, |
| 10414 kDescriptorPointerCompare, | 10409 kDescriptorPointerCompare, |
| 10415 kDescriptorPrimitiveValue, | 10410 kDescriptorPrimitiveValue, |
| 10416 kDescriptorObjectDereference, | 10411 kDescriptorObjectDereference, |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10561 // failure. | 10556 // failure. |
| 10562 class AccessorPair: public Struct { | 10557 class AccessorPair: public Struct { |
| 10563 public: | 10558 public: |
| 10564 DECL_ACCESSORS(getter, Object) | 10559 DECL_ACCESSORS(getter, Object) |
| 10565 DECL_ACCESSORS(setter, Object) | 10560 DECL_ACCESSORS(setter, Object) |
| 10566 DECL_ACCESSORS(access_flags, Smi) | 10561 DECL_ACCESSORS(access_flags, Smi) |
| 10567 | 10562 |
| 10568 inline void set_access_flags(v8::AccessControl access_control); | 10563 inline void set_access_flags(v8::AccessControl access_control); |
| 10569 inline bool all_can_read(); | 10564 inline bool all_can_read(); |
| 10570 inline bool all_can_write(); | 10565 inline bool all_can_write(); |
| 10571 inline bool prohibits_overwriting(); | |
| 10572 | 10566 |
| 10573 static inline AccessorPair* cast(Object* obj); | 10567 static inline AccessorPair* cast(Object* obj); |
| 10574 | 10568 |
| 10575 static Handle<AccessorPair> Copy(Handle<AccessorPair> pair); | 10569 static Handle<AccessorPair> Copy(Handle<AccessorPair> pair); |
| 10576 | 10570 |
| 10577 Object* get(AccessorComponent component) { | 10571 Object* get(AccessorComponent component) { |
| 10578 return component == ACCESSOR_GETTER ? getter() : setter(); | 10572 return component == ACCESSOR_GETTER ? getter() : setter(); |
| 10579 } | 10573 } |
| 10580 | 10574 |
| 10581 void set(AccessorComponent component, Object* value) { | 10575 void set(AccessorComponent component, Object* value) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 10604 DECLARE_VERIFIER(AccessorPair) | 10598 DECLARE_VERIFIER(AccessorPair) |
| 10605 | 10599 |
| 10606 static const int kGetterOffset = HeapObject::kHeaderSize; | 10600 static const int kGetterOffset = HeapObject::kHeaderSize; |
| 10607 static const int kSetterOffset = kGetterOffset + kPointerSize; | 10601 static const int kSetterOffset = kGetterOffset + kPointerSize; |
| 10608 static const int kAccessFlagsOffset = kSetterOffset + kPointerSize; | 10602 static const int kAccessFlagsOffset = kSetterOffset + kPointerSize; |
| 10609 static const int kSize = kAccessFlagsOffset + kPointerSize; | 10603 static const int kSize = kAccessFlagsOffset + kPointerSize; |
| 10610 | 10604 |
| 10611 private: | 10605 private: |
| 10612 static const int kAllCanReadBit = 0; | 10606 static const int kAllCanReadBit = 0; |
| 10613 static const int kAllCanWriteBit = 1; | 10607 static const int kAllCanWriteBit = 1; |
| 10614 static const int kProhibitsOverwritingBit = 2; | |
| 10615 | 10608 |
| 10616 // Strangely enough, in addition to functions and harmony proxies, the spec | 10609 // Strangely enough, in addition to functions and harmony proxies, the spec |
| 10617 // requires us to consider undefined as a kind of accessor, too: | 10610 // requires us to consider undefined as a kind of accessor, too: |
| 10618 // var obj = {}; | 10611 // var obj = {}; |
| 10619 // Object.defineProperty(obj, "foo", {get: undefined}); | 10612 // Object.defineProperty(obj, "foo", {get: undefined}); |
| 10620 // assertTrue("foo" in obj); | 10613 // assertTrue("foo" in obj); |
| 10621 bool IsJSAccessor(Object* obj) { | 10614 bool IsJSAccessor(Object* obj) { |
| 10622 return obj->IsSpecFunction() || obj->IsUndefined(); | 10615 return obj->IsSpecFunction() || obj->IsUndefined(); |
| 10623 } | 10616 } |
| 10624 | 10617 |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11074 } else { | 11067 } else { |
| 11075 value &= ~(1 << bit_position); | 11068 value &= ~(1 << bit_position); |
| 11076 } | 11069 } |
| 11077 return value; | 11070 return value; |
| 11078 } | 11071 } |
| 11079 }; | 11072 }; |
| 11080 | 11073 |
| 11081 } } // namespace v8::internal | 11074 } } // namespace v8::internal |
| 11082 | 11075 |
| 11083 #endif // V8_OBJECTS_H_ | 11076 #endif // V8_OBJECTS_H_ |
| OLD | NEW |