OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 return !IsFailure() && ToObjectUnchecked()->IsTheHole(); | 439 return !IsFailure() && ToObjectUnchecked()->IsTheHole(); |
440 } | 440 } |
441 | 441 |
442 | 442 |
443 Failure* Failure::cast(MaybeObject* obj) { | 443 Failure* Failure::cast(MaybeObject* obj) { |
444 ASSERT(HAS_FAILURE_TAG(obj)); | 444 ASSERT(HAS_FAILURE_TAG(obj)); |
445 return reinterpret_cast<Failure*>(obj); | 445 return reinterpret_cast<Failure*>(obj); |
446 } | 446 } |
447 | 447 |
448 | 448 |
| 449 bool Object::IsJSReceiver() { |
| 450 return IsHeapObject() && |
| 451 HeapObject::cast(this)->map()->instance_type() >= FIRST_JS_RECEIVER_TYPE; |
| 452 } |
| 453 |
| 454 |
449 bool Object::IsJSObject() { | 455 bool Object::IsJSObject() { |
450 return IsHeapObject() | 456 return IsJSReceiver() && !IsJSProxy(); |
451 && HeapObject::cast(this)->map()->instance_type() >= FIRST_JS_OBJECT_TYPE; | |
452 } | 457 } |
453 | 458 |
454 | 459 |
| 460 bool Object::IsJSProxy() { |
| 461 return Object::IsHeapObject() && |
| 462 (HeapObject::cast(this)->map()->instance_type() == JS_PROXY_TYPE || |
| 463 HeapObject::cast(this)->map()->instance_type() == JS_FUNCTION_PROXY_TYPE); |
| 464 } |
| 465 |
| 466 |
| 467 bool Object::IsJSFunctionProxy() { |
| 468 return Object::IsHeapObject() && |
| 469 HeapObject::cast(this)->map()->instance_type() == JS_FUNCTION_PROXY_TYPE; |
| 470 } |
| 471 |
| 472 |
455 bool Object::IsJSContextExtensionObject() { | 473 bool Object::IsJSContextExtensionObject() { |
456 return IsHeapObject() | 474 return IsHeapObject() |
457 && (HeapObject::cast(this)->map()->instance_type() == | 475 && (HeapObject::cast(this)->map()->instance_type() == |
458 JS_CONTEXT_EXTENSION_OBJECT_TYPE); | 476 JS_CONTEXT_EXTENSION_OBJECT_TYPE); |
459 } | 477 } |
460 | 478 |
461 | 479 |
462 bool Object::IsMap() { | 480 bool Object::IsMap() { |
463 return Object::IsHeapObject() | 481 return Object::IsHeapObject() |
464 && HeapObject::cast(this)->map()->instance_type() == MAP_TYPE; | 482 && HeapObject::cast(this)->map()->instance_type() == MAP_TYPE; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 && (HeapObject::cast(this)->map()->instance_type() == | 595 && (HeapObject::cast(this)->map()->instance_type() == |
578 JS_MESSAGE_OBJECT_TYPE); | 596 JS_MESSAGE_OBJECT_TYPE); |
579 } | 597 } |
580 | 598 |
581 | 599 |
582 bool Object::IsStringWrapper() { | 600 bool Object::IsStringWrapper() { |
583 return IsJSValue() && JSValue::cast(this)->value()->IsString(); | 601 return IsJSValue() && JSValue::cast(this)->value()->IsString(); |
584 } | 602 } |
585 | 603 |
586 | 604 |
587 bool Object::IsJSProxy() { | |
588 return Object::IsHeapObject() | |
589 && HeapObject::cast(this)->map()->instance_type() == JS_PROXY_TYPE; | |
590 } | |
591 | |
592 | |
593 bool Object::IsForeign() { | 605 bool Object::IsForeign() { |
594 return Object::IsHeapObject() | 606 return Object::IsHeapObject() |
595 && HeapObject::cast(this)->map()->instance_type() == FOREIGN_TYPE; | 607 && HeapObject::cast(this)->map()->instance_type() == FOREIGN_TYPE; |
596 } | 608 } |
597 | 609 |
598 | 610 |
599 bool Object::IsBoolean() { | 611 bool Object::IsBoolean() { |
600 return IsOddball() && | 612 return IsOddball() && |
601 ((Oddball::cast(this)->kind() & Oddball::kNotBooleanMask) == 0); | 613 ((Oddball::cast(this)->kind() & Oddball::kNotBooleanMask) == 0); |
602 } | 614 } |
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1881 CAST_ACCESSOR(CodeCacheHashTable) | 1893 CAST_ACCESSOR(CodeCacheHashTable) |
1882 CAST_ACCESSOR(MapCache) | 1894 CAST_ACCESSOR(MapCache) |
1883 CAST_ACCESSOR(String) | 1895 CAST_ACCESSOR(String) |
1884 CAST_ACCESSOR(SeqString) | 1896 CAST_ACCESSOR(SeqString) |
1885 CAST_ACCESSOR(SeqAsciiString) | 1897 CAST_ACCESSOR(SeqAsciiString) |
1886 CAST_ACCESSOR(SeqTwoByteString) | 1898 CAST_ACCESSOR(SeqTwoByteString) |
1887 CAST_ACCESSOR(ConsString) | 1899 CAST_ACCESSOR(ConsString) |
1888 CAST_ACCESSOR(ExternalString) | 1900 CAST_ACCESSOR(ExternalString) |
1889 CAST_ACCESSOR(ExternalAsciiString) | 1901 CAST_ACCESSOR(ExternalAsciiString) |
1890 CAST_ACCESSOR(ExternalTwoByteString) | 1902 CAST_ACCESSOR(ExternalTwoByteString) |
| 1903 CAST_ACCESSOR(JSReceiver) |
1891 CAST_ACCESSOR(JSObject) | 1904 CAST_ACCESSOR(JSObject) |
1892 CAST_ACCESSOR(Smi) | 1905 CAST_ACCESSOR(Smi) |
1893 CAST_ACCESSOR(HeapObject) | 1906 CAST_ACCESSOR(HeapObject) |
1894 CAST_ACCESSOR(HeapNumber) | 1907 CAST_ACCESSOR(HeapNumber) |
1895 CAST_ACCESSOR(Oddball) | 1908 CAST_ACCESSOR(Oddball) |
1896 CAST_ACCESSOR(JSGlobalPropertyCell) | 1909 CAST_ACCESSOR(JSGlobalPropertyCell) |
1897 CAST_ACCESSOR(SharedFunctionInfo) | 1910 CAST_ACCESSOR(SharedFunctionInfo) |
1898 CAST_ACCESSOR(Map) | 1911 CAST_ACCESSOR(Map) |
1899 CAST_ACCESSOR(JSFunction) | 1912 CAST_ACCESSOR(JSFunction) |
1900 CAST_ACCESSOR(GlobalObject) | 1913 CAST_ACCESSOR(GlobalObject) |
1901 CAST_ACCESSOR(JSGlobalProxy) | 1914 CAST_ACCESSOR(JSGlobalProxy) |
1902 CAST_ACCESSOR(JSGlobalObject) | 1915 CAST_ACCESSOR(JSGlobalObject) |
1903 CAST_ACCESSOR(JSBuiltinsObject) | 1916 CAST_ACCESSOR(JSBuiltinsObject) |
1904 CAST_ACCESSOR(Code) | 1917 CAST_ACCESSOR(Code) |
1905 CAST_ACCESSOR(JSArray) | 1918 CAST_ACCESSOR(JSArray) |
1906 CAST_ACCESSOR(JSRegExp) | 1919 CAST_ACCESSOR(JSRegExp) |
1907 CAST_ACCESSOR(JSProxy) | 1920 CAST_ACCESSOR(JSProxy) |
| 1921 CAST_ACCESSOR(JSFunctionProxy) |
1908 CAST_ACCESSOR(Foreign) | 1922 CAST_ACCESSOR(Foreign) |
1909 CAST_ACCESSOR(ByteArray) | 1923 CAST_ACCESSOR(ByteArray) |
1910 CAST_ACCESSOR(ExternalArray) | 1924 CAST_ACCESSOR(ExternalArray) |
1911 CAST_ACCESSOR(ExternalByteArray) | 1925 CAST_ACCESSOR(ExternalByteArray) |
1912 CAST_ACCESSOR(ExternalUnsignedByteArray) | 1926 CAST_ACCESSOR(ExternalUnsignedByteArray) |
1913 CAST_ACCESSOR(ExternalShortArray) | 1927 CAST_ACCESSOR(ExternalShortArray) |
1914 CAST_ACCESSOR(ExternalUnsignedShortArray) | 1928 CAST_ACCESSOR(ExternalUnsignedShortArray) |
1915 CAST_ACCESSOR(ExternalIntArray) | 1929 CAST_ACCESSOR(ExternalIntArray) |
1916 CAST_ACCESSOR(ExternalUnsignedIntArray) | 1930 CAST_ACCESSOR(ExternalUnsignedIntArray) |
1917 CAST_ACCESSOR(ExternalFloatArray) | 1931 CAST_ACCESSOR(ExternalFloatArray) |
(...skipping 1991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3909 | 3923 |
3910 bool String::AsArrayIndex(uint32_t* index) { | 3924 bool String::AsArrayIndex(uint32_t* index) { |
3911 uint32_t field = hash_field(); | 3925 uint32_t field = hash_field(); |
3912 if (IsHashFieldComputed(field) && (field & kIsNotArrayIndexMask)) { | 3926 if (IsHashFieldComputed(field) && (field & kIsNotArrayIndexMask)) { |
3913 return false; | 3927 return false; |
3914 } | 3928 } |
3915 return SlowAsArrayIndex(index); | 3929 return SlowAsArrayIndex(index); |
3916 } | 3930 } |
3917 | 3931 |
3918 | 3932 |
3919 Object* JSObject::GetPrototype() { | 3933 Object* JSReceiver::GetPrototype() { |
3920 return JSObject::cast(this)->map()->prototype(); | 3934 return HeapObject::cast(this)->map()->prototype(); |
3921 } | 3935 } |
3922 | 3936 |
3923 | 3937 |
3924 PropertyAttributes JSObject::GetPropertyAttribute(String* key) { | 3938 PropertyAttributes JSReceiver::GetPropertyAttribute(String* key) { |
3925 return GetPropertyAttributeWithReceiver(this, key); | 3939 return GetPropertyAttributeWithReceiver(this, key); |
3926 } | 3940 } |
3927 | 3941 |
3928 // TODO(504): this may be useful in other places too where JSGlobalProxy | 3942 // TODO(504): this may be useful in other places too where JSGlobalProxy |
3929 // is used. | 3943 // is used. |
3930 Object* JSObject::BypassGlobalProxy() { | 3944 Object* JSObject::BypassGlobalProxy() { |
3931 if (IsJSGlobalProxy()) { | 3945 if (IsJSGlobalProxy()) { |
3932 Object* proto = GetPrototype(); | 3946 Object* proto = GetPrototype(); |
3933 if (proto->IsNull()) return GetHeap()->undefined_value(); | 3947 if (proto->IsNull()) return GetHeap()->undefined_value(); |
3934 ASSERT(proto->IsJSGlobalObject()); | 3948 ASSERT(proto->IsJSGlobalObject()); |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4228 #undef WRITE_INT_FIELD | 4242 #undef WRITE_INT_FIELD |
4229 #undef READ_SHORT_FIELD | 4243 #undef READ_SHORT_FIELD |
4230 #undef WRITE_SHORT_FIELD | 4244 #undef WRITE_SHORT_FIELD |
4231 #undef READ_BYTE_FIELD | 4245 #undef READ_BYTE_FIELD |
4232 #undef WRITE_BYTE_FIELD | 4246 #undef WRITE_BYTE_FIELD |
4233 | 4247 |
4234 | 4248 |
4235 } } // namespace v8::internal | 4249 } } // namespace v8::internal |
4236 | 4250 |
4237 #endif // V8_OBJECTS_INL_H_ | 4251 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |