Index: src/objects-inl.h |
diff --git a/src/objects-inl.h b/src/objects-inl.h |
index e9db3c57361759a64e35580522b2b3a348776c43..2e77f92927613732b2a1579824f27319330ee345 100644 |
--- a/src/objects-inl.h |
+++ b/src/objects-inl.h |
@@ -4377,23 +4377,25 @@ Handle<Object> FixedTypedArray<Traits>::get( |
template <class Traits> |
Handle<Object> FixedTypedArray<Traits>::SetValue( |
- Handle<FixedTypedArray<Traits> > array, |
- uint32_t index, |
- Handle<Object> value) { |
+ Handle<JSObject> holder, Handle<FixedTypedArray<Traits> > array, |
+ uint32_t index, Handle<Object> value) { |
ElementType cast_value = Traits::defaultValue(); |
- if (index < static_cast<uint32_t>(array->length())) { |
- if (value->IsSmi()) { |
- int int_value = Handle<Smi>::cast(value)->value(); |
- cast_value = from_int(int_value); |
- } else if (value->IsHeapNumber()) { |
- double double_value = Handle<HeapNumber>::cast(value)->value(); |
- cast_value = from_double(double_value); |
- } else { |
- // Clamp undefined to the default value. All other types have been |
- // converted to a number type further up in the call chain. |
- DCHECK(value->IsUndefined()); |
+ Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder); |
+ if (!view->WasNeutered()) { |
+ if (index < static_cast<uint32_t>(array->length())) { |
+ if (value->IsSmi()) { |
+ int int_value = Handle<Smi>::cast(value)->value(); |
+ cast_value = from_int(int_value); |
+ } else if (value->IsHeapNumber()) { |
+ double double_value = Handle<HeapNumber>::cast(value)->value(); |
+ cast_value = from_double(double_value); |
+ } else { |
+ // Clamp undefined to the default value. All other types have been |
+ // converted to a number type further up in the call chain. |
+ DCHECK(value->IsUndefined()); |
+ } |
+ array->set(index, cast_value); |
} |
- array->set(index, cast_value); |
} |
return Traits::ToHandle(array->GetIsolate(), cast_value); |
} |
@@ -6455,15 +6457,71 @@ void JSArrayBuffer::set_is_neuterable(bool value) { |
} |
+bool JSArrayBuffer::was_neutered() { |
+ return BooleanBit::get(flag(), kWasNeuteredBit); |
+} |
+ |
+ |
+void JSArrayBuffer::set_was_neutered(bool value) { |
+ set_flag(BooleanBit::set(flag(), kWasNeuteredBit, value)); |
+} |
+ |
+ |
ACCESSORS(JSArrayBuffer, weak_next, Object, kWeakNextOffset) |
-ACCESSORS(JSArrayBuffer, weak_first_view, Object, kWeakFirstViewOffset) |
+ |
+ |
+Object* JSArrayBufferView::byte_offset() const { |
+ if (WasNeutered()) return Smi::FromInt(0); |
+ return Object::cast(READ_FIELD(this, kByteOffsetOffset)); |
+} |
+ |
+ |
+void JSArrayBufferView::set_byte_offset(Object* value, WriteBarrierMode mode) { |
+ WRITE_FIELD(this, kByteOffsetOffset, value); |
+ CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kByteOffsetOffset, value, mode); |
+} |
+ |
+ |
+Object* JSArrayBufferView::byte_length() const { |
+ if (WasNeutered()) return Smi::FromInt(0); |
+ return Object::cast(READ_FIELD(this, kByteLengthOffset)); |
+} |
+ |
+ |
+void JSArrayBufferView::set_byte_length(Object* value, WriteBarrierMode mode) { |
+ WRITE_FIELD(this, kByteLengthOffset, value); |
+ CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kByteLengthOffset, value, mode); |
+} |
ACCESSORS(JSArrayBufferView, buffer, Object, kBufferOffset) |
-ACCESSORS(JSArrayBufferView, byte_offset, Object, kByteOffsetOffset) |
-ACCESSORS(JSArrayBufferView, byte_length, Object, kByteLengthOffset) |
-ACCESSORS(JSArrayBufferView, weak_next, Object, kWeakNextOffset) |
-ACCESSORS(JSTypedArray, length, Object, kLengthOffset) |
+#ifdef VERIFY_HEAP |
+ACCESSORS(JSArrayBufferView, raw_byte_offset, Object, kByteOffsetOffset) |
+ACCESSORS(JSArrayBufferView, raw_byte_length, Object, kByteLengthOffset) |
+#endif |
+ |
+ |
+bool JSArrayBufferView::WasNeutered() const { |
+ return !buffer()->IsSmi() && JSArrayBuffer::cast(buffer())->was_neutered(); |
+} |
+ |
+ |
+Object* JSTypedArray::length() const { |
+ if (WasNeutered()) return Smi::FromInt(0); |
+ return Object::cast(READ_FIELD(this, kLengthOffset)); |
+} |
+ |
+ |
+void JSTypedArray::set_length(Object* value, WriteBarrierMode mode) { |
+ WRITE_FIELD(this, kLengthOffset, value); |
+ CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kLengthOffset, value, mode); |
+} |
+ |
+ |
+#ifdef VERIFY_HEAP |
+ACCESSORS(JSTypedArray, raw_length, Object, kLengthOffset) |
+#endif |
+ |
ACCESSORS(JSRegExp, data, Object, kDataOffset) |