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 2319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2330 IsSimd128Value() || IsUndefined(isolate) || IsTrue(isolate) || | 2330 IsSimd128Value() || IsUndefined(isolate) || IsTrue(isolate) || |
2331 IsFalse(isolate) || IsNull(isolate))) { | 2331 IsFalse(isolate) || IsNull(isolate))) { |
2332 FATAL("API call returned invalid object"); | 2332 FATAL("API call returned invalid object"); |
2333 } | 2333 } |
2334 #endif // DEBUG | 2334 #endif // DEBUG |
2335 } | 2335 } |
2336 | 2336 |
2337 | 2337 |
2338 Object* FixedArray::get(int index) const { | 2338 Object* FixedArray::get(int index) const { |
2339 SLOW_DCHECK(index >= 0 && index < this->length()); | 2339 SLOW_DCHECK(index >= 0 && index < this->length()); |
2340 return READ_FIELD(this, kHeaderSize + index * kPointerSize); | 2340 return NOBARRIER_READ_FIELD(this, kHeaderSize + index * kPointerSize); |
2341 } | 2341 } |
2342 | 2342 |
2343 Handle<Object> FixedArray::get(FixedArray* array, int index, Isolate* isolate) { | 2343 Handle<Object> FixedArray::get(FixedArray* array, int index, Isolate* isolate) { |
2344 return handle(array->get(index), isolate); | 2344 return handle(array->get(index), isolate); |
2345 } | 2345 } |
2346 | 2346 |
2347 template <class T> | 2347 template <class T> |
2348 MaybeHandle<T> FixedArray::GetValue(Isolate* isolate, int index) const { | 2348 MaybeHandle<T> FixedArray::GetValue(Isolate* isolate, int index) const { |
2349 Object* obj = get(index); | 2349 Object* obj = get(index); |
2350 if (obj->IsUndefined(isolate)) return MaybeHandle<T>(); | 2350 if (obj->IsUndefined(isolate)) return MaybeHandle<T>(); |
2351 return Handle<T>(T::cast(obj), isolate); | 2351 return Handle<T>(T::cast(obj), isolate); |
2352 } | 2352 } |
2353 | 2353 |
2354 template <class T> | 2354 template <class T> |
2355 Handle<T> FixedArray::GetValueChecked(Isolate* isolate, int index) const { | 2355 Handle<T> FixedArray::GetValueChecked(Isolate* isolate, int index) const { |
2356 Object* obj = get(index); | 2356 Object* obj = get(index); |
2357 CHECK(!obj->IsUndefined(isolate)); | 2357 CHECK(!obj->IsUndefined(isolate)); |
2358 return Handle<T>(T::cast(obj), isolate); | 2358 return Handle<T>(T::cast(obj), isolate); |
2359 } | 2359 } |
2360 bool FixedArray::is_the_hole(Isolate* isolate, int index) { | 2360 bool FixedArray::is_the_hole(Isolate* isolate, int index) { |
2361 return get(index)->IsTheHole(isolate); | 2361 return get(index)->IsTheHole(isolate); |
2362 } | 2362 } |
2363 | 2363 |
2364 void FixedArray::set(int index, Smi* value) { | 2364 void FixedArray::set(int index, Smi* value) { |
2365 DCHECK(map() != GetHeap()->fixed_cow_array_map()); | 2365 DCHECK(map() != GetHeap()->fixed_cow_array_map()); |
2366 DCHECK(index >= 0 && index < this->length()); | 2366 DCHECK(index >= 0 && index < this->length()); |
2367 DCHECK(reinterpret_cast<Object*>(value)->IsSmi()); | 2367 DCHECK(reinterpret_cast<Object*>(value)->IsSmi()); |
2368 int offset = kHeaderSize + index * kPointerSize; | 2368 int offset = kHeaderSize + index * kPointerSize; |
2369 WRITE_FIELD(this, offset, value); | 2369 NOBARRIER_WRITE_FIELD(this, offset, value); |
2370 } | 2370 } |
2371 | 2371 |
2372 | 2372 |
2373 void FixedArray::set(int index, Object* value) { | 2373 void FixedArray::set(int index, Object* value) { |
2374 DCHECK_NE(GetHeap()->fixed_cow_array_map(), map()); | 2374 DCHECK_NE(GetHeap()->fixed_cow_array_map(), map()); |
2375 DCHECK(IsFixedArray()); | 2375 DCHECK(IsFixedArray()); |
2376 DCHECK_GE(index, 0); | 2376 DCHECK_GE(index, 0); |
2377 DCHECK_LT(index, this->length()); | 2377 DCHECK_LT(index, this->length()); |
2378 int offset = kHeaderSize + index * kPointerSize; | 2378 int offset = kHeaderSize + index * kPointerSize; |
2379 WRITE_FIELD(this, offset, value); | 2379 NOBARRIER_WRITE_FIELD(this, offset, value); |
2380 WRITE_BARRIER(GetHeap(), this, offset, value); | 2380 WRITE_BARRIER(GetHeap(), this, offset, value); |
2381 } | 2381 } |
2382 | 2382 |
2383 | 2383 |
2384 double FixedDoubleArray::get_scalar(int index) { | 2384 double FixedDoubleArray::get_scalar(int index) { |
2385 DCHECK(map() != GetHeap()->fixed_cow_array_map() && | 2385 DCHECK(map() != GetHeap()->fixed_cow_array_map() && |
2386 map() != GetHeap()->fixed_array_map()); | 2386 map() != GetHeap()->fixed_array_map()); |
2387 DCHECK(index >= 0 && index < this->length()); | 2387 DCHECK(index >= 0 && index < this->length()); |
2388 DCHECK(!is_the_hole(index)); | 2388 DCHECK(!is_the_hole(index)); |
2389 return READ_DOUBLE_FIELD(this, kHeaderSize + index * kDoubleSize); | 2389 return READ_DOUBLE_FIELD(this, kHeaderSize + index * kDoubleSize); |
(...skipping 6046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8436 #undef WRITE_INT64_FIELD | 8436 #undef WRITE_INT64_FIELD |
8437 #undef READ_BYTE_FIELD | 8437 #undef READ_BYTE_FIELD |
8438 #undef WRITE_BYTE_FIELD | 8438 #undef WRITE_BYTE_FIELD |
8439 #undef NOBARRIER_READ_BYTE_FIELD | 8439 #undef NOBARRIER_READ_BYTE_FIELD |
8440 #undef NOBARRIER_WRITE_BYTE_FIELD | 8440 #undef NOBARRIER_WRITE_BYTE_FIELD |
8441 | 8441 |
8442 } // namespace internal | 8442 } // namespace internal |
8443 } // namespace v8 | 8443 } // namespace v8 |
8444 | 8444 |
8445 #endif // V8_OBJECTS_INL_H_ | 8445 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |