Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/objects-inl.h

Issue 6992072: Implement set trap for proxies, and revamp class hierarchy in preparation (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.cc ('k') | src/proxy.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1893 CAST_ACCESSOR(CodeCacheHashTable) 1905 CAST_ACCESSOR(CodeCacheHashTable)
1894 CAST_ACCESSOR(MapCache) 1906 CAST_ACCESSOR(MapCache)
1895 CAST_ACCESSOR(String) 1907 CAST_ACCESSOR(String)
1896 CAST_ACCESSOR(SeqString) 1908 CAST_ACCESSOR(SeqString)
1897 CAST_ACCESSOR(SeqAsciiString) 1909 CAST_ACCESSOR(SeqAsciiString)
1898 CAST_ACCESSOR(SeqTwoByteString) 1910 CAST_ACCESSOR(SeqTwoByteString)
1899 CAST_ACCESSOR(ConsString) 1911 CAST_ACCESSOR(ConsString)
1900 CAST_ACCESSOR(ExternalString) 1912 CAST_ACCESSOR(ExternalString)
1901 CAST_ACCESSOR(ExternalAsciiString) 1913 CAST_ACCESSOR(ExternalAsciiString)
1902 CAST_ACCESSOR(ExternalTwoByteString) 1914 CAST_ACCESSOR(ExternalTwoByteString)
1915 CAST_ACCESSOR(JSReceiver)
1903 CAST_ACCESSOR(JSObject) 1916 CAST_ACCESSOR(JSObject)
1904 CAST_ACCESSOR(Smi) 1917 CAST_ACCESSOR(Smi)
1905 CAST_ACCESSOR(HeapObject) 1918 CAST_ACCESSOR(HeapObject)
1906 CAST_ACCESSOR(HeapNumber) 1919 CAST_ACCESSOR(HeapNumber)
1907 CAST_ACCESSOR(Oddball) 1920 CAST_ACCESSOR(Oddball)
1908 CAST_ACCESSOR(JSGlobalPropertyCell) 1921 CAST_ACCESSOR(JSGlobalPropertyCell)
1909 CAST_ACCESSOR(SharedFunctionInfo) 1922 CAST_ACCESSOR(SharedFunctionInfo)
1910 CAST_ACCESSOR(Map) 1923 CAST_ACCESSOR(Map)
1911 CAST_ACCESSOR(JSFunction) 1924 CAST_ACCESSOR(JSFunction)
1912 CAST_ACCESSOR(GlobalObject) 1925 CAST_ACCESSOR(GlobalObject)
1913 CAST_ACCESSOR(JSGlobalProxy) 1926 CAST_ACCESSOR(JSGlobalProxy)
1914 CAST_ACCESSOR(JSGlobalObject) 1927 CAST_ACCESSOR(JSGlobalObject)
1915 CAST_ACCESSOR(JSBuiltinsObject) 1928 CAST_ACCESSOR(JSBuiltinsObject)
1916 CAST_ACCESSOR(Code) 1929 CAST_ACCESSOR(Code)
1917 CAST_ACCESSOR(JSArray) 1930 CAST_ACCESSOR(JSArray)
1918 CAST_ACCESSOR(JSRegExp) 1931 CAST_ACCESSOR(JSRegExp)
1919 CAST_ACCESSOR(JSProxy) 1932 CAST_ACCESSOR(JSProxy)
1933 CAST_ACCESSOR(JSFunctionProxy)
1920 CAST_ACCESSOR(Foreign) 1934 CAST_ACCESSOR(Foreign)
1921 CAST_ACCESSOR(ByteArray) 1935 CAST_ACCESSOR(ByteArray)
1922 CAST_ACCESSOR(ExternalArray) 1936 CAST_ACCESSOR(ExternalArray)
1923 CAST_ACCESSOR(ExternalByteArray) 1937 CAST_ACCESSOR(ExternalByteArray)
1924 CAST_ACCESSOR(ExternalUnsignedByteArray) 1938 CAST_ACCESSOR(ExternalUnsignedByteArray)
1925 CAST_ACCESSOR(ExternalShortArray) 1939 CAST_ACCESSOR(ExternalShortArray)
1926 CAST_ACCESSOR(ExternalUnsignedShortArray) 1940 CAST_ACCESSOR(ExternalUnsignedShortArray)
1927 CAST_ACCESSOR(ExternalIntArray) 1941 CAST_ACCESSOR(ExternalIntArray)
1928 CAST_ACCESSOR(ExternalUnsignedIntArray) 1942 CAST_ACCESSOR(ExternalUnsignedIntArray)
1929 CAST_ACCESSOR(ExternalFloatArray) 1943 CAST_ACCESSOR(ExternalFloatArray)
(...skipping 2065 matching lines...) Expand 10 before | Expand all | Expand 10 after
3995 4009
3996 bool String::AsArrayIndex(uint32_t* index) { 4010 bool String::AsArrayIndex(uint32_t* index) {
3997 uint32_t field = hash_field(); 4011 uint32_t field = hash_field();
3998 if (IsHashFieldComputed(field) && (field & kIsNotArrayIndexMask)) { 4012 if (IsHashFieldComputed(field) && (field & kIsNotArrayIndexMask)) {
3999 return false; 4013 return false;
4000 } 4014 }
4001 return SlowAsArrayIndex(index); 4015 return SlowAsArrayIndex(index);
4002 } 4016 }
4003 4017
4004 4018
4005 Object* JSObject::GetPrototype() { 4019 Object* JSReceiver::GetPrototype() {
4006 return JSObject::cast(this)->map()->prototype(); 4020 return HeapObject::cast(this)->map()->prototype();
4007 } 4021 }
4008 4022
4009 4023
4010 PropertyAttributes JSObject::GetPropertyAttribute(String* key) { 4024 PropertyAttributes JSReceiver::GetPropertyAttribute(String* key) {
4011 return GetPropertyAttributeWithReceiver(this, key); 4025 return GetPropertyAttributeWithReceiver(this, key);
4012 } 4026 }
4013 4027
4014 // TODO(504): this may be useful in other places too where JSGlobalProxy 4028 // TODO(504): this may be useful in other places too where JSGlobalProxy
4015 // is used. 4029 // is used.
4016 Object* JSObject::BypassGlobalProxy() { 4030 Object* JSObject::BypassGlobalProxy() {
4017 if (IsJSGlobalProxy()) { 4031 if (IsJSGlobalProxy()) {
4018 Object* proto = GetPrototype(); 4032 Object* proto = GetPrototype();
4019 if (proto->IsNull()) return GetHeap()->undefined_value(); 4033 if (proto->IsNull()) return GetHeap()->undefined_value();
4020 ASSERT(proto->IsJSGlobalObject()); 4034 ASSERT(proto->IsJSGlobalObject());
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
4314 #undef WRITE_INT_FIELD 4328 #undef WRITE_INT_FIELD
4315 #undef READ_SHORT_FIELD 4329 #undef READ_SHORT_FIELD
4316 #undef WRITE_SHORT_FIELD 4330 #undef WRITE_SHORT_FIELD
4317 #undef READ_BYTE_FIELD 4331 #undef READ_BYTE_FIELD
4318 #undef WRITE_BYTE_FIELD 4332 #undef WRITE_BYTE_FIELD
4319 4333
4320 4334
4321 } } // namespace v8::internal 4335 } } // namespace v8::internal
4322 4336
4323 #endif // V8_OBJECTS_INL_H_ 4337 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/proxy.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698