| 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(array, index, value); \ | 13308 return External##Type##Array::SetValue(object, 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(array, index, value); \ | 13313 return Fixed##Type##Array::SetValue(object, 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<ExternalUint8ClampedArray> array, | 15180 Handle<JSObject> holder, Handle<ExternalUint8ClampedArray> array, |
| 15181 uint32_t index, | 15181 uint32_t index, Handle<Object> value) { |
| 15182 Handle<Object> value) { | |
| 15183 uint8_t clamped_value = 0; | 15182 uint8_t clamped_value = 0; |
| 15184 if (index < static_cast<uint32_t>(array->length())) { | 15183 Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder); |
| 15185 if (value->IsSmi()) { | 15184 if (!view->WasNeutered()) { |
| 15186 int int_value = Handle<Smi>::cast(value)->value(); | 15185 if (index < static_cast<uint32_t>(array->length())) { |
| 15187 if (int_value < 0) { | 15186 if (value->IsSmi()) { |
| 15188 clamped_value = 0; | 15187 int int_value = Handle<Smi>::cast(value)->value(); |
| 15189 } else if (int_value > 255) { | 15188 if (int_value < 0) { |
| 15190 clamped_value = 255; | 15189 clamped_value = 0; |
| 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 } |
| 15191 } else { | 15207 } else { |
| 15192 clamped_value = static_cast<uint8_t>(int_value); | 15208 // Clamp undefined to zero (default). All other types have been |
| 15209 // converted to a number type further up in the call chain. |
| 15210 DCHECK(value->IsUndefined()); |
| 15193 } | 15211 } |
| 15194 } else if (value->IsHeapNumber()) { | 15212 array->set(index, clamped_value); |
| 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()); | |
| 15210 } | 15213 } |
| 15211 array->set(index, clamped_value); | |
| 15212 } | 15214 } |
| 15213 return handle(Smi::FromInt(clamped_value), array->GetIsolate()); | 15215 return handle(Smi::FromInt(clamped_value), array->GetIsolate()); |
| 15214 } | 15216 } |
| 15215 | 15217 |
| 15216 | 15218 |
| 15217 template<typename ExternalArrayClass, typename ValueType> | 15219 template <typename ExternalArrayClass, typename ValueType> |
| 15218 static Handle<Object> ExternalArrayIntSetter( | 15220 static Handle<Object> ExternalArrayIntSetter( |
| 15219 Isolate* isolate, | 15221 Isolate* isolate, Handle<JSObject> holder, |
| 15220 Handle<ExternalArrayClass> receiver, | 15222 Handle<ExternalArrayClass> receiver, uint32_t index, Handle<Object> value) { |
| 15221 uint32_t index, | |
| 15222 Handle<Object> value) { | |
| 15223 ValueType cast_value = 0; | 15223 ValueType cast_value = 0; |
| 15224 if (index < static_cast<uint32_t>(receiver->length())) { | 15224 Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder); |
| 15225 if (value->IsSmi()) { | 15225 if (!view->WasNeutered()) { |
| 15226 int int_value = Handle<Smi>::cast(value)->value(); | 15226 if (index < static_cast<uint32_t>(receiver->length())) { |
| 15227 cast_value = static_cast<ValueType>(int_value); | 15227 if (value->IsSmi()) { |
| 15228 } else if (value->IsHeapNumber()) { | 15228 int int_value = Handle<Smi>::cast(value)->value(); |
| 15229 double double_value = Handle<HeapNumber>::cast(value)->value(); | 15229 cast_value = static_cast<ValueType>(int_value); |
| 15230 cast_value = static_cast<ValueType>(DoubleToInt32(double_value)); | 15230 } else if (value->IsHeapNumber()) { |
| 15231 } else { | 15231 double double_value = Handle<HeapNumber>::cast(value)->value(); |
| 15232 // Clamp undefined to zero (default). All other types have been | 15232 cast_value = static_cast<ValueType>(DoubleToInt32(double_value)); |
| 15233 // converted to a number type further up in the call chain. | 15233 } else { |
| 15234 DCHECK(value->IsUndefined()); | 15234 // Clamp undefined to zero (default). All other types have been |
| 15235 // converted to a number type further up in the call chain. |
| 15236 DCHECK(value->IsUndefined()); |
| 15237 } |
| 15238 receiver->set(index, cast_value); |
| 15235 } | 15239 } |
| 15236 receiver->set(index, cast_value); | |
| 15237 } | 15240 } |
| 15238 return isolate->factory()->NewNumberFromInt(cast_value); | 15241 return isolate->factory()->NewNumberFromInt(cast_value); |
| 15239 } | 15242 } |
| 15240 | 15243 |
| 15241 | 15244 |
| 15242 Handle<Object> ExternalInt8Array::SetValue(Handle<ExternalInt8Array> array, | 15245 Handle<Object> ExternalInt8Array::SetValue(Handle<JSObject> holder, |
| 15246 Handle<ExternalInt8Array> array, |
| 15243 uint32_t index, | 15247 uint32_t index, |
| 15244 Handle<Object> value) { | 15248 Handle<Object> value) { |
| 15245 return ExternalArrayIntSetter<ExternalInt8Array, int8_t>( | 15249 return ExternalArrayIntSetter<ExternalInt8Array, int8_t>( |
| 15246 array->GetIsolate(), array, index, value); | 15250 array->GetIsolate(), holder, array, index, value); |
| 15247 } | 15251 } |
| 15248 | 15252 |
| 15249 | 15253 |
| 15250 Handle<Object> ExternalUint8Array::SetValue(Handle<ExternalUint8Array> array, | 15254 Handle<Object> ExternalUint8Array::SetValue(Handle<JSObject> holder, |
| 15255 Handle<ExternalUint8Array> array, |
| 15251 uint32_t index, | 15256 uint32_t index, |
| 15252 Handle<Object> value) { | 15257 Handle<Object> value) { |
| 15253 return ExternalArrayIntSetter<ExternalUint8Array, uint8_t>( | 15258 return ExternalArrayIntSetter<ExternalUint8Array, uint8_t>( |
| 15254 array->GetIsolate(), array, index, value); | 15259 array->GetIsolate(), holder, array, index, value); |
| 15255 } | 15260 } |
| 15256 | 15261 |
| 15257 | 15262 |
| 15258 Handle<Object> ExternalInt16Array::SetValue(Handle<ExternalInt16Array> array, | 15263 Handle<Object> ExternalInt16Array::SetValue(Handle<JSObject> holder, |
| 15264 Handle<ExternalInt16Array> array, |
| 15259 uint32_t index, | 15265 uint32_t index, |
| 15260 Handle<Object> value) { | 15266 Handle<Object> value) { |
| 15261 return ExternalArrayIntSetter<ExternalInt16Array, int16_t>( | 15267 return ExternalArrayIntSetter<ExternalInt16Array, int16_t>( |
| 15262 array->GetIsolate(), array, index, value); | 15268 array->GetIsolate(), holder, array, index, value); |
| 15263 } | 15269 } |
| 15264 | 15270 |
| 15265 | 15271 |
| 15266 Handle<Object> ExternalUint16Array::SetValue(Handle<ExternalUint16Array> array, | 15272 Handle<Object> ExternalUint16Array::SetValue(Handle<JSObject> holder, |
| 15273 Handle<ExternalUint16Array> array, |
| 15267 uint32_t index, | 15274 uint32_t index, |
| 15268 Handle<Object> value) { | 15275 Handle<Object> value) { |
| 15269 return ExternalArrayIntSetter<ExternalUint16Array, uint16_t>( | 15276 return ExternalArrayIntSetter<ExternalUint16Array, uint16_t>( |
| 15270 array->GetIsolate(), array, index, value); | 15277 array->GetIsolate(), holder, array, index, value); |
| 15271 } | 15278 } |
| 15272 | 15279 |
| 15273 | 15280 |
| 15274 Handle<Object> ExternalInt32Array::SetValue(Handle<ExternalInt32Array> array, | 15281 Handle<Object> ExternalInt32Array::SetValue(Handle<JSObject> holder, |
| 15282 Handle<ExternalInt32Array> array, |
| 15275 uint32_t index, | 15283 uint32_t index, |
| 15276 Handle<Object> value) { | 15284 Handle<Object> value) { |
| 15277 return ExternalArrayIntSetter<ExternalInt32Array, int32_t>( | 15285 return ExternalArrayIntSetter<ExternalInt32Array, int32_t>( |
| 15278 array->GetIsolate(), array, index, value); | 15286 array->GetIsolate(), holder, array, index, value); |
| 15279 } | 15287 } |
| 15280 | 15288 |
| 15281 | 15289 |
| 15282 Handle<Object> ExternalUint32Array::SetValue( | 15290 Handle<Object> ExternalUint32Array::SetValue(Handle<JSObject> holder, |
| 15283 Handle<ExternalUint32Array> array, | 15291 Handle<ExternalUint32Array> array, |
| 15284 uint32_t index, | 15292 uint32_t index, |
| 15285 Handle<Object> value) { | 15293 Handle<Object> value) { |
| 15286 uint32_t cast_value = 0; | 15294 uint32_t cast_value = 0; |
| 15287 if (index < static_cast<uint32_t>(array->length())) { | 15295 Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder); |
| 15288 if (value->IsSmi()) { | 15296 if (!view->WasNeutered()) { |
| 15289 int int_value = Handle<Smi>::cast(value)->value(); | 15297 if (index < static_cast<uint32_t>(array->length())) { |
| 15290 cast_value = static_cast<uint32_t>(int_value); | 15298 if (value->IsSmi()) { |
| 15291 } else if (value->IsHeapNumber()) { | 15299 int int_value = Handle<Smi>::cast(value)->value(); |
| 15292 double double_value = Handle<HeapNumber>::cast(value)->value(); | 15300 cast_value = static_cast<uint32_t>(int_value); |
| 15293 cast_value = static_cast<uint32_t>(DoubleToUint32(double_value)); | 15301 } else if (value->IsHeapNumber()) { |
| 15294 } else { | 15302 double double_value = Handle<HeapNumber>::cast(value)->value(); |
| 15295 // Clamp undefined to zero (default). All other types have been | 15303 cast_value = static_cast<uint32_t>(DoubleToUint32(double_value)); |
| 15296 // converted to a number type further up in the call chain. | 15304 } else { |
| 15297 DCHECK(value->IsUndefined()); | 15305 // Clamp undefined to zero (default). All other types have been |
| 15306 // converted to a number type further up in the call chain. |
| 15307 DCHECK(value->IsUndefined()); |
| 15308 } |
| 15309 array->set(index, cast_value); |
| 15298 } | 15310 } |
| 15299 array->set(index, cast_value); | |
| 15300 } | 15311 } |
| 15301 return array->GetIsolate()->factory()->NewNumberFromUint(cast_value); | 15312 return array->GetIsolate()->factory()->NewNumberFromUint(cast_value); |
| 15302 } | 15313 } |
| 15303 | 15314 |
| 15304 | 15315 |
| 15305 Handle<Object> ExternalFloat32Array::SetValue( | 15316 Handle<Object> ExternalFloat32Array::SetValue( |
| 15306 Handle<ExternalFloat32Array> array, | 15317 Handle<JSObject> holder, Handle<ExternalFloat32Array> array, uint32_t index, |
| 15307 uint32_t index, | |
| 15308 Handle<Object> value) { | 15318 Handle<Object> value) { |
| 15309 float cast_value = std::numeric_limits<float>::quiet_NaN(); | 15319 float cast_value = std::numeric_limits<float>::quiet_NaN(); |
| 15310 if (index < static_cast<uint32_t>(array->length())) { | 15320 Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder); |
| 15311 if (value->IsSmi()) { | 15321 if (!view->WasNeutered()) { |
| 15312 int int_value = Handle<Smi>::cast(value)->value(); | 15322 if (index < static_cast<uint32_t>(array->length())) { |
| 15313 cast_value = static_cast<float>(int_value); | 15323 if (value->IsSmi()) { |
| 15314 } else if (value->IsHeapNumber()) { | 15324 int int_value = Handle<Smi>::cast(value)->value(); |
| 15315 double double_value = Handle<HeapNumber>::cast(value)->value(); | 15325 cast_value = static_cast<float>(int_value); |
| 15316 cast_value = static_cast<float>(double_value); | 15326 } else if (value->IsHeapNumber()) { |
| 15317 } else { | 15327 double double_value = Handle<HeapNumber>::cast(value)->value(); |
| 15318 // Clamp undefined to NaN (default). All other types have been | 15328 cast_value = static_cast<float>(double_value); |
| 15319 // converted to a number type further up in the call chain. | 15329 } else { |
| 15320 DCHECK(value->IsUndefined()); | 15330 // Clamp undefined to NaN (default). All other types have been |
| 15331 // converted to a number type further up in the call chain. |
| 15332 DCHECK(value->IsUndefined()); |
| 15333 } |
| 15334 array->set(index, cast_value); |
| 15321 } | 15335 } |
| 15322 array->set(index, cast_value); | |
| 15323 } | 15336 } |
| 15324 return array->GetIsolate()->factory()->NewNumber(cast_value); | 15337 return array->GetIsolate()->factory()->NewNumber(cast_value); |
| 15325 } | 15338 } |
| 15326 | 15339 |
| 15327 | 15340 |
| 15328 Handle<Object> ExternalFloat64Array::SetValue( | 15341 Handle<Object> ExternalFloat64Array::SetValue( |
| 15329 Handle<ExternalFloat64Array> array, | 15342 Handle<JSObject> holder, Handle<ExternalFloat64Array> array, uint32_t index, |
| 15330 uint32_t index, | |
| 15331 Handle<Object> value) { | 15343 Handle<Object> value) { |
| 15332 double double_value = std::numeric_limits<double>::quiet_NaN(); | 15344 double double_value = std::numeric_limits<double>::quiet_NaN(); |
| 15333 if (index < static_cast<uint32_t>(array->length())) { | 15345 Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder); |
| 15334 if (value->IsNumber()) { | 15346 if (!view->WasNeutered()) { |
| 15335 double_value = value->Number(); | 15347 if (index < static_cast<uint32_t>(array->length())) { |
| 15336 } else { | 15348 if (value->IsNumber()) { |
| 15337 // Clamp undefined to NaN (default). All other types have been | 15349 double_value = value->Number(); |
| 15338 // converted to a number type further up in the call chain. | 15350 } else { |
| 15339 DCHECK(value->IsUndefined()); | 15351 // Clamp undefined to NaN (default). All other types have been |
| 15352 // converted to a number type further up in the call chain. |
| 15353 DCHECK(value->IsUndefined()); |
| 15354 } |
| 15355 array->set(index, double_value); |
| 15340 } | 15356 } |
| 15341 array->set(index, double_value); | |
| 15342 } | 15357 } |
| 15343 return array->GetIsolate()->factory()->NewNumber(double_value); | 15358 return array->GetIsolate()->factory()->NewNumber(double_value); |
| 15344 } | 15359 } |
| 15345 | 15360 |
| 15346 | 15361 |
| 15347 void GlobalObject::InvalidatePropertyCell(Handle<GlobalObject> global, | 15362 void GlobalObject::InvalidatePropertyCell(Handle<GlobalObject> global, |
| 15348 Handle<Name> name) { | 15363 Handle<Name> name) { |
| 15349 DCHECK(!global->HasFastProperties()); | 15364 DCHECK(!global->HasFastProperties()); |
| 15350 auto dictionary = handle(global->property_dictionary()); | 15365 auto dictionary = handle(global->property_dictionary()); |
| 15351 int entry = dictionary->FindEntry(name); | 15366 int entry = dictionary->FindEntry(name); |
| (...skipping 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16893 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 16908 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
| 16894 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 16909 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
| 16895 } | 16910 } |
| 16896 | 16911 |
| 16897 | 16912 |
| 16898 void JSArrayBuffer::Neuter() { | 16913 void JSArrayBuffer::Neuter() { |
| 16899 CHECK(is_neuterable()); | 16914 CHECK(is_neuterable()); |
| 16900 CHECK(is_external()); | 16915 CHECK(is_external()); |
| 16901 set_backing_store(NULL); | 16916 set_backing_store(NULL); |
| 16902 set_byte_length(Smi::FromInt(0)); | 16917 set_byte_length(Smi::FromInt(0)); |
| 16918 set_was_neutered(true); |
| 16903 } | 16919 } |
| 16904 | 16920 |
| 16905 | 16921 |
| 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 | |
| 16925 static ElementsKind FixedToExternalElementsKind(ElementsKind elements_kind) { | 16922 static ElementsKind FixedToExternalElementsKind(ElementsKind elements_kind) { |
| 16926 switch (elements_kind) { | 16923 switch (elements_kind) { |
| 16927 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 16924 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
| 16928 case TYPE##_ELEMENTS: return EXTERNAL_##TYPE##_ELEMENTS; | 16925 case TYPE##_ELEMENTS: return EXTERNAL_##TYPE##_ELEMENTS; |
| 16929 | 16926 |
| 16930 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 16927 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
| 16931 #undef TYPED_ARRAY_CASE | 16928 #undef TYPED_ARRAY_CASE |
| 16932 | 16929 |
| 16933 default: | 16930 default: |
| 16934 UNREACHABLE(); | 16931 UNREACHABLE(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 16955 Runtime::SetupArrayBufferAllocatingData(isolate, buffer, | 16952 Runtime::SetupArrayBufferAllocatingData(isolate, buffer, |
| 16956 fixed_typed_array->DataSize(), false); | 16953 fixed_typed_array->DataSize(), false); |
| 16957 memcpy(buffer->backing_store(), | 16954 memcpy(buffer->backing_store(), |
| 16958 fixed_typed_array->DataPtr(), | 16955 fixed_typed_array->DataPtr(), |
| 16959 fixed_typed_array->DataSize()); | 16956 fixed_typed_array->DataSize()); |
| 16960 Handle<ExternalArray> new_elements = | 16957 Handle<ExternalArray> new_elements = |
| 16961 isolate->factory()->NewExternalArray( | 16958 isolate->factory()->NewExternalArray( |
| 16962 fixed_typed_array->length(), typed_array->type(), | 16959 fixed_typed_array->length(), typed_array->type(), |
| 16963 static_cast<uint8_t*>(buffer->backing_store())); | 16960 static_cast<uint8_t*>(buffer->backing_store())); |
| 16964 | 16961 |
| 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 } | |
| 16974 typed_array->set_buffer(*buffer); | 16962 typed_array->set_buffer(*buffer); |
| 16975 JSObject::SetMapAndElements(typed_array, new_map, new_elements); | 16963 JSObject::SetMapAndElements(typed_array, new_map, new_elements); |
| 16976 | 16964 |
| 16977 return buffer; | 16965 return buffer; |
| 16978 } | 16966 } |
| 16979 | 16967 |
| 16980 | 16968 |
| 16981 Handle<JSArrayBuffer> JSTypedArray::GetBuffer() { | 16969 Handle<JSArrayBuffer> JSTypedArray::GetBuffer() { |
| 16982 Handle<Object> result(buffer(), GetIsolate()); | 16970 Handle<Object> result(buffer(), GetIsolate()); |
| 16983 if (*result != Smi::FromInt(0)) { | 16971 if (*result != Smi::FromInt(0)) { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17090 if (!invalidate && old_type == PropertyCellType::kConstant && | 17078 if (!invalidate && old_type == PropertyCellType::kConstant && |
| 17091 new_type != PropertyCellType::kConstant) { | 17079 new_type != PropertyCellType::kConstant) { |
| 17092 auto isolate = dictionary->GetIsolate(); | 17080 auto isolate = dictionary->GetIsolate(); |
| 17093 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 17081 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 17094 isolate, DependentCode::kPropertyCellChangedGroup); | 17082 isolate, DependentCode::kPropertyCellChangedGroup); |
| 17095 } | 17083 } |
| 17096 return value; | 17084 return value; |
| 17097 } | 17085 } |
| 17098 | 17086 |
| 17099 } } // namespace v8::internal | 17087 } } // namespace v8::internal |
| OLD | NEW |