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

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

Issue 1053203007: Revert of Reland "Remove the weak list of views from array buffers" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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/runtime/runtime-typedarray.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 4359 matching lines...) Expand 10 before | Expand all | Expand 10 after
4370 template <class Traits> 4370 template <class Traits>
4371 Handle<Object> FixedTypedArray<Traits>::get( 4371 Handle<Object> FixedTypedArray<Traits>::get(
4372 Handle<FixedTypedArray<Traits> > array, 4372 Handle<FixedTypedArray<Traits> > array,
4373 int index) { 4373 int index) {
4374 return Traits::ToHandle(array->GetIsolate(), array->get_scalar(index)); 4374 return Traits::ToHandle(array->GetIsolate(), array->get_scalar(index));
4375 } 4375 }
4376 4376
4377 4377
4378 template <class Traits> 4378 template <class Traits>
4379 Handle<Object> FixedTypedArray<Traits>::SetValue( 4379 Handle<Object> FixedTypedArray<Traits>::SetValue(
4380 Handle<JSObject> holder, Handle<FixedTypedArray<Traits> > array, 4380 Handle<FixedTypedArray<Traits> > array,
4381 uint32_t index, Handle<Object> value) { 4381 uint32_t index,
4382 Handle<Object> value) {
4382 ElementType cast_value = Traits::defaultValue(); 4383 ElementType cast_value = Traits::defaultValue();
4383 Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder); 4384 if (index < static_cast<uint32_t>(array->length())) {
4384 if (!view->WasNeutered()) { 4385 if (value->IsSmi()) {
4385 if (index < static_cast<uint32_t>(array->length())) { 4386 int int_value = Handle<Smi>::cast(value)->value();
4386 if (value->IsSmi()) { 4387 cast_value = from_int(int_value);
4387 int int_value = Handle<Smi>::cast(value)->value(); 4388 } else if (value->IsHeapNumber()) {
4388 cast_value = from_int(int_value); 4389 double double_value = Handle<HeapNumber>::cast(value)->value();
4389 } else if (value->IsHeapNumber()) { 4390 cast_value = from_double(double_value);
4390 double double_value = Handle<HeapNumber>::cast(value)->value(); 4391 } else {
4391 cast_value = from_double(double_value); 4392 // Clamp undefined to the default value. All other types have been
4392 } else { 4393 // converted to a number type further up in the call chain.
4393 // Clamp undefined to the default value. All other types have been 4394 DCHECK(value->IsUndefined());
4394 // converted to a number type further up in the call chain.
4395 DCHECK(value->IsUndefined());
4396 }
4397 array->set(index, cast_value);
4398 } 4395 }
4396 array->set(index, cast_value);
4399 } 4397 }
4400 return Traits::ToHandle(array->GetIsolate(), cast_value); 4398 return Traits::ToHandle(array->GetIsolate(), cast_value);
4401 } 4399 }
4402 4400
4403 4401
4404 Handle<Object> Uint8ArrayTraits::ToHandle(Isolate* isolate, uint8_t scalar) { 4402 Handle<Object> Uint8ArrayTraits::ToHandle(Isolate* isolate, uint8_t scalar) {
4405 return handle(Smi::FromInt(scalar), isolate); 4403 return handle(Smi::FromInt(scalar), isolate);
4406 } 4404 }
4407 4405
4408 4406
(...skipping 2041 matching lines...) Expand 10 before | Expand all | Expand 10 after
6450 bool JSArrayBuffer::is_neuterable() { 6448 bool JSArrayBuffer::is_neuterable() {
6451 return BooleanBit::get(flag(), kIsNeuterableBit); 6449 return BooleanBit::get(flag(), kIsNeuterableBit);
6452 } 6450 }
6453 6451
6454 6452
6455 void JSArrayBuffer::set_is_neuterable(bool value) { 6453 void JSArrayBuffer::set_is_neuterable(bool value) {
6456 set_flag(BooleanBit::set(flag(), kIsNeuterableBit, value)); 6454 set_flag(BooleanBit::set(flag(), kIsNeuterableBit, value));
6457 } 6455 }
6458 6456
6459 6457
6460 bool JSArrayBuffer::was_neutered() {
6461 return BooleanBit::get(flag(), kWasNeuteredBit);
6462 }
6463
6464
6465 void JSArrayBuffer::set_was_neutered(bool value) {
6466 set_flag(BooleanBit::set(flag(), kWasNeuteredBit, value));
6467 }
6468
6469
6470 ACCESSORS(JSArrayBuffer, weak_next, Object, kWeakNextOffset) 6458 ACCESSORS(JSArrayBuffer, weak_next, Object, kWeakNextOffset)
6471 6459 ACCESSORS(JSArrayBuffer, weak_first_view, Object, kWeakFirstViewOffset)
6472
6473 Object* JSArrayBufferView::byte_offset() const {
6474 if (WasNeutered()) return Smi::FromInt(0);
6475 return Object::cast(READ_FIELD(this, kByteOffsetOffset));
6476 }
6477
6478
6479 void JSArrayBufferView::set_byte_offset(Object* value, WriteBarrierMode mode) {
6480 WRITE_FIELD(this, kByteOffsetOffset, value);
6481 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kByteOffsetOffset, value, mode);
6482 }
6483
6484
6485 Object* JSArrayBufferView::byte_length() const {
6486 if (WasNeutered()) return Smi::FromInt(0);
6487 return Object::cast(READ_FIELD(this, kByteLengthOffset));
6488 }
6489
6490
6491 void JSArrayBufferView::set_byte_length(Object* value, WriteBarrierMode mode) {
6492 WRITE_FIELD(this, kByteLengthOffset, value);
6493 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kByteLengthOffset, value, mode);
6494 }
6495 6460
6496 6461
6497 ACCESSORS(JSArrayBufferView, buffer, Object, kBufferOffset) 6462 ACCESSORS(JSArrayBufferView, buffer, Object, kBufferOffset)
6498 #ifdef VERIFY_HEAP 6463 ACCESSORS(JSArrayBufferView, byte_offset, Object, kByteOffsetOffset)
6499 ACCESSORS(JSArrayBufferView, raw_byte_offset, Object, kByteOffsetOffset) 6464 ACCESSORS(JSArrayBufferView, byte_length, Object, kByteLengthOffset)
6500 ACCESSORS(JSArrayBufferView, raw_byte_length, Object, kByteLengthOffset) 6465 ACCESSORS(JSArrayBufferView, weak_next, Object, kWeakNextOffset)
6501 #endif 6466 ACCESSORS(JSTypedArray, length, Object, kLengthOffset)
6502
6503
6504 bool JSArrayBufferView::WasNeutered() const {
6505 return !buffer()->IsSmi() && JSArrayBuffer::cast(buffer())->was_neutered();
6506 }
6507
6508
6509 Object* JSTypedArray::length() const {
6510 if (WasNeutered()) return Smi::FromInt(0);
6511 return Object::cast(READ_FIELD(this, kLengthOffset));
6512 }
6513
6514
6515 void JSTypedArray::set_length(Object* value, WriteBarrierMode mode) {
6516 WRITE_FIELD(this, kLengthOffset, value);
6517 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kLengthOffset, value, mode);
6518 }
6519
6520
6521 #ifdef VERIFY_HEAP
6522 ACCESSORS(JSTypedArray, raw_length, Object, kLengthOffset)
6523 #endif
6524
6525 6467
6526 ACCESSORS(JSRegExp, data, Object, kDataOffset) 6468 ACCESSORS(JSRegExp, data, Object, kDataOffset)
6527 6469
6528 6470
6529 JSRegExp::Type JSRegExp::TypeTag() { 6471 JSRegExp::Type JSRegExp::TypeTag() {
6530 Object* data = this->data(); 6472 Object* data = this->data();
6531 if (data->IsUndefined()) return JSRegExp::NOT_COMPILED; 6473 if (data->IsUndefined()) return JSRegExp::NOT_COMPILED;
6532 Smi* smi = Smi::cast(FixedArray::cast(data)->get(kTagIndex)); 6474 Smi* smi = Smi::cast(FixedArray::cast(data)->get(kTagIndex));
6533 return static_cast<JSRegExp::Type>(smi->value()); 6475 return static_cast<JSRegExp::Type>(smi->value());
6534 } 6476 }
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
7602 #undef READ_SHORT_FIELD 7544 #undef READ_SHORT_FIELD
7603 #undef WRITE_SHORT_FIELD 7545 #undef WRITE_SHORT_FIELD
7604 #undef READ_BYTE_FIELD 7546 #undef READ_BYTE_FIELD
7605 #undef WRITE_BYTE_FIELD 7547 #undef WRITE_BYTE_FIELD
7606 #undef NOBARRIER_READ_BYTE_FIELD 7548 #undef NOBARRIER_READ_BYTE_FIELD
7607 #undef NOBARRIER_WRITE_BYTE_FIELD 7549 #undef NOBARRIER_WRITE_BYTE_FIELD
7608 7550
7609 } } // namespace v8::internal 7551 } } // namespace v8::internal
7610 7552
7611 #endif // V8_OBJECTS_INL_H_ 7553 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects-debug.cc ('k') | src/runtime/runtime-typedarray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698