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

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

Issue 893073006: Add map-based read barrier to WeakCell 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
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 Object* WeakCell::value(Heap* heap) {
1953 Object* pointer = READ_FIELD(this, kValueOffsetDontForgetTheReadBarrier);
1954 NOBARRIER_WRITE_FIELD(this, kMapOffset, GetHeap()->used_weak_cell_map());
1955 return pointer;
1956 }
1957
1958
1959 Object* WeakCell::ValueNoReadBarrier() {
1960 return READ_FIELD(this, kValueOffsetDontForgetTheReadBarrier);
1961 }
1962
1963
1964 void WeakCell::TriggerReadBarrier(Object* possible_weak_cell) {
1965 if (possible_weak_cell->IsWeakCell()) {
1966 WeakCell* weak_cell = reinterpret_cast<WeakCell*>(possible_weak_cell);
1967 weak_cell->value(weak_cell->GetHeap());
1968 }
1969 }
1953 1970
1954 1971
1955 void WeakCell::clear() { 1972 void WeakCell::clear() {
1956 DCHECK(GetHeap()->gc_state() == Heap::MARK_COMPACT); 1973 DCHECK(GetHeap()->gc_state() == Heap::MARK_COMPACT);
1957 WRITE_FIELD(this, kValueOffset, Smi::FromInt(0)); 1974 WRITE_FIELD(this, kValueOffsetDontForgetTheReadBarrier, Smi::FromInt(0));
1958 } 1975 }
1959 1976
1960 1977
1961 void WeakCell::initialize(HeapObject* val) { 1978 void WeakCell::initialize(HeapObject* val) {
1962 WRITE_FIELD(this, kValueOffset, val); 1979 WRITE_FIELD(this, kValueOffsetDontForgetTheReadBarrier, val);
1963 WRITE_BARRIER(GetHeap(), this, kValueOffset, val); 1980 WRITE_BARRIER(GetHeap(), this, kValueOffsetDontForgetTheReadBarrier, val);
1964 } 1981 }
1965 1982
1966 1983
1967 bool WeakCell::cleared() const { return value() == Smi::FromInt(0); } 1984 bool WeakCell::cleared() const {
1985 Object* pointer = READ_FIELD(this, kValueOffsetDontForgetTheReadBarrier);
1986 return pointer == Smi::FromInt(0);
1987 }
1968 1988
1969 1989
1970 Object* WeakCell::next() const { return READ_FIELD(this, kNextOffset); } 1990 Object* WeakCell::next() const { return READ_FIELD(this, kNextOffset); }
1971 1991
1972 1992
1973 void WeakCell::set_next(Object* val, WriteBarrierMode mode) { 1993 void WeakCell::set_next(Object* val, WriteBarrierMode mode) {
1974 WRITE_FIELD(this, kNextOffset, val); 1994 WRITE_FIELD(this, kNextOffset, val);
1975 if (mode == UPDATE_WRITE_BARRIER) { 1995 if (mode == UPDATE_WRITE_BARRIER) {
1976 WRITE_BARRIER(GetHeap(), this, kNextOffset, val); 1996 WRITE_BARRIER(GetHeap(), this, kNextOffset, val);
1977 } 1997 }
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
2353 } 2373 }
2354 2374
2355 2375
2356 void FixedDoubleArray::FillWithHoles(int from, int to) { 2376 void FixedDoubleArray::FillWithHoles(int from, int to) {
2357 for (int i = from; i < to; i++) { 2377 for (int i = from; i < to; i++) {
2358 set_the_hole(i); 2378 set_the_hole(i);
2359 } 2379 }
2360 } 2380 }
2361 2381
2362 2382
2363 Object* WeakFixedArray::Get(int index) const { 2383 Object* WeakFixedArray::Get(Heap* heap, int index) const {
2364 Object* raw = FixedArray::cast(this)->get(index + kFirstIndex); 2384 Object* raw = FixedArray::cast(this)->get(index + kFirstIndex);
2365 if (raw->IsSmi()) return raw; 2385 if (raw->IsSmi()) return raw;
2366 return WeakCell::cast(raw)->value(); 2386 return WeakCell::cast(raw)->value(heap);
2387 }
2388
2389
2390 bool WeakFixedArray::EqualAt(int index, Object* object) const {
2391 DCHECK(index < Length());
2392 Object* raw = FixedArray::cast(this)->get(index + kFirstIndex);
2393 if (raw->IsSmi()) return raw == object;
2394 return WeakCell::cast(raw)->ValueNoReadBarrier() == object;
2367 } 2395 }
2368 2396
2369 2397
2370 bool WeakFixedArray::IsEmptySlot(int index) const { 2398 bool WeakFixedArray::IsEmptySlot(int index) const {
2371 DCHECK(index < Length()); 2399 DCHECK(index < Length());
2372 return Get(index)->IsSmi(); 2400 Object* raw = FixedArray::cast(this)->get(index + kFirstIndex);
2401 if (raw->IsSmi()) return true;
2402 return WeakCell::cast(raw)->cleared();
2373 } 2403 }
2374 2404
2375 2405
2376 void WeakFixedArray::clear(int index) { 2406 void WeakFixedArray::clear(int index) {
2377 FixedArray::cast(this)->set(index + kFirstIndex, Smi::FromInt(0)); 2407 FixedArray::cast(this)->set(index + kFirstIndex, Smi::FromInt(0));
2378 } 2408 }
2379 2409
2380 2410
2381 int WeakFixedArray::Length() const { 2411 int WeakFixedArray::Length() const {
2382 return FixedArray::cast(this)->length() - kFirstIndex; 2412 return FixedArray::cast(this)->length() - kFirstIndex;
(...skipping 5195 matching lines...) Expand 10 before | Expand all | Expand 10 after
7578 #undef ACCESSORS 7608 #undef ACCESSORS
7579 #undef ACCESSORS_TO_SMI 7609 #undef ACCESSORS_TO_SMI
7580 #undef SMI_ACCESSORS 7610 #undef SMI_ACCESSORS
7581 #undef SYNCHRONIZED_SMI_ACCESSORS 7611 #undef SYNCHRONIZED_SMI_ACCESSORS
7582 #undef NOBARRIER_SMI_ACCESSORS 7612 #undef NOBARRIER_SMI_ACCESSORS
7583 #undef BOOL_GETTER 7613 #undef BOOL_GETTER
7584 #undef BOOL_ACCESSORS 7614 #undef BOOL_ACCESSORS
7585 #undef FIELD_ADDR 7615 #undef FIELD_ADDR
7586 #undef FIELD_ADDR_CONST 7616 #undef FIELD_ADDR_CONST
7587 #undef READ_FIELD 7617 #undef READ_FIELD
7588 #undef NOBARRIER_READ_FIELD
7589 #undef WRITE_FIELD 7618 #undef WRITE_FIELD
7590 #undef NOBARRIER_WRITE_FIELD 7619 #undef NOBARRIER_WRITE_FIELD
7591 #undef WRITE_BARRIER 7620 #undef WRITE_BARRIER
7592 #undef CONDITIONAL_WRITE_BARRIER 7621 #undef CONDITIONAL_WRITE_BARRIER
7593 #undef READ_DOUBLE_FIELD 7622 #undef READ_DOUBLE_FIELD
7594 #undef WRITE_DOUBLE_FIELD 7623 #undef WRITE_DOUBLE_FIELD
7595 #undef READ_INT_FIELD 7624 #undef READ_INT_FIELD
7596 #undef WRITE_INT_FIELD 7625 #undef WRITE_INT_FIELD
7597 #undef READ_INTPTR_FIELD 7626 #undef READ_INTPTR_FIELD
7598 #undef WRITE_INTPTR_FIELD 7627 #undef WRITE_INTPTR_FIELD
7599 #undef READ_UINT32_FIELD 7628 #undef READ_UINT32_FIELD
7600 #undef WRITE_UINT32_FIELD 7629 #undef WRITE_UINT32_FIELD
7601 #undef READ_SHORT_FIELD 7630 #undef READ_SHORT_FIELD
7602 #undef WRITE_SHORT_FIELD 7631 #undef WRITE_SHORT_FIELD
7603 #undef READ_BYTE_FIELD 7632 #undef READ_BYTE_FIELD
7604 #undef WRITE_BYTE_FIELD 7633 #undef WRITE_BYTE_FIELD
7605 #undef NOBARRIER_READ_BYTE_FIELD 7634 #undef NOBARRIER_READ_BYTE_FIELD
7606 #undef NOBARRIER_WRITE_BYTE_FIELD 7635 #undef NOBARRIER_WRITE_BYTE_FIELD
7607 7636
7608 } } // namespace v8::internal 7637 } } // namespace v8::internal
7609 7638
7610 #endif // V8_OBJECTS_INL_H_ 7639 #endif // V8_OBJECTS_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698