diff --git a/src/heap/concurrent-marking.cc b/src/heap/concurrent-marking.cc index a8469cd556..2d3ad10872 100644 --- a/src/heap/concurrent-marking.cc +++ b/src/heap/concurrent-marking.cc @@ -162,12 +162,14 @@ class ConcurrentMarkingVisitor final // =========================================================================== int VisitBytecodeArray(Map* map, BytecodeArray* object) { - if (!ShouldVisit(object)) return 0; - int size = BytecodeArray::BodyDescriptorWeak::SizeOf(map, object); - VisitMapPointer(object, object->map_slot()); - BytecodeArray::BodyDescriptorWeak::IterateBody(object, size, this); - object->MakeOlder(); - return size; + if (marking_state_.IsGrey(object)) { + int size = BytecodeArray::BodyDescriptorWeak::SizeOf(map, object); + VisitMapPointer(object, object->map_slot()); + BytecodeArray::BodyDescriptorWeak::IterateBody(object, size, this); + // Aging of bytecode arrays is done on the main thread. + bailout_.Push(object); + } + return 0; } int VisitAllocationSite(Map* map, AllocationSite* object) { diff --git a/src/objects-inl.h b/src/objects-inl.h index f866ca51fc..112cce35c9 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -2858,16 +2858,14 @@ void BytecodeArray::set_osr_loop_nesting_level(int depth) { } BytecodeArray::Age BytecodeArray::bytecode_age() const { - // Bytecode is aged by the concurrent marker. - return static_cast(RELAXED_READ_INT8_FIELD(this, kBytecodeAgeOffset)); + return static_cast(READ_INT8_FIELD(this, kBytecodeAgeOffset)); } void BytecodeArray::set_bytecode_age(BytecodeArray::Age age) { DCHECK_GE(age, kFirstBytecodeAge); DCHECK_LE(age, kLastBytecodeAge); STATIC_ASSERT(kLastBytecodeAge <= kMaxInt8); - // Bytecode is aged by the concurrent marker. - RELAXED_WRITE_INT8_FIELD(this, kBytecodeAgeOffset, static_cast(age)); + WRITE_INT8_FIELD(this, kBytecodeAgeOffset, static_cast(age)); } int BytecodeArray::parameter_count() const { diff --git a/src/objects.cc b/src/objects.cc index ed91e4b987..8a7df947f7 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -14880,17 +14880,10 @@ void BytecodeArray::CopyBytecodesTo(BytecodeArray* to) { } void BytecodeArray::MakeOlder() { - // BytecodeArray is aged in concurrent marker. - // The word must be completely within the byte code array. - Address age_addr = address() + kBytecodeAgeOffset; - DCHECK_LE((reinterpret_cast(age_addr) & ~kPointerAlignmentMask) + - kPointerSize, - reinterpret_cast(address() + Size())); Age age = bytecode_age(); if (age < kLastBytecodeAge) { - base::AsAtomic8::Release_CompareAndSwap(age_addr, age, age + 1); + set_bytecode_age(static_cast(age + 1)); } - DCHECK_GE(bytecode_age(), kFirstBytecodeAge); DCHECK_LE(bytecode_age(), kLastBytecodeAge); } diff --git a/src/objects/object-macros.h b/src/objects/object-macros.h index eb192bcd8c..893224764f 100644 --- a/src/objects/object-macros.h +++ b/src/objects/object-macros.h @@ -209,17 +209,9 @@ #define WRITE_UINT8_FIELD(p, offset, value) \ (*reinterpret_cast(FIELD_ADDR(p, offset)) = value) -#define RELAXED_WRITE_INT8_FIELD(p, offset, value) \ - base::Relaxed_Store(reinterpret_cast(FIELD_ADDR(p, offset)), \ - static_cast(value)); - #define READ_INT8_FIELD(p, offset) \ (*reinterpret_cast(FIELD_ADDR_CONST(p, offset))) -#define RELAXED_READ_INT8_FIELD(p, offset) \ - static_cast(base::Relaxed_Load( \ - reinterpret_cast(FIELD_ADDR_CONST(p, offset)))) - #define WRITE_INT8_FIELD(p, offset, value) \ (*reinterpret_cast(FIELD_ADDR(p, offset)) = value) diff --git a/test/cctest/heap/test-heap.cc b/test/cctest/heap/test-heap.cc index 0b9c38feca..c6da5dc0b3 100644 --- a/test/cctest/heap/test-heap.cc +++ b/test/cctest/heap/test-heap.cc @@ -803,27 +803,6 @@ TEST(BytecodeArray) { CHECK_NE(array->constant_pool(), old_constant_pool_address); } -TEST(BytecodeArrayAging) { - static const uint8_t kRawBytes[] = {0xc3, 0x7e, 0xa5, 0x5a}; - static const int kRawBytesSize = sizeof(kRawBytes); - static const int kFrameSize = 32; - static const int kParameterCount = 2; - CcTest::InitializeVM(); - Isolate* isolate = CcTest::i_isolate(); - Factory* factory = isolate->factory(); - HandleScope scope(isolate); - - Handle array = - factory->NewBytecodeArray(kRawBytesSize, kRawBytes, kFrameSize, - kParameterCount, factory->empty_fixed_array()); - - CHECK_EQ(BytecodeArray::kFirstBytecodeAge, array->bytecode_age()); - array->MakeOlder(); - CHECK_EQ(BytecodeArray::kQuadragenarianBytecodeAge, array->bytecode_age()); - array->set_bytecode_age(BytecodeArray::kLastBytecodeAge); - array->MakeOlder(); - CHECK_EQ(BytecodeArray::kLastBytecodeAge, array->bytecode_age()); -} static const char* not_so_random_string_table[] = { "abstract",