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

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

Issue 640303006: Weak Cells (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Skip cleared weak cells Created 6 years, 2 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-debug.cc ('k') | src/objects-printer.cc » ('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 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 // Review notes: 5 // Review notes:
6 // 6 //
7 // - The use of macros in these inline functions may seem superfluous 7 // - The use of macros in these inline functions may seem superfluous
8 // but it is absolutely needed to make sure gcc generates optimal 8 // but it is absolutely needed to make sure gcc generates optimal
9 // code. gcc is not happy when attempting to inline too deep. 9 // code. gcc is not happy when attempting to inline too deep.
10 // 10 //
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 779
780 template <> inline bool Is<JSFunction>(Object* obj) { 780 template <> inline bool Is<JSFunction>(Object* obj) {
781 return obj->IsJSFunction(); 781 return obj->IsJSFunction();
782 } 782 }
783 783
784 784
785 TYPE_CHECKER(Code, CODE_TYPE) 785 TYPE_CHECKER(Code, CODE_TYPE)
786 TYPE_CHECKER(Oddball, ODDBALL_TYPE) 786 TYPE_CHECKER(Oddball, ODDBALL_TYPE)
787 TYPE_CHECKER(Cell, CELL_TYPE) 787 TYPE_CHECKER(Cell, CELL_TYPE)
788 TYPE_CHECKER(PropertyCell, PROPERTY_CELL_TYPE) 788 TYPE_CHECKER(PropertyCell, PROPERTY_CELL_TYPE)
789 TYPE_CHECKER(WeakCell, WEAK_CELL_TYPE)
789 TYPE_CHECKER(SharedFunctionInfo, SHARED_FUNCTION_INFO_TYPE) 790 TYPE_CHECKER(SharedFunctionInfo, SHARED_FUNCTION_INFO_TYPE)
790 TYPE_CHECKER(JSGeneratorObject, JS_GENERATOR_OBJECT_TYPE) 791 TYPE_CHECKER(JSGeneratorObject, JS_GENERATOR_OBJECT_TYPE)
791 TYPE_CHECKER(JSModule, JS_MODULE_TYPE) 792 TYPE_CHECKER(JSModule, JS_MODULE_TYPE)
792 TYPE_CHECKER(JSValue, JS_VALUE_TYPE) 793 TYPE_CHECKER(JSValue, JS_VALUE_TYPE)
793 TYPE_CHECKER(JSDate, JS_DATE_TYPE) 794 TYPE_CHECKER(JSDate, JS_DATE_TYPE)
794 TYPE_CHECKER(JSMessageObject, JS_MESSAGE_OBJECT_TYPE) 795 TYPE_CHECKER(JSMessageObject, JS_MESSAGE_OBJECT_TYPE)
795 796
796 797
797 bool Object::IsStringWrapper() const { 798 bool Object::IsStringWrapper() const {
798 return IsJSValue() && JSValue::cast(this)->value()->IsString(); 799 return IsJSValue() && JSValue::cast(this)->value()->IsString();
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 Object* PropertyCell::type_raw() const { 1923 Object* PropertyCell::type_raw() const {
1923 return READ_FIELD(this, kTypeOffset); 1924 return READ_FIELD(this, kTypeOffset);
1924 } 1925 }
1925 1926
1926 1927
1927 void PropertyCell::set_type_raw(Object* val, WriteBarrierMode ignored) { 1928 void PropertyCell::set_type_raw(Object* val, WriteBarrierMode ignored) {
1928 WRITE_FIELD(this, kTypeOffset, val); 1929 WRITE_FIELD(this, kTypeOffset, val);
1929 } 1930 }
1930 1931
1931 1932
1933 HeapObject* WeakCell::value() const {
1934 return HeapObject::cast(READ_FIELD(this, kValueOffset));
1935 }
1936
1937
1938 void WeakCell::clear(HeapObject* undefined) {
1939 WRITE_FIELD(this, kValueOffset, undefined);
1940 }
1941
1942
1943 void WeakCell::initialize(HeapObject* val) {
1944 WRITE_FIELD(this, kValueOffset, val);
1945 WRITE_BARRIER(GetHeap(), this, kValueOffset, val);
1946 }
1947
1948
1949 Object* WeakCell::next() const { return READ_FIELD(this, kNextOffset); }
1950
1951
1952 void WeakCell::set_next(Object* val, WriteBarrierMode mode) {
1953 WRITE_FIELD(this, kNextOffset, val);
1954 if (mode == UPDATE_WRITE_BARRIER) {
1955 WRITE_BARRIER(GetHeap(), this, kNextOffset, val);
1956 }
1957 }
1958
1959
1932 int JSObject::GetHeaderSize() { 1960 int JSObject::GetHeaderSize() {
1933 InstanceType type = map()->instance_type(); 1961 InstanceType type = map()->instance_type();
1934 // Check for the most common kind of JavaScript object before 1962 // Check for the most common kind of JavaScript object before
1935 // falling into the generic switch. This speeds up the internal 1963 // falling into the generic switch. This speeds up the internal
1936 // field operations considerably on average. 1964 // field operations considerably on average.
1937 if (type == JS_OBJECT_TYPE) return JSObject::kHeaderSize; 1965 if (type == JS_OBJECT_TYPE) return JSObject::kHeaderSize;
1938 switch (type) { 1966 switch (type) {
1939 case JS_GENERATOR_OBJECT_TYPE: 1967 case JS_GENERATOR_OBJECT_TYPE:
1940 return JSGeneratorObject::kSize; 1968 return JSGeneratorObject::kSize;
1941 case JS_MODULE_TYPE: 1969 case JS_MODULE_TYPE:
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after
3246 CAST_ACCESSOR(SeqString) 3274 CAST_ACCESSOR(SeqString)
3247 CAST_ACCESSOR(SeqTwoByteString) 3275 CAST_ACCESSOR(SeqTwoByteString)
3248 CAST_ACCESSOR(SharedFunctionInfo) 3276 CAST_ACCESSOR(SharedFunctionInfo)
3249 CAST_ACCESSOR(SlicedString) 3277 CAST_ACCESSOR(SlicedString)
3250 CAST_ACCESSOR(Smi) 3278 CAST_ACCESSOR(Smi)
3251 CAST_ACCESSOR(String) 3279 CAST_ACCESSOR(String)
3252 CAST_ACCESSOR(StringTable) 3280 CAST_ACCESSOR(StringTable)
3253 CAST_ACCESSOR(Struct) 3281 CAST_ACCESSOR(Struct)
3254 CAST_ACCESSOR(Symbol) 3282 CAST_ACCESSOR(Symbol)
3255 CAST_ACCESSOR(UnseededNumberDictionary) 3283 CAST_ACCESSOR(UnseededNumberDictionary)
3284 CAST_ACCESSOR(WeakCell)
3256 CAST_ACCESSOR(WeakHashTable) 3285 CAST_ACCESSOR(WeakHashTable)
3257 3286
3258 3287
3259 template <class Traits> 3288 template <class Traits>
3260 FixedTypedArray<Traits>* FixedTypedArray<Traits>::cast(Object* object) { 3289 FixedTypedArray<Traits>* FixedTypedArray<Traits>::cast(Object* object) {
3261 SLOW_DCHECK(object->IsHeapObject() && 3290 SLOW_DCHECK(object->IsHeapObject() &&
3262 HeapObject::cast(object)->map()->instance_type() == 3291 HeapObject::cast(object)->map()->instance_type() ==
3263 Traits::kInstanceType); 3292 Traits::kInstanceType);
3264 return reinterpret_cast<FixedTypedArray<Traits>*>(object); 3293 return reinterpret_cast<FixedTypedArray<Traits>*>(object);
3265 } 3294 }
(...skipping 3992 matching lines...) Expand 10 before | Expand all | Expand 10 after
7258 #undef READ_SHORT_FIELD 7287 #undef READ_SHORT_FIELD
7259 #undef WRITE_SHORT_FIELD 7288 #undef WRITE_SHORT_FIELD
7260 #undef READ_BYTE_FIELD 7289 #undef READ_BYTE_FIELD
7261 #undef WRITE_BYTE_FIELD 7290 #undef WRITE_BYTE_FIELD
7262 #undef NOBARRIER_READ_BYTE_FIELD 7291 #undef NOBARRIER_READ_BYTE_FIELD
7263 #undef NOBARRIER_WRITE_BYTE_FIELD 7292 #undef NOBARRIER_WRITE_BYTE_FIELD
7264 7293
7265 } } // namespace v8::internal 7294 } } // namespace v8::internal
7266 7295
7267 #endif // V8_OBJECTS_INL_H_ 7296 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698