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

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: 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
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::update_value_from_gc(HeapObject* val) {
1939 WRITE_FIELD(this, kValueOffset, val);
1940 WRITE_BARRIER(GetHeap(), this, kValueOffset, val);
Erik Corry 2014/10/13 15:56:17 If we are in GC, do we need the write barrier? I
ulan 2014/10/14 10:17:22 Yes, we need write barrier for the first initializ
1941 }
1942
1943
1944 Object* WeakCell::next() const { return READ_FIELD(this, kNextOffset); }
1945
1946
1947 void WeakCell::set_next(Object* val, WriteBarrierMode mode) {
1948 WRITE_FIELD(this, kNextOffset, val);
1949 if (mode == UPDATE_WRITE_BARRIER) {
1950 WRITE_BARRIER(GetHeap(), this, kNextOffset, val);
1951 }
1952 }
1953
1954
1932 int JSObject::GetHeaderSize() { 1955 int JSObject::GetHeaderSize() {
1933 InstanceType type = map()->instance_type(); 1956 InstanceType type = map()->instance_type();
1934 // Check for the most common kind of JavaScript object before 1957 // Check for the most common kind of JavaScript object before
1935 // falling into the generic switch. This speeds up the internal 1958 // falling into the generic switch. This speeds up the internal
1936 // field operations considerably on average. 1959 // field operations considerably on average.
1937 if (type == JS_OBJECT_TYPE) return JSObject::kHeaderSize; 1960 if (type == JS_OBJECT_TYPE) return JSObject::kHeaderSize;
1938 switch (type) { 1961 switch (type) {
1939 case JS_GENERATOR_OBJECT_TYPE: 1962 case JS_GENERATOR_OBJECT_TYPE:
1940 return JSGeneratorObject::kSize; 1963 return JSGeneratorObject::kSize;
1941 case JS_MODULE_TYPE: 1964 case JS_MODULE_TYPE:
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after
3246 CAST_ACCESSOR(SeqString) 3269 CAST_ACCESSOR(SeqString)
3247 CAST_ACCESSOR(SeqTwoByteString) 3270 CAST_ACCESSOR(SeqTwoByteString)
3248 CAST_ACCESSOR(SharedFunctionInfo) 3271 CAST_ACCESSOR(SharedFunctionInfo)
3249 CAST_ACCESSOR(SlicedString) 3272 CAST_ACCESSOR(SlicedString)
3250 CAST_ACCESSOR(Smi) 3273 CAST_ACCESSOR(Smi)
3251 CAST_ACCESSOR(String) 3274 CAST_ACCESSOR(String)
3252 CAST_ACCESSOR(StringTable) 3275 CAST_ACCESSOR(StringTable)
3253 CAST_ACCESSOR(Struct) 3276 CAST_ACCESSOR(Struct)
3254 CAST_ACCESSOR(Symbol) 3277 CAST_ACCESSOR(Symbol)
3255 CAST_ACCESSOR(UnseededNumberDictionary) 3278 CAST_ACCESSOR(UnseededNumberDictionary)
3279 CAST_ACCESSOR(WeakCell)
3256 CAST_ACCESSOR(WeakHashTable) 3280 CAST_ACCESSOR(WeakHashTable)
3257 3281
3258 3282
3259 template <class Traits> 3283 template <class Traits>
3260 FixedTypedArray<Traits>* FixedTypedArray<Traits>::cast(Object* object) { 3284 FixedTypedArray<Traits>* FixedTypedArray<Traits>::cast(Object* object) {
3261 SLOW_DCHECK(object->IsHeapObject() && 3285 SLOW_DCHECK(object->IsHeapObject() &&
3262 HeapObject::cast(object)->map()->instance_type() == 3286 HeapObject::cast(object)->map()->instance_type() ==
3263 Traits::kInstanceType); 3287 Traits::kInstanceType);
3264 return reinterpret_cast<FixedTypedArray<Traits>*>(object); 3288 return reinterpret_cast<FixedTypedArray<Traits>*>(object);
3265 } 3289 }
(...skipping 3991 matching lines...) Expand 10 before | Expand all | Expand 10 after
7257 #undef READ_SHORT_FIELD 7281 #undef READ_SHORT_FIELD
7258 #undef WRITE_SHORT_FIELD 7282 #undef WRITE_SHORT_FIELD
7259 #undef READ_BYTE_FIELD 7283 #undef READ_BYTE_FIELD
7260 #undef WRITE_BYTE_FIELD 7284 #undef WRITE_BYTE_FIELD
7261 #undef NOBARRIER_READ_BYTE_FIELD 7285 #undef NOBARRIER_READ_BYTE_FIELD
7262 #undef NOBARRIER_WRITE_BYTE_FIELD 7286 #undef NOBARRIER_WRITE_BYTE_FIELD
7263 7287
7264 } } // namespace v8::internal 7288 } } // namespace v8::internal
7265 7289
7266 #endif // V8_OBJECTS_INL_H_ 7290 #endif // V8_OBJECTS_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698