OLD | NEW |
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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 if (filter & SKIP_STRINGS) return true; | 298 if (filter & SKIP_STRINGS) return true; |
299 } | 299 } |
300 return false; | 300 return false; |
301 } | 301 } |
302 | 302 |
303 | 303 |
304 Handle<Object> Object::NewStorageFor(Isolate* isolate, | 304 Handle<Object> Object::NewStorageFor(Isolate* isolate, |
305 Handle<Object> object, | 305 Handle<Object> object, |
306 Representation representation) { | 306 Representation representation) { |
307 if (representation.IsSmi() && object->IsUninitialized(isolate)) { | 307 if (representation.IsSmi() && object->IsUninitialized(isolate)) { |
308 return handle(Smi::kZero, isolate); | 308 return handle(Smi::FromInt(0), isolate); |
309 } | 309 } |
310 if (!representation.IsDouble()) return object; | 310 if (!representation.IsDouble()) return object; |
311 double value; | 311 double value; |
312 if (object->IsUninitialized(isolate)) { | 312 if (object->IsUninitialized(isolate)) { |
313 value = 0; | 313 value = 0; |
314 } else if (object->IsMutableHeapNumber()) { | 314 } else if (object->IsMutableHeapNumber()) { |
315 value = HeapNumber::cast(*object)->value(); | 315 value = HeapNumber::cast(*object)->value(); |
316 } else { | 316 } else { |
317 value = object->Number(); | 317 value = object->Number(); |
318 } | 318 } |
(...skipping 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1582 } | 1582 } |
1583 | 1583 |
1584 | 1584 |
1585 FixedArrayBase* JSObject::elements() const { | 1585 FixedArrayBase* JSObject::elements() const { |
1586 Object* array = READ_FIELD(this, kElementsOffset); | 1586 Object* array = READ_FIELD(this, kElementsOffset); |
1587 return static_cast<FixedArrayBase*>(array); | 1587 return static_cast<FixedArrayBase*>(array); |
1588 } | 1588 } |
1589 | 1589 |
1590 | 1590 |
1591 void AllocationSite::Initialize() { | 1591 void AllocationSite::Initialize() { |
1592 set_transition_info(Smi::kZero); | 1592 set_transition_info(Smi::FromInt(0)); |
1593 SetElementsKind(GetInitialFastElementsKind()); | 1593 SetElementsKind(GetInitialFastElementsKind()); |
1594 set_nested_site(Smi::kZero); | 1594 set_nested_site(Smi::FromInt(0)); |
1595 set_pretenure_data(0); | 1595 set_pretenure_data(0); |
1596 set_pretenure_create_count(0); | 1596 set_pretenure_create_count(0); |
1597 set_dependent_code(DependentCode::cast(GetHeap()->empty_fixed_array()), | 1597 set_dependent_code(DependentCode::cast(GetHeap()->empty_fixed_array()), |
1598 SKIP_WRITE_BARRIER); | 1598 SKIP_WRITE_BARRIER); |
1599 } | 1599 } |
1600 | 1600 |
1601 | 1601 |
1602 bool AllocationSite::IsZombie() { return pretenure_decision() == kZombie; } | 1602 bool AllocationSite::IsZombie() { return pretenure_decision() == kZombie; } |
1603 | 1603 |
1604 | 1604 |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2012 | 2012 |
2013 | 2013 |
2014 Object* WeakCell::value() const { return READ_FIELD(this, kValueOffset); } | 2014 Object* WeakCell::value() const { return READ_FIELD(this, kValueOffset); } |
2015 | 2015 |
2016 | 2016 |
2017 void WeakCell::clear() { | 2017 void WeakCell::clear() { |
2018 // Either the garbage collector is clearing the cell or we are simply | 2018 // Either the garbage collector is clearing the cell or we are simply |
2019 // initializing the root empty weak cell. | 2019 // initializing the root empty weak cell. |
2020 DCHECK(GetHeap()->gc_state() == Heap::MARK_COMPACT || | 2020 DCHECK(GetHeap()->gc_state() == Heap::MARK_COMPACT || |
2021 this == GetHeap()->empty_weak_cell()); | 2021 this == GetHeap()->empty_weak_cell()); |
2022 WRITE_FIELD(this, kValueOffset, Smi::kZero); | 2022 WRITE_FIELD(this, kValueOffset, Smi::FromInt(0)); |
2023 } | 2023 } |
2024 | 2024 |
2025 | 2025 |
2026 void WeakCell::initialize(HeapObject* val) { | 2026 void WeakCell::initialize(HeapObject* val) { |
2027 WRITE_FIELD(this, kValueOffset, val); | 2027 WRITE_FIELD(this, kValueOffset, val); |
2028 // We just have to execute the generational barrier here because we never | 2028 // We just have to execute the generational barrier here because we never |
2029 // mark through a weak cell and collect evacuation candidates when we process | 2029 // mark through a weak cell and collect evacuation candidates when we process |
2030 // all weak cells. | 2030 // all weak cells. |
2031 WriteBarrierMode mode = Marking::IsBlack(ObjectMarking::MarkBitFrom(this)) | 2031 WriteBarrierMode mode = Marking::IsBlack(ObjectMarking::MarkBitFrom(this)) |
2032 ? UPDATE_WRITE_BARRIER | 2032 ? UPDATE_WRITE_BARRIER |
2033 : UPDATE_WEAK_WRITE_BARRIER; | 2033 : UPDATE_WEAK_WRITE_BARRIER; |
2034 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kValueOffset, val, mode); | 2034 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kValueOffset, val, mode); |
2035 } | 2035 } |
2036 | 2036 |
2037 bool WeakCell::cleared() const { return value() == Smi::kZero; } | 2037 |
| 2038 bool WeakCell::cleared() const { return value() == Smi::FromInt(0); } |
| 2039 |
2038 | 2040 |
2039 Object* WeakCell::next() const { return READ_FIELD(this, kNextOffset); } | 2041 Object* WeakCell::next() const { return READ_FIELD(this, kNextOffset); } |
2040 | 2042 |
2041 | 2043 |
2042 void WeakCell::set_next(Object* val, WriteBarrierMode mode) { | 2044 void WeakCell::set_next(Object* val, WriteBarrierMode mode) { |
2043 WRITE_FIELD(this, kNextOffset, val); | 2045 WRITE_FIELD(this, kNextOffset, val); |
2044 if (mode == UPDATE_WRITE_BARRIER) { | 2046 if (mode == UPDATE_WRITE_BARRIER) { |
2045 WRITE_BARRIER(GetHeap(), this, kNextOffset, val); | 2047 WRITE_BARRIER(GetHeap(), this, kNextOffset, val); |
2046 } | 2048 } |
2047 } | 2049 } |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2460 } | 2462 } |
2461 | 2463 |
2462 | 2464 |
2463 bool WeakFixedArray::IsEmptySlot(int index) const { | 2465 bool WeakFixedArray::IsEmptySlot(int index) const { |
2464 DCHECK(index < Length()); | 2466 DCHECK(index < Length()); |
2465 return Get(index)->IsSmi(); | 2467 return Get(index)->IsSmi(); |
2466 } | 2468 } |
2467 | 2469 |
2468 | 2470 |
2469 void WeakFixedArray::Clear(int index) { | 2471 void WeakFixedArray::Clear(int index) { |
2470 FixedArray::cast(this)->set(index + kFirstIndex, Smi::kZero); | 2472 FixedArray::cast(this)->set(index + kFirstIndex, Smi::FromInt(0)); |
2471 } | 2473 } |
2472 | 2474 |
2473 | 2475 |
2474 int WeakFixedArray::Length() const { | 2476 int WeakFixedArray::Length() const { |
2475 return FixedArray::cast(this)->length() - kFirstIndex; | 2477 return FixedArray::cast(this)->length() - kFirstIndex; |
2476 } | 2478 } |
2477 | 2479 |
2478 | 2480 |
2479 int WeakFixedArray::last_used_index() const { | 2481 int WeakFixedArray::last_used_index() const { |
2480 return Smi::cast(FixedArray::cast(this)->get(kLastUsedIndexIndex))->value(); | 2482 return Smi::cast(FixedArray::cast(this)->get(kLastUsedIndexIndex))->value(); |
(...skipping 1737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4218 #undef TYPED_ARRAY_CASE | 4220 #undef TYPED_ARRAY_CASE |
4219 default: | 4221 default: |
4220 UNREACHABLE(); | 4222 UNREACHABLE(); |
4221 return 0; | 4223 return 0; |
4222 } | 4224 } |
4223 return element_size; | 4225 return element_size; |
4224 } | 4226 } |
4225 | 4227 |
4226 | 4228 |
4227 int FixedTypedArrayBase::DataSize(InstanceType type) { | 4229 int FixedTypedArrayBase::DataSize(InstanceType type) { |
4228 if (base_pointer() == Smi::kZero) return 0; | 4230 if (base_pointer() == Smi::FromInt(0)) return 0; |
4229 return length() * ElementSize(type); | 4231 return length() * ElementSize(type); |
4230 } | 4232 } |
4231 | 4233 |
4232 | 4234 |
4233 int FixedTypedArrayBase::DataSize() { | 4235 int FixedTypedArrayBase::DataSize() { |
4234 return DataSize(map()->instance_type()); | 4236 return DataSize(map()->instance_type()); |
4235 } | 4237 } |
4236 | 4238 |
4237 | 4239 |
4238 int FixedTypedArrayBase::size() { | 4240 int FixedTypedArrayBase::size() { |
(...skipping 2669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6908 | 6910 |
6909 bool JSArrayBuffer::is_shared() { return IsShared::decode(bit_field()); } | 6911 bool JSArrayBuffer::is_shared() { return IsShared::decode(bit_field()); } |
6910 | 6912 |
6911 | 6913 |
6912 void JSArrayBuffer::set_is_shared(bool value) { | 6914 void JSArrayBuffer::set_is_shared(bool value) { |
6913 set_bit_field(IsShared::update(bit_field(), value)); | 6915 set_bit_field(IsShared::update(bit_field(), value)); |
6914 } | 6916 } |
6915 | 6917 |
6916 | 6918 |
6917 Object* JSArrayBufferView::byte_offset() const { | 6919 Object* JSArrayBufferView::byte_offset() const { |
6918 if (WasNeutered()) return Smi::kZero; | 6920 if (WasNeutered()) return Smi::FromInt(0); |
6919 return Object::cast(READ_FIELD(this, kByteOffsetOffset)); | 6921 return Object::cast(READ_FIELD(this, kByteOffsetOffset)); |
6920 } | 6922 } |
6921 | 6923 |
6922 | 6924 |
6923 void JSArrayBufferView::set_byte_offset(Object* value, WriteBarrierMode mode) { | 6925 void JSArrayBufferView::set_byte_offset(Object* value, WriteBarrierMode mode) { |
6924 WRITE_FIELD(this, kByteOffsetOffset, value); | 6926 WRITE_FIELD(this, kByteOffsetOffset, value); |
6925 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kByteOffsetOffset, value, mode); | 6927 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kByteOffsetOffset, value, mode); |
6926 } | 6928 } |
6927 | 6929 |
6928 | 6930 |
6929 Object* JSArrayBufferView::byte_length() const { | 6931 Object* JSArrayBufferView::byte_length() const { |
6930 if (WasNeutered()) return Smi::kZero; | 6932 if (WasNeutered()) return Smi::FromInt(0); |
6931 return Object::cast(READ_FIELD(this, kByteLengthOffset)); | 6933 return Object::cast(READ_FIELD(this, kByteLengthOffset)); |
6932 } | 6934 } |
6933 | 6935 |
6934 | 6936 |
6935 void JSArrayBufferView::set_byte_length(Object* value, WriteBarrierMode mode) { | 6937 void JSArrayBufferView::set_byte_length(Object* value, WriteBarrierMode mode) { |
6936 WRITE_FIELD(this, kByteLengthOffset, value); | 6938 WRITE_FIELD(this, kByteLengthOffset, value); |
6937 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kByteLengthOffset, value, mode); | 6939 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kByteLengthOffset, value, mode); |
6938 } | 6940 } |
6939 | 6941 |
6940 | 6942 |
6941 ACCESSORS(JSArrayBufferView, buffer, Object, kBufferOffset) | 6943 ACCESSORS(JSArrayBufferView, buffer, Object, kBufferOffset) |
6942 #ifdef VERIFY_HEAP | 6944 #ifdef VERIFY_HEAP |
6943 ACCESSORS(JSArrayBufferView, raw_byte_offset, Object, kByteOffsetOffset) | 6945 ACCESSORS(JSArrayBufferView, raw_byte_offset, Object, kByteOffsetOffset) |
6944 ACCESSORS(JSArrayBufferView, raw_byte_length, Object, kByteLengthOffset) | 6946 ACCESSORS(JSArrayBufferView, raw_byte_length, Object, kByteLengthOffset) |
6945 #endif | 6947 #endif |
6946 | 6948 |
6947 | 6949 |
6948 bool JSArrayBufferView::WasNeutered() const { | 6950 bool JSArrayBufferView::WasNeutered() const { |
6949 return JSArrayBuffer::cast(buffer())->was_neutered(); | 6951 return JSArrayBuffer::cast(buffer())->was_neutered(); |
6950 } | 6952 } |
6951 | 6953 |
6952 | 6954 |
6953 Object* JSTypedArray::length() const { | 6955 Object* JSTypedArray::length() const { |
6954 if (WasNeutered()) return Smi::kZero; | 6956 if (WasNeutered()) return Smi::FromInt(0); |
6955 return Object::cast(READ_FIELD(this, kLengthOffset)); | 6957 return Object::cast(READ_FIELD(this, kLengthOffset)); |
6956 } | 6958 } |
6957 | 6959 |
6958 | 6960 |
6959 uint32_t JSTypedArray::length_value() const { | 6961 uint32_t JSTypedArray::length_value() const { |
6960 if (WasNeutered()) return 0; | 6962 if (WasNeutered()) return 0; |
6961 uint32_t index = 0; | 6963 uint32_t index = 0; |
6962 CHECK(Object::cast(READ_FIELD(this, kLengthOffset))->ToArrayLength(&index)); | 6964 CHECK(Object::cast(READ_FIELD(this, kLengthOffset))->ToArrayLength(&index)); |
6963 return index; | 6965 return index; |
6964 } | 6966 } |
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7696 | 7698 |
7697 bool AccessorPair::IsJSAccessor(Object* obj) { | 7699 bool AccessorPair::IsJSAccessor(Object* obj) { |
7698 return obj->IsCallable() || obj->IsUndefined(GetIsolate()); | 7700 return obj->IsCallable() || obj->IsUndefined(GetIsolate()); |
7699 } | 7701 } |
7700 | 7702 |
7701 | 7703 |
7702 template<typename Derived, typename Shape, typename Key> | 7704 template<typename Derived, typename Shape, typename Key> |
7703 void Dictionary<Derived, Shape, Key>::SetEntry(int entry, | 7705 void Dictionary<Derived, Shape, Key>::SetEntry(int entry, |
7704 Handle<Object> key, | 7706 Handle<Object> key, |
7705 Handle<Object> value) { | 7707 Handle<Object> value) { |
7706 this->SetEntry(entry, key, value, PropertyDetails(Smi::kZero)); | 7708 this->SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0))); |
7707 } | 7709 } |
7708 | 7710 |
7709 | 7711 |
7710 template<typename Derived, typename Shape, typename Key> | 7712 template<typename Derived, typename Shape, typename Key> |
7711 void Dictionary<Derived, Shape, Key>::SetEntry(int entry, | 7713 void Dictionary<Derived, Shape, Key>::SetEntry(int entry, |
7712 Handle<Object> key, | 7714 Handle<Object> key, |
7713 Handle<Object> value, | 7715 Handle<Object> value, |
7714 PropertyDetails details) { | 7716 PropertyDetails details) { |
7715 Shape::SetEntry(static_cast<Derived*>(this), entry, key, value, details); | 7717 Shape::SetEntry(static_cast<Derived*>(this), entry, key, value, details); |
7716 } | 7718 } |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8088 if (delta == 0) return; | 8090 if (delta == 0) return; |
8089 int new_count = ic_generic_count() + delta; | 8091 int new_count = ic_generic_count() + delta; |
8090 if (new_count >= 0) { | 8092 if (new_count >= 0) { |
8091 new_count &= ~Smi::kMinValue; | 8093 new_count &= ~Smi::kMinValue; |
8092 WRITE_FIELD(this, kStorage3Offset, Smi::FromInt(new_count)); | 8094 WRITE_FIELD(this, kStorage3Offset, Smi::FromInt(new_count)); |
8093 } | 8095 } |
8094 } | 8096 } |
8095 | 8097 |
8096 | 8098 |
8097 void TypeFeedbackInfo::initialize_storage() { | 8099 void TypeFeedbackInfo::initialize_storage() { |
8098 WRITE_FIELD(this, kStorage1Offset, Smi::kZero); | 8100 WRITE_FIELD(this, kStorage1Offset, Smi::FromInt(0)); |
8099 WRITE_FIELD(this, kStorage2Offset, Smi::kZero); | 8101 WRITE_FIELD(this, kStorage2Offset, Smi::FromInt(0)); |
8100 WRITE_FIELD(this, kStorage3Offset, Smi::kZero); | 8102 WRITE_FIELD(this, kStorage3Offset, Smi::FromInt(0)); |
8101 } | 8103 } |
8102 | 8104 |
8103 | 8105 |
8104 void TypeFeedbackInfo::change_own_type_change_checksum() { | 8106 void TypeFeedbackInfo::change_own_type_change_checksum() { |
8105 int value = Smi::cast(READ_FIELD(this, kStorage1Offset))->value(); | 8107 int value = Smi::cast(READ_FIELD(this, kStorage1Offset))->value(); |
8106 int checksum = OwnTypeChangeChecksum::decode(value); | 8108 int checksum = OwnTypeChangeChecksum::decode(value); |
8107 checksum = (checksum + 1) % (1 << kTypeChangeChecksumBits); | 8109 checksum = (checksum + 1) % (1 << kTypeChangeChecksumBits); |
8108 value = OwnTypeChangeChecksum::update(value, checksum); | 8110 value = OwnTypeChangeChecksum::update(value, checksum); |
8109 // Ensure packed bit field is in Smi range. | 8111 // Ensure packed bit field is in Smi range. |
8110 if (value > Smi::kMaxValue) value |= Smi::kMinValue; | 8112 if (value > Smi::kMaxValue) value |= Smi::kMinValue; |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8313 #undef WRITE_INT64_FIELD | 8315 #undef WRITE_INT64_FIELD |
8314 #undef READ_BYTE_FIELD | 8316 #undef READ_BYTE_FIELD |
8315 #undef WRITE_BYTE_FIELD | 8317 #undef WRITE_BYTE_FIELD |
8316 #undef NOBARRIER_READ_BYTE_FIELD | 8318 #undef NOBARRIER_READ_BYTE_FIELD |
8317 #undef NOBARRIER_WRITE_BYTE_FIELD | 8319 #undef NOBARRIER_WRITE_BYTE_FIELD |
8318 | 8320 |
8319 } // namespace internal | 8321 } // namespace internal |
8320 } // namespace v8 | 8322 } // namespace v8 |
8321 | 8323 |
8322 #endif // V8_OBJECTS_INL_H_ | 8324 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |