OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #include <iomanip> | 5 #include <iomanip> |
6 #include <sstream> | 6 #include <sstream> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 13283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13294 case FAST_ELEMENTS: | 13294 case FAST_ELEMENTS: |
13295 case FAST_HOLEY_SMI_ELEMENTS: | 13295 case FAST_HOLEY_SMI_ELEMENTS: |
13296 case FAST_HOLEY_ELEMENTS: | 13296 case FAST_HOLEY_ELEMENTS: |
13297 return SetFastElement(object, index, value, language_mode, | 13297 return SetFastElement(object, index, value, language_mode, |
13298 check_prototype); | 13298 check_prototype); |
13299 case FAST_DOUBLE_ELEMENTS: | 13299 case FAST_DOUBLE_ELEMENTS: |
13300 case FAST_HOLEY_DOUBLE_ELEMENTS: | 13300 case FAST_HOLEY_DOUBLE_ELEMENTS: |
13301 return SetFastDoubleElement(object, index, value, language_mode, | 13301 return SetFastDoubleElement(object, index, value, language_mode, |
13302 check_prototype); | 13302 check_prototype); |
13303 | 13303 |
13304 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 13304 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
13305 case EXTERNAL_##TYPE##_ELEMENTS: { \ | 13305 case EXTERNAL_##TYPE##_ELEMENTS: { \ |
13306 Handle<External##Type##Array> array( \ | 13306 Handle<External##Type##Array> array( \ |
13307 External##Type##Array::cast(object->elements())); \ | 13307 External##Type##Array::cast(object->elements())); \ |
13308 return External##Type##Array::SetValue(object, array, index, value); \ | 13308 return External##Type##Array::SetValue(array, index, value); \ |
13309 } \ | 13309 } \ |
13310 case TYPE##_ELEMENTS: { \ | 13310 case TYPE##_ELEMENTS: { \ |
13311 Handle<Fixed##Type##Array> array( \ | 13311 Handle<Fixed##Type##Array> array( \ |
13312 Fixed##Type##Array::cast(object->elements())); \ | 13312 Fixed##Type##Array::cast(object->elements())); \ |
13313 return Fixed##Type##Array::SetValue(object, array, index, value); \ | 13313 return Fixed##Type##Array::SetValue(array, index, value); \ |
13314 } | 13314 } |
13315 | 13315 |
13316 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 13316 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
13317 | 13317 |
13318 #undef TYPED_ARRAY_CASE | 13318 #undef TYPED_ARRAY_CASE |
13319 | 13319 |
13320 case DICTIONARY_ELEMENTS: | 13320 case DICTIONARY_ELEMENTS: |
13321 return SetDictionaryElement(object, index, value, attributes, | 13321 return SetDictionaryElement(object, index, value, attributes, |
13322 language_mode, check_prototype, set_mode); | 13322 language_mode, check_prototype, set_mode); |
13323 case SLOPPY_ARGUMENTS_ELEMENTS: { | 13323 case SLOPPY_ARGUMENTS_ELEMENTS: { |
13324 Handle<FixedArray> parameter_map(FixedArray::cast(object->elements())); | 13324 Handle<FixedArray> parameter_map(FixedArray::cast(object->elements())); |
(...skipping 1845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15170 #undef INSTANCE_TYPE_TO_ELEMENT_SIZE | 15170 #undef INSTANCE_TYPE_TO_ELEMENT_SIZE |
15171 | 15171 |
15172 default: | 15172 default: |
15173 UNREACHABLE(); | 15173 UNREACHABLE(); |
15174 return 0; | 15174 return 0; |
15175 } | 15175 } |
15176 } | 15176 } |
15177 | 15177 |
15178 | 15178 |
15179 Handle<Object> ExternalUint8ClampedArray::SetValue( | 15179 Handle<Object> ExternalUint8ClampedArray::SetValue( |
15180 Handle<JSObject> holder, Handle<ExternalUint8ClampedArray> array, | 15180 Handle<ExternalUint8ClampedArray> array, |
15181 uint32_t index, Handle<Object> value) { | 15181 uint32_t index, |
| 15182 Handle<Object> value) { |
15182 uint8_t clamped_value = 0; | 15183 uint8_t clamped_value = 0; |
15183 Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder); | 15184 if (index < static_cast<uint32_t>(array->length())) { |
15184 if (!view->WasNeutered()) { | 15185 if (value->IsSmi()) { |
15185 if (index < static_cast<uint32_t>(array->length())) { | 15186 int int_value = Handle<Smi>::cast(value)->value(); |
15186 if (value->IsSmi()) { | 15187 if (int_value < 0) { |
15187 int int_value = Handle<Smi>::cast(value)->value(); | 15188 clamped_value = 0; |
15188 if (int_value < 0) { | 15189 } else if (int_value > 255) { |
15189 clamped_value = 0; | 15190 clamped_value = 255; |
15190 } else if (int_value > 255) { | |
15191 clamped_value = 255; | |
15192 } else { | |
15193 clamped_value = static_cast<uint8_t>(int_value); | |
15194 } | |
15195 } else if (value->IsHeapNumber()) { | |
15196 double double_value = Handle<HeapNumber>::cast(value)->value(); | |
15197 if (!(double_value > 0)) { | |
15198 // NaN and less than zero clamp to zero. | |
15199 clamped_value = 0; | |
15200 } else if (double_value > 255) { | |
15201 // Greater than 255 clamp to 255. | |
15202 clamped_value = 255; | |
15203 } else { | |
15204 // Other doubles are rounded to the nearest integer. | |
15205 clamped_value = static_cast<uint8_t>(lrint(double_value)); | |
15206 } | |
15207 } else { | 15191 } else { |
15208 // Clamp undefined to zero (default). All other types have been | 15192 clamped_value = static_cast<uint8_t>(int_value); |
15209 // converted to a number type further up in the call chain. | |
15210 DCHECK(value->IsUndefined()); | |
15211 } | 15193 } |
15212 array->set(index, clamped_value); | 15194 } else if (value->IsHeapNumber()) { |
| 15195 double double_value = Handle<HeapNumber>::cast(value)->value(); |
| 15196 if (!(double_value > 0)) { |
| 15197 // NaN and less than zero clamp to zero. |
| 15198 clamped_value = 0; |
| 15199 } else if (double_value > 255) { |
| 15200 // Greater than 255 clamp to 255. |
| 15201 clamped_value = 255; |
| 15202 } else { |
| 15203 // Other doubles are rounded to the nearest integer. |
| 15204 clamped_value = static_cast<uint8_t>(lrint(double_value)); |
| 15205 } |
| 15206 } else { |
| 15207 // Clamp undefined to zero (default). All other types have been |
| 15208 // converted to a number type further up in the call chain. |
| 15209 DCHECK(value->IsUndefined()); |
15213 } | 15210 } |
| 15211 array->set(index, clamped_value); |
15214 } | 15212 } |
15215 return handle(Smi::FromInt(clamped_value), array->GetIsolate()); | 15213 return handle(Smi::FromInt(clamped_value), array->GetIsolate()); |
15216 } | 15214 } |
15217 | 15215 |
15218 | 15216 |
15219 template <typename ExternalArrayClass, typename ValueType> | 15217 template<typename ExternalArrayClass, typename ValueType> |
15220 static Handle<Object> ExternalArrayIntSetter( | 15218 static Handle<Object> ExternalArrayIntSetter( |
15221 Isolate* isolate, Handle<JSObject> holder, | 15219 Isolate* isolate, |
15222 Handle<ExternalArrayClass> receiver, uint32_t index, Handle<Object> value) { | 15220 Handle<ExternalArrayClass> receiver, |
| 15221 uint32_t index, |
| 15222 Handle<Object> value) { |
15223 ValueType cast_value = 0; | 15223 ValueType cast_value = 0; |
15224 Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder); | 15224 if (index < static_cast<uint32_t>(receiver->length())) { |
15225 if (!view->WasNeutered()) { | 15225 if (value->IsSmi()) { |
15226 if (index < static_cast<uint32_t>(receiver->length())) { | 15226 int int_value = Handle<Smi>::cast(value)->value(); |
15227 if (value->IsSmi()) { | 15227 cast_value = static_cast<ValueType>(int_value); |
15228 int int_value = Handle<Smi>::cast(value)->value(); | 15228 } else if (value->IsHeapNumber()) { |
15229 cast_value = static_cast<ValueType>(int_value); | 15229 double double_value = Handle<HeapNumber>::cast(value)->value(); |
15230 } else if (value->IsHeapNumber()) { | 15230 cast_value = static_cast<ValueType>(DoubleToInt32(double_value)); |
15231 double double_value = Handle<HeapNumber>::cast(value)->value(); | 15231 } else { |
15232 cast_value = static_cast<ValueType>(DoubleToInt32(double_value)); | 15232 // Clamp undefined to zero (default). All other types have been |
15233 } else { | 15233 // converted to a number type further up in the call chain. |
15234 // Clamp undefined to zero (default). All other types have been | 15234 DCHECK(value->IsUndefined()); |
15235 // converted to a number type further up in the call chain. | |
15236 DCHECK(value->IsUndefined()); | |
15237 } | |
15238 receiver->set(index, cast_value); | |
15239 } | 15235 } |
| 15236 receiver->set(index, cast_value); |
15240 } | 15237 } |
15241 return isolate->factory()->NewNumberFromInt(cast_value); | 15238 return isolate->factory()->NewNumberFromInt(cast_value); |
15242 } | 15239 } |
15243 | 15240 |
15244 | 15241 |
15245 Handle<Object> ExternalInt8Array::SetValue(Handle<JSObject> holder, | 15242 Handle<Object> ExternalInt8Array::SetValue(Handle<ExternalInt8Array> array, |
15246 Handle<ExternalInt8Array> array, | |
15247 uint32_t index, | 15243 uint32_t index, |
15248 Handle<Object> value) { | 15244 Handle<Object> value) { |
15249 return ExternalArrayIntSetter<ExternalInt8Array, int8_t>( | 15245 return ExternalArrayIntSetter<ExternalInt8Array, int8_t>( |
15250 array->GetIsolate(), holder, array, index, value); | 15246 array->GetIsolate(), array, index, value); |
15251 } | 15247 } |
15252 | 15248 |
15253 | 15249 |
15254 Handle<Object> ExternalUint8Array::SetValue(Handle<JSObject> holder, | 15250 Handle<Object> ExternalUint8Array::SetValue(Handle<ExternalUint8Array> array, |
15255 Handle<ExternalUint8Array> array, | |
15256 uint32_t index, | 15251 uint32_t index, |
15257 Handle<Object> value) { | 15252 Handle<Object> value) { |
15258 return ExternalArrayIntSetter<ExternalUint8Array, uint8_t>( | 15253 return ExternalArrayIntSetter<ExternalUint8Array, uint8_t>( |
15259 array->GetIsolate(), holder, array, index, value); | 15254 array->GetIsolate(), array, index, value); |
15260 } | 15255 } |
15261 | 15256 |
15262 | 15257 |
15263 Handle<Object> ExternalInt16Array::SetValue(Handle<JSObject> holder, | 15258 Handle<Object> ExternalInt16Array::SetValue(Handle<ExternalInt16Array> array, |
15264 Handle<ExternalInt16Array> array, | |
15265 uint32_t index, | 15259 uint32_t index, |
15266 Handle<Object> value) { | 15260 Handle<Object> value) { |
15267 return ExternalArrayIntSetter<ExternalInt16Array, int16_t>( | 15261 return ExternalArrayIntSetter<ExternalInt16Array, int16_t>( |
15268 array->GetIsolate(), holder, array, index, value); | 15262 array->GetIsolate(), array, index, value); |
15269 } | 15263 } |
15270 | 15264 |
15271 | 15265 |
15272 Handle<Object> ExternalUint16Array::SetValue(Handle<JSObject> holder, | 15266 Handle<Object> ExternalUint16Array::SetValue(Handle<ExternalUint16Array> array, |
15273 Handle<ExternalUint16Array> array, | |
15274 uint32_t index, | 15267 uint32_t index, |
15275 Handle<Object> value) { | 15268 Handle<Object> value) { |
15276 return ExternalArrayIntSetter<ExternalUint16Array, uint16_t>( | 15269 return ExternalArrayIntSetter<ExternalUint16Array, uint16_t>( |
15277 array->GetIsolate(), holder, array, index, value); | 15270 array->GetIsolate(), array, index, value); |
15278 } | 15271 } |
15279 | 15272 |
15280 | 15273 |
15281 Handle<Object> ExternalInt32Array::SetValue(Handle<JSObject> holder, | 15274 Handle<Object> ExternalInt32Array::SetValue(Handle<ExternalInt32Array> array, |
15282 Handle<ExternalInt32Array> array, | |
15283 uint32_t index, | 15275 uint32_t index, |
15284 Handle<Object> value) { | 15276 Handle<Object> value) { |
15285 return ExternalArrayIntSetter<ExternalInt32Array, int32_t>( | 15277 return ExternalArrayIntSetter<ExternalInt32Array, int32_t>( |
15286 array->GetIsolate(), holder, array, index, value); | 15278 array->GetIsolate(), array, index, value); |
15287 } | 15279 } |
15288 | 15280 |
15289 | 15281 |
15290 Handle<Object> ExternalUint32Array::SetValue(Handle<JSObject> holder, | 15282 Handle<Object> ExternalUint32Array::SetValue( |
15291 Handle<ExternalUint32Array> array, | 15283 Handle<ExternalUint32Array> array, |
15292 uint32_t index, | 15284 uint32_t index, |
15293 Handle<Object> value) { | 15285 Handle<Object> value) { |
15294 uint32_t cast_value = 0; | 15286 uint32_t cast_value = 0; |
15295 Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder); | 15287 if (index < static_cast<uint32_t>(array->length())) { |
15296 if (!view->WasNeutered()) { | 15288 if (value->IsSmi()) { |
15297 if (index < static_cast<uint32_t>(array->length())) { | 15289 int int_value = Handle<Smi>::cast(value)->value(); |
15298 if (value->IsSmi()) { | 15290 cast_value = static_cast<uint32_t>(int_value); |
15299 int int_value = Handle<Smi>::cast(value)->value(); | 15291 } else if (value->IsHeapNumber()) { |
15300 cast_value = static_cast<uint32_t>(int_value); | 15292 double double_value = Handle<HeapNumber>::cast(value)->value(); |
15301 } else if (value->IsHeapNumber()) { | 15293 cast_value = static_cast<uint32_t>(DoubleToUint32(double_value)); |
15302 double double_value = Handle<HeapNumber>::cast(value)->value(); | 15294 } else { |
15303 cast_value = static_cast<uint32_t>(DoubleToUint32(double_value)); | 15295 // Clamp undefined to zero (default). All other types have been |
15304 } else { | 15296 // converted to a number type further up in the call chain. |
15305 // Clamp undefined to zero (default). All other types have been | 15297 DCHECK(value->IsUndefined()); |
15306 // converted to a number type further up in the call chain. | |
15307 DCHECK(value->IsUndefined()); | |
15308 } | |
15309 array->set(index, cast_value); | |
15310 } | 15298 } |
| 15299 array->set(index, cast_value); |
15311 } | 15300 } |
15312 return array->GetIsolate()->factory()->NewNumberFromUint(cast_value); | 15301 return array->GetIsolate()->factory()->NewNumberFromUint(cast_value); |
15313 } | 15302 } |
15314 | 15303 |
15315 | 15304 |
15316 Handle<Object> ExternalFloat32Array::SetValue( | 15305 Handle<Object> ExternalFloat32Array::SetValue( |
15317 Handle<JSObject> holder, Handle<ExternalFloat32Array> array, uint32_t index, | 15306 Handle<ExternalFloat32Array> array, |
| 15307 uint32_t index, |
15318 Handle<Object> value) { | 15308 Handle<Object> value) { |
15319 float cast_value = std::numeric_limits<float>::quiet_NaN(); | 15309 float cast_value = std::numeric_limits<float>::quiet_NaN(); |
15320 Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder); | 15310 if (index < static_cast<uint32_t>(array->length())) { |
15321 if (!view->WasNeutered()) { | 15311 if (value->IsSmi()) { |
15322 if (index < static_cast<uint32_t>(array->length())) { | 15312 int int_value = Handle<Smi>::cast(value)->value(); |
15323 if (value->IsSmi()) { | 15313 cast_value = static_cast<float>(int_value); |
15324 int int_value = Handle<Smi>::cast(value)->value(); | 15314 } else if (value->IsHeapNumber()) { |
15325 cast_value = static_cast<float>(int_value); | 15315 double double_value = Handle<HeapNumber>::cast(value)->value(); |
15326 } else if (value->IsHeapNumber()) { | 15316 cast_value = static_cast<float>(double_value); |
15327 double double_value = Handle<HeapNumber>::cast(value)->value(); | 15317 } else { |
15328 cast_value = static_cast<float>(double_value); | 15318 // Clamp undefined to NaN (default). All other types have been |
15329 } else { | 15319 // converted to a number type further up in the call chain. |
15330 // Clamp undefined to NaN (default). All other types have been | 15320 DCHECK(value->IsUndefined()); |
15331 // converted to a number type further up in the call chain. | |
15332 DCHECK(value->IsUndefined()); | |
15333 } | |
15334 array->set(index, cast_value); | |
15335 } | 15321 } |
| 15322 array->set(index, cast_value); |
15336 } | 15323 } |
15337 return array->GetIsolate()->factory()->NewNumber(cast_value); | 15324 return array->GetIsolate()->factory()->NewNumber(cast_value); |
15338 } | 15325 } |
15339 | 15326 |
15340 | 15327 |
15341 Handle<Object> ExternalFloat64Array::SetValue( | 15328 Handle<Object> ExternalFloat64Array::SetValue( |
15342 Handle<JSObject> holder, Handle<ExternalFloat64Array> array, uint32_t index, | 15329 Handle<ExternalFloat64Array> array, |
| 15330 uint32_t index, |
15343 Handle<Object> value) { | 15331 Handle<Object> value) { |
15344 double double_value = std::numeric_limits<double>::quiet_NaN(); | 15332 double double_value = std::numeric_limits<double>::quiet_NaN(); |
15345 Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder); | 15333 if (index < static_cast<uint32_t>(array->length())) { |
15346 if (!view->WasNeutered()) { | 15334 if (value->IsNumber()) { |
15347 if (index < static_cast<uint32_t>(array->length())) { | 15335 double_value = value->Number(); |
15348 if (value->IsNumber()) { | 15336 } else { |
15349 double_value = value->Number(); | 15337 // Clamp undefined to NaN (default). All other types have been |
15350 } else { | 15338 // converted to a number type further up in the call chain. |
15351 // Clamp undefined to NaN (default). All other types have been | 15339 DCHECK(value->IsUndefined()); |
15352 // converted to a number type further up in the call chain. | |
15353 DCHECK(value->IsUndefined()); | |
15354 } | |
15355 array->set(index, double_value); | |
15356 } | 15340 } |
| 15341 array->set(index, double_value); |
15357 } | 15342 } |
15358 return array->GetIsolate()->factory()->NewNumber(double_value); | 15343 return array->GetIsolate()->factory()->NewNumber(double_value); |
15359 } | 15344 } |
15360 | 15345 |
15361 | 15346 |
15362 void GlobalObject::InvalidatePropertyCell(Handle<GlobalObject> global, | 15347 void GlobalObject::InvalidatePropertyCell(Handle<GlobalObject> global, |
15363 Handle<Name> name) { | 15348 Handle<Name> name) { |
15364 DCHECK(!global->HasFastProperties()); | 15349 DCHECK(!global->HasFastProperties()); |
15365 auto dictionary = handle(global->property_dictionary()); | 15350 auto dictionary = handle(global->property_dictionary()); |
15366 int entry = dictionary->FindEntry(name); | 15351 int entry = dictionary->FindEntry(name); |
(...skipping 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16908 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 16893 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
16909 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 16894 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
16910 } | 16895 } |
16911 | 16896 |
16912 | 16897 |
16913 void JSArrayBuffer::Neuter() { | 16898 void JSArrayBuffer::Neuter() { |
16914 CHECK(is_neuterable()); | 16899 CHECK(is_neuterable()); |
16915 CHECK(is_external()); | 16900 CHECK(is_external()); |
16916 set_backing_store(NULL); | 16901 set_backing_store(NULL); |
16917 set_byte_length(Smi::FromInt(0)); | 16902 set_byte_length(Smi::FromInt(0)); |
16918 set_was_neutered(true); | |
16919 } | 16903 } |
16920 | 16904 |
16921 | 16905 |
| 16906 void JSArrayBufferView::NeuterView() { |
| 16907 CHECK(JSArrayBuffer::cast(buffer())->is_neuterable()); |
| 16908 set_byte_offset(Smi::FromInt(0)); |
| 16909 set_byte_length(Smi::FromInt(0)); |
| 16910 } |
| 16911 |
| 16912 |
| 16913 void JSDataView::Neuter() { |
| 16914 NeuterView(); |
| 16915 } |
| 16916 |
| 16917 |
| 16918 void JSTypedArray::Neuter() { |
| 16919 NeuterView(); |
| 16920 set_length(Smi::FromInt(0)); |
| 16921 set_elements(GetHeap()->EmptyExternalArrayForMap(map())); |
| 16922 } |
| 16923 |
| 16924 |
16922 static ElementsKind FixedToExternalElementsKind(ElementsKind elements_kind) { | 16925 static ElementsKind FixedToExternalElementsKind(ElementsKind elements_kind) { |
16923 switch (elements_kind) { | 16926 switch (elements_kind) { |
16924 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 16927 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
16925 case TYPE##_ELEMENTS: return EXTERNAL_##TYPE##_ELEMENTS; | 16928 case TYPE##_ELEMENTS: return EXTERNAL_##TYPE##_ELEMENTS; |
16926 | 16929 |
16927 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 16930 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
16928 #undef TYPED_ARRAY_CASE | 16931 #undef TYPED_ARRAY_CASE |
16929 | 16932 |
16930 default: | 16933 default: |
16931 UNREACHABLE(); | 16934 UNREACHABLE(); |
(...skipping 20 matching lines...) Expand all Loading... |
16952 Runtime::SetupArrayBufferAllocatingData(isolate, buffer, | 16955 Runtime::SetupArrayBufferAllocatingData(isolate, buffer, |
16953 fixed_typed_array->DataSize(), false); | 16956 fixed_typed_array->DataSize(), false); |
16954 memcpy(buffer->backing_store(), | 16957 memcpy(buffer->backing_store(), |
16955 fixed_typed_array->DataPtr(), | 16958 fixed_typed_array->DataPtr(), |
16956 fixed_typed_array->DataSize()); | 16959 fixed_typed_array->DataSize()); |
16957 Handle<ExternalArray> new_elements = | 16960 Handle<ExternalArray> new_elements = |
16958 isolate->factory()->NewExternalArray( | 16961 isolate->factory()->NewExternalArray( |
16959 fixed_typed_array->length(), typed_array->type(), | 16962 fixed_typed_array->length(), typed_array->type(), |
16960 static_cast<uint8_t*>(buffer->backing_store())); | 16963 static_cast<uint8_t*>(buffer->backing_store())); |
16961 | 16964 |
| 16965 Heap* heap = isolate->heap(); |
| 16966 if (heap->InNewSpace(*typed_array)) { |
| 16967 DCHECK(typed_array->weak_next() == isolate->heap()->undefined_value()); |
| 16968 typed_array->set_weak_next(heap->new_array_buffer_views_list()); |
| 16969 heap->set_new_array_buffer_views_list(*typed_array); |
| 16970 } else { |
| 16971 buffer->set_weak_first_view(*typed_array); |
| 16972 DCHECK(typed_array->weak_next() == isolate->heap()->undefined_value()); |
| 16973 } |
16962 typed_array->set_buffer(*buffer); | 16974 typed_array->set_buffer(*buffer); |
16963 JSObject::SetMapAndElements(typed_array, new_map, new_elements); | 16975 JSObject::SetMapAndElements(typed_array, new_map, new_elements); |
16964 | 16976 |
16965 return buffer; | 16977 return buffer; |
16966 } | 16978 } |
16967 | 16979 |
16968 | 16980 |
16969 Handle<JSArrayBuffer> JSTypedArray::GetBuffer() { | 16981 Handle<JSArrayBuffer> JSTypedArray::GetBuffer() { |
16970 Handle<Object> result(buffer(), GetIsolate()); | 16982 Handle<Object> result(buffer(), GetIsolate()); |
16971 if (*result != Smi::FromInt(0)) { | 16983 if (*result != Smi::FromInt(0)) { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17078 if (!invalidate && old_type == PropertyCellType::kConstant && | 17090 if (!invalidate && old_type == PropertyCellType::kConstant && |
17079 new_type != PropertyCellType::kConstant) { | 17091 new_type != PropertyCellType::kConstant) { |
17080 auto isolate = dictionary->GetIsolate(); | 17092 auto isolate = dictionary->GetIsolate(); |
17081 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 17093 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
17082 isolate, DependentCode::kPropertyCellChangedGroup); | 17094 isolate, DependentCode::kPropertyCellChangedGroup); |
17083 } | 17095 } |
17084 return value; | 17096 return value; |
17085 } | 17097 } |
17086 | 17098 |
17087 } } // namespace v8::internal | 17099 } } // namespace v8::internal |
OLD | NEW |