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

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: Fix merge 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
« 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 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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
2361 } 2381 }
2362 2382
2363 2383
2364 void FixedDoubleArray::FillWithHoles(int from, int to) { 2384 void FixedDoubleArray::FillWithHoles(int from, int to) {
2365 for (int i = from; i < to; i++) { 2385 for (int i = from; i < to; i++) {
2366 set_the_hole(i); 2386 set_the_hole(i);
2367 } 2387 }
2368 } 2388 }
2369 2389
2370 2390
2371 Object* WeakFixedArray::Get(int index) const { 2391 Object* WeakFixedArray::Get(Heap* heap, int index) const {
2372 Object* raw = FixedArray::cast(this)->get(index + kFirstIndex); 2392 Object* raw = FixedArray::cast(this)->get(index + kFirstIndex);
2373 if (raw->IsSmi()) return raw; 2393 if (raw->IsSmi()) return raw;
2374 return WeakCell::cast(raw)->value(); 2394 return WeakCell::cast(raw)->value(heap);
2395 }
2396
2397
2398 bool WeakFixedArray::EqualAt(int index, Object* object) const {
2399 DCHECK(index < Length());
2400 Object* raw = FixedArray::cast(this)->get(index + kFirstIndex);
2401 if (raw->IsSmi()) return raw == object;
2402 return WeakCell::cast(raw)->ValueNoReadBarrier() == object;
2375 } 2403 }
2376 2404
2377 2405
2378 bool WeakFixedArray::IsEmptySlot(int index) const { 2406 bool WeakFixedArray::IsEmptySlot(int index) const {
2379 DCHECK(index < Length()); 2407 DCHECK(index < Length());
2380 return Get(index)->IsSmi(); 2408 Object* raw = FixedArray::cast(this)->get(index + kFirstIndex);
2409 if (raw->IsSmi()) return true;
2410 return WeakCell::cast(raw)->cleared();
2381 } 2411 }
2382 2412
2383 2413
2384 void WeakFixedArray::clear(int index) { 2414 void WeakFixedArray::clear(int index) {
2385 FixedArray::cast(this)->set(index + kFirstIndex, Smi::FromInt(0)); 2415 FixedArray::cast(this)->set(index + kFirstIndex, Smi::FromInt(0));
2386 } 2416 }
2387 2417
2388 2418
2389 int WeakFixedArray::Length() const { 2419 int WeakFixedArray::Length() const {
2390 return FixedArray::cast(this)->length() - kFirstIndex; 2420 return FixedArray::cast(this)->length() - kFirstIndex;
(...skipping 5207 matching lines...) Expand 10 before | Expand all | Expand 10 after
7598 #undef ACCESSORS 7628 #undef ACCESSORS
7599 #undef ACCESSORS_TO_SMI 7629 #undef ACCESSORS_TO_SMI
7600 #undef SMI_ACCESSORS 7630 #undef SMI_ACCESSORS
7601 #undef SYNCHRONIZED_SMI_ACCESSORS 7631 #undef SYNCHRONIZED_SMI_ACCESSORS
7602 #undef NOBARRIER_SMI_ACCESSORS 7632 #undef NOBARRIER_SMI_ACCESSORS
7603 #undef BOOL_GETTER 7633 #undef BOOL_GETTER
7604 #undef BOOL_ACCESSORS 7634 #undef BOOL_ACCESSORS
7605 #undef FIELD_ADDR 7635 #undef FIELD_ADDR
7606 #undef FIELD_ADDR_CONST 7636 #undef FIELD_ADDR_CONST
7607 #undef READ_FIELD 7637 #undef READ_FIELD
7608 #undef NOBARRIER_READ_FIELD
7609 #undef WRITE_FIELD 7638 #undef WRITE_FIELD
7610 #undef NOBARRIER_WRITE_FIELD 7639 #undef NOBARRIER_WRITE_FIELD
7611 #undef WRITE_BARRIER 7640 #undef WRITE_BARRIER
7612 #undef CONDITIONAL_WRITE_BARRIER 7641 #undef CONDITIONAL_WRITE_BARRIER
7613 #undef READ_DOUBLE_FIELD 7642 #undef READ_DOUBLE_FIELD
7614 #undef WRITE_DOUBLE_FIELD 7643 #undef WRITE_DOUBLE_FIELD
7615 #undef READ_INT_FIELD 7644 #undef READ_INT_FIELD
7616 #undef WRITE_INT_FIELD 7645 #undef WRITE_INT_FIELD
7617 #undef READ_INTPTR_FIELD 7646 #undef READ_INTPTR_FIELD
7618 #undef WRITE_INTPTR_FIELD 7647 #undef WRITE_INTPTR_FIELD
7619 #undef READ_UINT32_FIELD 7648 #undef READ_UINT32_FIELD
7620 #undef WRITE_UINT32_FIELD 7649 #undef WRITE_UINT32_FIELD
7621 #undef READ_SHORT_FIELD 7650 #undef READ_SHORT_FIELD
7622 #undef WRITE_SHORT_FIELD 7651 #undef WRITE_SHORT_FIELD
7623 #undef READ_BYTE_FIELD 7652 #undef READ_BYTE_FIELD
7624 #undef WRITE_BYTE_FIELD 7653 #undef WRITE_BYTE_FIELD
7625 #undef NOBARRIER_READ_BYTE_FIELD 7654 #undef NOBARRIER_READ_BYTE_FIELD
7626 #undef NOBARRIER_WRITE_BYTE_FIELD 7655 #undef NOBARRIER_WRITE_BYTE_FIELD
7627 7656
7628 } } // namespace v8::internal 7657 } } // namespace v8::internal
7629 7658
7630 #endif // V8_OBJECTS_INL_H_ 7659 #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