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

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

Issue 892843002: Add mistagging-readbarrier to weak cell Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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
« src/ia32/macro-assembler-ia32.cc ('K') | « src/objects-debug.cc ('k') | no next file » | 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 1931 matching lines...) Expand 10 before | Expand all | Expand 10 after
1942 Object* PropertyCell::type_raw() const { 1942 Object* PropertyCell::type_raw() const {
1943 return READ_FIELD(this, kTypeOffset); 1943 return READ_FIELD(this, kTypeOffset);
1944 } 1944 }
1945 1945
1946 1946
1947 void PropertyCell::set_type_raw(Object* val, WriteBarrierMode ignored) { 1947 void PropertyCell::set_type_raw(Object* val, WriteBarrierMode ignored) {
1948 WRITE_FIELD(this, kTypeOffset, val); 1948 WRITE_FIELD(this, kTypeOffset, val);
1949 } 1949 }
1950 1950
1951 1951
1952 Object* WeakCell::value() const { return READ_FIELD(this, kValueOffset); } 1952 static const intptr_t kReadBarrierTag = 2;
1953 static const intptr_t kReadBarrierMask = 2;
1954
1955
1956 inline bool HasReadBarrierTag(Object* value) {
1957 DCHECK(!HAS_SMI_TAG(value));
1958 return (reinterpret_cast<intptr_t>(value) & kReadBarrierMask) ==
1959 kReadBarrierTag;
1960 }
1961
1962
1963 inline Object* ReadBarrierTag(Object* value) {
1964 DCHECK(!HAS_SMI_TAG(value));
1965 intptr_t tagged = reinterpret_cast<intptr_t>(value) | kReadBarrierTag;
1966 return reinterpret_cast<Object*>(tagged);
1967 }
1968
1969
1970 inline Object* ReadBarrierUntag(Object* value) {
1971 DCHECK(!HAS_SMI_TAG(value));
1972 intptr_t untagged = reinterpret_cast<intptr_t>(value) & kReadBarrierTag;
1973 return reinterpret_cast<Object*>(untagged);
1974 }
1975
1976
1977 Object* WeakCell::value() {
1978 Object* pointer = READ_FIELD(this, kValueOffsetDontForgetTheReadBarrier);
1979 if (pointer != Smi::FromInt(0) && HasReadBarrierTag(pointer)) {
1980 pointer = ReadBarrierUntag(pointer);
1981 WRITE_FIELD(this, kValueOffsetDontForgetTheReadBarrier, pointer);
1982 }
1983
1984 return pointer;
1985 }
1986
1987
1988 Object* WeakCell::ValueNoReadBarrier() {
1989 Object* pointer = READ_FIELD(this, kValueOffsetDontForgetTheReadBarrier);
1990 if (pointer == Smi::FromInt(0)) return pointer;
1991 DCHECK(!pointer->IsSmi());
1992 return ReadBarrierUntag(pointer);
1993 }
1953 1994
1954 1995
1955 void WeakCell::clear() { 1996 void WeakCell::clear() {
1956 DCHECK(GetHeap()->gc_state() == Heap::MARK_COMPACT); 1997 DCHECK(GetHeap()->gc_state() == Heap::MARK_COMPACT);
1957 WRITE_FIELD(this, kValueOffset, Smi::FromInt(0)); 1998 WRITE_FIELD(this, kValueOffsetDontForgetTheReadBarrier, Smi::FromInt(0));
1958 } 1999 }
1959 2000
1960 2001
1961 void WeakCell::initialize(HeapObject* val) { 2002 void WeakCell::initialize(HeapObject* val) {
1962 WRITE_FIELD(this, kValueOffset, val); 2003 WRITE_FIELD(this, kValueOffsetDontForgetTheReadBarrier, val);
1963 WRITE_BARRIER(GetHeap(), this, kValueOffset, val); 2004 WRITE_BARRIER(GetHeap(), this, kValueOffsetDontForgetTheReadBarrier, val);
1964 } 2005 }
1965 2006
1966 2007
1967 bool WeakCell::cleared() const { return value() == Smi::FromInt(0); } 2008 bool WeakCell::cleared() const {
2009 Object* pointer = READ_FIELD(this, kValueOffsetDontForgetTheReadBarrier);
2010 return pointer == Smi::FromInt(0);
2011 }
1968 2012
1969 2013
1970 Object* WeakCell::next() const { return READ_FIELD(this, kNextOffset); } 2014 Object* WeakCell::next() const { return READ_FIELD(this, kNextOffset); }
1971 2015
1972 2016
1973 void WeakCell::set_next(Object* val, WriteBarrierMode mode) { 2017 void WeakCell::set_next(Object* val, WriteBarrierMode mode) {
1974 WRITE_FIELD(this, kNextOffset, val); 2018 WRITE_FIELD(this, kNextOffset, val);
1975 if (mode == UPDATE_WRITE_BARRIER) { 2019 if (mode == UPDATE_WRITE_BARRIER) {
1976 WRITE_BARRIER(GetHeap(), this, kNextOffset, val); 2020 WRITE_BARRIER(GetHeap(), this, kNextOffset, val);
1977 } 2021 }
(...skipping 5540 matching lines...) Expand 10 before | Expand all | Expand 10 after
7518 #undef READ_SHORT_FIELD 7562 #undef READ_SHORT_FIELD
7519 #undef WRITE_SHORT_FIELD 7563 #undef WRITE_SHORT_FIELD
7520 #undef READ_BYTE_FIELD 7564 #undef READ_BYTE_FIELD
7521 #undef WRITE_BYTE_FIELD 7565 #undef WRITE_BYTE_FIELD
7522 #undef NOBARRIER_READ_BYTE_FIELD 7566 #undef NOBARRIER_READ_BYTE_FIELD
7523 #undef NOBARRIER_WRITE_BYTE_FIELD 7567 #undef NOBARRIER_WRITE_BYTE_FIELD
7524 7568
7525 } } // namespace v8::internal 7569 } } // namespace v8::internal
7526 7570
7527 #endif // V8_OBJECTS_INL_H_ 7571 #endif // V8_OBJECTS_INL_H_
OLDNEW
« src/ia32/macro-assembler-ia32.cc ('K') | « src/objects-debug.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698