| 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 13312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13323 case FAST_ELEMENTS: | 13323 case FAST_ELEMENTS: |
| 13324 case FAST_HOLEY_SMI_ELEMENTS: | 13324 case FAST_HOLEY_SMI_ELEMENTS: |
| 13325 case FAST_HOLEY_ELEMENTS: | 13325 case FAST_HOLEY_ELEMENTS: |
| 13326 return SetFastElement(object, index, value, language_mode, | 13326 return SetFastElement(object, index, value, language_mode, |
| 13327 check_prototype); | 13327 check_prototype); |
| 13328 case FAST_DOUBLE_ELEMENTS: | 13328 case FAST_DOUBLE_ELEMENTS: |
| 13329 case FAST_HOLEY_DOUBLE_ELEMENTS: | 13329 case FAST_HOLEY_DOUBLE_ELEMENTS: |
| 13330 return SetFastDoubleElement(object, index, value, language_mode, | 13330 return SetFastDoubleElement(object, index, value, language_mode, |
| 13331 check_prototype); | 13331 check_prototype); |
| 13332 | 13332 |
| 13333 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 13333 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
| 13334 case EXTERNAL_##TYPE##_ELEMENTS: { \ | 13334 case EXTERNAL_##TYPE##_ELEMENTS: { \ |
| 13335 Handle<External##Type##Array> array( \ | 13335 Handle<External##Type##Array> array( \ |
| 13336 External##Type##Array::cast(object->elements())); \ | 13336 External##Type##Array::cast(object->elements())); \ |
| 13337 return External##Type##Array::SetValue(array, index, value); \ | 13337 return External##Type##Array::SetValue(object, array, index, value); \ |
| 13338 } \ | 13338 } \ |
| 13339 case TYPE##_ELEMENTS: { \ | 13339 case TYPE##_ELEMENTS: { \ |
| 13340 Handle<Fixed##Type##Array> array( \ | 13340 Handle<Fixed##Type##Array> array( \ |
| 13341 Fixed##Type##Array::cast(object->elements())); \ | 13341 Fixed##Type##Array::cast(object->elements())); \ |
| 13342 return Fixed##Type##Array::SetValue(array, index, value); \ | 13342 return Fixed##Type##Array::SetValue(object, array, index, value); \ |
| 13343 } | 13343 } |
| 13344 | 13344 |
| 13345 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 13345 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
| 13346 | 13346 |
| 13347 #undef TYPED_ARRAY_CASE | 13347 #undef TYPED_ARRAY_CASE |
| 13348 | 13348 |
| 13349 case DICTIONARY_ELEMENTS: | 13349 case DICTIONARY_ELEMENTS: |
| 13350 return SetDictionaryElement(object, index, value, attributes, | 13350 return SetDictionaryElement(object, index, value, attributes, |
| 13351 language_mode, check_prototype, set_mode); | 13351 language_mode, check_prototype, set_mode); |
| 13352 case SLOPPY_ARGUMENTS_ELEMENTS: { | 13352 case SLOPPY_ARGUMENTS_ELEMENTS: { |
| 13353 Handle<FixedArray> parameter_map(FixedArray::cast(object->elements())); | 13353 Handle<FixedArray> parameter_map(FixedArray::cast(object->elements())); |
| (...skipping 1845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15199 #undef INSTANCE_TYPE_TO_ELEMENT_SIZE | 15199 #undef INSTANCE_TYPE_TO_ELEMENT_SIZE |
| 15200 | 15200 |
| 15201 default: | 15201 default: |
| 15202 UNREACHABLE(); | 15202 UNREACHABLE(); |
| 15203 return 0; | 15203 return 0; |
| 15204 } | 15204 } |
| 15205 } | 15205 } |
| 15206 | 15206 |
| 15207 | 15207 |
| 15208 Handle<Object> ExternalUint8ClampedArray::SetValue( | 15208 Handle<Object> ExternalUint8ClampedArray::SetValue( |
| 15209 Handle<ExternalUint8ClampedArray> array, | 15209 Handle<JSObject> holder, Handle<ExternalUint8ClampedArray> array, |
| 15210 uint32_t index, | 15210 uint32_t index, Handle<Object> value) { |
| 15211 Handle<Object> value) { | |
| 15212 uint8_t clamped_value = 0; | 15211 uint8_t clamped_value = 0; |
| 15213 if (index < static_cast<uint32_t>(array->length())) { | 15212 Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder); |
| 15214 if (value->IsSmi()) { | 15213 if (!view->WasNeutered()) { |
| 15215 int int_value = Handle<Smi>::cast(value)->value(); | 15214 if (index < static_cast<uint32_t>(array->length())) { |
| 15216 if (int_value < 0) { | 15215 if (value->IsSmi()) { |
| 15217 clamped_value = 0; | 15216 int int_value = Handle<Smi>::cast(value)->value(); |
| 15218 } else if (int_value > 255) { | 15217 if (int_value < 0) { |
| 15219 clamped_value = 255; | 15218 clamped_value = 0; |
| 15219 } else if (int_value > 255) { |
| 15220 clamped_value = 255; |
| 15221 } else { |
| 15222 clamped_value = static_cast<uint8_t>(int_value); |
| 15223 } |
| 15224 } else if (value->IsHeapNumber()) { |
| 15225 double double_value = Handle<HeapNumber>::cast(value)->value(); |
| 15226 if (!(double_value > 0)) { |
| 15227 // NaN and less than zero clamp to zero. |
| 15228 clamped_value = 0; |
| 15229 } else if (double_value > 255) { |
| 15230 // Greater than 255 clamp to 255. |
| 15231 clamped_value = 255; |
| 15232 } else { |
| 15233 // Other doubles are rounded to the nearest integer. |
| 15234 clamped_value = static_cast<uint8_t>(lrint(double_value)); |
| 15235 } |
| 15220 } else { | 15236 } else { |
| 15221 clamped_value = static_cast<uint8_t>(int_value); | 15237 // Clamp undefined to zero (default). All other types have been |
| 15238 // converted to a number type further up in the call chain. |
| 15239 DCHECK(value->IsUndefined()); |
| 15222 } | 15240 } |
| 15223 } else if (value->IsHeapNumber()) { | 15241 array->set(index, clamped_value); |
| 15224 double double_value = Handle<HeapNumber>::cast(value)->value(); | |
| 15225 if (!(double_value > 0)) { | |
| 15226 // NaN and less than zero clamp to zero. | |
| 15227 clamped_value = 0; | |
| 15228 } else if (double_value > 255) { | |
| 15229 // Greater than 255 clamp to 255. | |
| 15230 clamped_value = 255; | |
| 15231 } else { | |
| 15232 // Other doubles are rounded to the nearest integer. | |
| 15233 clamped_value = static_cast<uint8_t>(lrint(double_value)); | |
| 15234 } | |
| 15235 } else { | |
| 15236 // Clamp undefined to zero (default). All other types have been | |
| 15237 // converted to a number type further up in the call chain. | |
| 15238 DCHECK(value->IsUndefined()); | |
| 15239 } | 15242 } |
| 15240 array->set(index, clamped_value); | |
| 15241 } | 15243 } |
| 15242 return handle(Smi::FromInt(clamped_value), array->GetIsolate()); | 15244 return handle(Smi::FromInt(clamped_value), array->GetIsolate()); |
| 15243 } | 15245 } |
| 15244 | 15246 |
| 15245 | 15247 |
| 15246 template<typename ExternalArrayClass, typename ValueType> | 15248 template <typename ExternalArrayClass, typename ValueType> |
| 15247 static Handle<Object> ExternalArrayIntSetter( | 15249 static Handle<Object> ExternalArrayIntSetter( |
| 15248 Isolate* isolate, | 15250 Isolate* isolate, Handle<JSObject> holder, |
| 15249 Handle<ExternalArrayClass> receiver, | 15251 Handle<ExternalArrayClass> receiver, uint32_t index, Handle<Object> value) { |
| 15250 uint32_t index, | |
| 15251 Handle<Object> value) { | |
| 15252 ValueType cast_value = 0; | 15252 ValueType cast_value = 0; |
| 15253 if (index < static_cast<uint32_t>(receiver->length())) { | 15253 Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder); |
| 15254 if (value->IsSmi()) { | 15254 if (!view->WasNeutered()) { |
| 15255 int int_value = Handle<Smi>::cast(value)->value(); | 15255 if (index < static_cast<uint32_t>(receiver->length())) { |
| 15256 cast_value = static_cast<ValueType>(int_value); | 15256 if (value->IsSmi()) { |
| 15257 } else if (value->IsHeapNumber()) { | 15257 int int_value = Handle<Smi>::cast(value)->value(); |
| 15258 double double_value = Handle<HeapNumber>::cast(value)->value(); | 15258 cast_value = static_cast<ValueType>(int_value); |
| 15259 cast_value = static_cast<ValueType>(DoubleToInt32(double_value)); | 15259 } else if (value->IsHeapNumber()) { |
| 15260 } else { | 15260 double double_value = Handle<HeapNumber>::cast(value)->value(); |
| 15261 // Clamp undefined to zero (default). All other types have been | 15261 cast_value = static_cast<ValueType>(DoubleToInt32(double_value)); |
| 15262 // converted to a number type further up in the call chain. | 15262 } else { |
| 15263 DCHECK(value->IsUndefined()); | 15263 // Clamp undefined to zero (default). All other types have been |
| 15264 // converted to a number type further up in the call chain. |
| 15265 DCHECK(value->IsUndefined()); |
| 15266 } |
| 15267 receiver->set(index, cast_value); |
| 15264 } | 15268 } |
| 15265 receiver->set(index, cast_value); | |
| 15266 } | 15269 } |
| 15267 return isolate->factory()->NewNumberFromInt(cast_value); | 15270 return isolate->factory()->NewNumberFromInt(cast_value); |
| 15268 } | 15271 } |
| 15269 | 15272 |
| 15270 | 15273 |
| 15271 Handle<Object> ExternalInt8Array::SetValue(Handle<ExternalInt8Array> array, | 15274 Handle<Object> ExternalInt8Array::SetValue(Handle<JSObject> holder, |
| 15275 Handle<ExternalInt8Array> array, |
| 15272 uint32_t index, | 15276 uint32_t index, |
| 15273 Handle<Object> value) { | 15277 Handle<Object> value) { |
| 15274 return ExternalArrayIntSetter<ExternalInt8Array, int8_t>( | 15278 return ExternalArrayIntSetter<ExternalInt8Array, int8_t>( |
| 15275 array->GetIsolate(), array, index, value); | 15279 array->GetIsolate(), holder, array, index, value); |
| 15276 } | 15280 } |
| 15277 | 15281 |
| 15278 | 15282 |
| 15279 Handle<Object> ExternalUint8Array::SetValue(Handle<ExternalUint8Array> array, | 15283 Handle<Object> ExternalUint8Array::SetValue(Handle<JSObject> holder, |
| 15284 Handle<ExternalUint8Array> array, |
| 15280 uint32_t index, | 15285 uint32_t index, |
| 15281 Handle<Object> value) { | 15286 Handle<Object> value) { |
| 15282 return ExternalArrayIntSetter<ExternalUint8Array, uint8_t>( | 15287 return ExternalArrayIntSetter<ExternalUint8Array, uint8_t>( |
| 15283 array->GetIsolate(), array, index, value); | 15288 array->GetIsolate(), holder, array, index, value); |
| 15284 } | 15289 } |
| 15285 | 15290 |
| 15286 | 15291 |
| 15287 Handle<Object> ExternalInt16Array::SetValue(Handle<ExternalInt16Array> array, | 15292 Handle<Object> ExternalInt16Array::SetValue(Handle<JSObject> holder, |
| 15293 Handle<ExternalInt16Array> array, |
| 15288 uint32_t index, | 15294 uint32_t index, |
| 15289 Handle<Object> value) { | 15295 Handle<Object> value) { |
| 15290 return ExternalArrayIntSetter<ExternalInt16Array, int16_t>( | 15296 return ExternalArrayIntSetter<ExternalInt16Array, int16_t>( |
| 15291 array->GetIsolate(), array, index, value); | 15297 array->GetIsolate(), holder, array, index, value); |
| 15292 } | 15298 } |
| 15293 | 15299 |
| 15294 | 15300 |
| 15295 Handle<Object> ExternalUint16Array::SetValue(Handle<ExternalUint16Array> array, | 15301 Handle<Object> ExternalUint16Array::SetValue(Handle<JSObject> holder, |
| 15302 Handle<ExternalUint16Array> array, |
| 15296 uint32_t index, | 15303 uint32_t index, |
| 15297 Handle<Object> value) { | 15304 Handle<Object> value) { |
| 15298 return ExternalArrayIntSetter<ExternalUint16Array, uint16_t>( | 15305 return ExternalArrayIntSetter<ExternalUint16Array, uint16_t>( |
| 15299 array->GetIsolate(), array, index, value); | 15306 array->GetIsolate(), holder, array, index, value); |
| 15300 } | 15307 } |
| 15301 | 15308 |
| 15302 | 15309 |
| 15303 Handle<Object> ExternalInt32Array::SetValue(Handle<ExternalInt32Array> array, | 15310 Handle<Object> ExternalInt32Array::SetValue(Handle<JSObject> holder, |
| 15311 Handle<ExternalInt32Array> array, |
| 15304 uint32_t index, | 15312 uint32_t index, |
| 15305 Handle<Object> value) { | 15313 Handle<Object> value) { |
| 15306 return ExternalArrayIntSetter<ExternalInt32Array, int32_t>( | 15314 return ExternalArrayIntSetter<ExternalInt32Array, int32_t>( |
| 15307 array->GetIsolate(), array, index, value); | 15315 array->GetIsolate(), holder, array, index, value); |
| 15308 } | 15316 } |
| 15309 | 15317 |
| 15310 | 15318 |
| 15311 Handle<Object> ExternalUint32Array::SetValue( | 15319 Handle<Object> ExternalUint32Array::SetValue(Handle<JSObject> holder, |
| 15312 Handle<ExternalUint32Array> array, | 15320 Handle<ExternalUint32Array> array, |
| 15313 uint32_t index, | 15321 uint32_t index, |
| 15314 Handle<Object> value) { | 15322 Handle<Object> value) { |
| 15315 uint32_t cast_value = 0; | 15323 uint32_t cast_value = 0; |
| 15316 if (index < static_cast<uint32_t>(array->length())) { | 15324 Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder); |
| 15317 if (value->IsSmi()) { | 15325 if (!view->WasNeutered()) { |
| 15318 int int_value = Handle<Smi>::cast(value)->value(); | 15326 if (index < static_cast<uint32_t>(array->length())) { |
| 15319 cast_value = static_cast<uint32_t>(int_value); | 15327 if (value->IsSmi()) { |
| 15320 } else if (value->IsHeapNumber()) { | 15328 int int_value = Handle<Smi>::cast(value)->value(); |
| 15321 double double_value = Handle<HeapNumber>::cast(value)->value(); | 15329 cast_value = static_cast<uint32_t>(int_value); |
| 15322 cast_value = static_cast<uint32_t>(DoubleToUint32(double_value)); | 15330 } else if (value->IsHeapNumber()) { |
| 15323 } else { | 15331 double double_value = Handle<HeapNumber>::cast(value)->value(); |
| 15324 // Clamp undefined to zero (default). All other types have been | 15332 cast_value = static_cast<uint32_t>(DoubleToUint32(double_value)); |
| 15325 // converted to a number type further up in the call chain. | 15333 } else { |
| 15326 DCHECK(value->IsUndefined()); | 15334 // Clamp undefined to zero (default). All other types have been |
| 15335 // converted to a number type further up in the call chain. |
| 15336 DCHECK(value->IsUndefined()); |
| 15337 } |
| 15338 array->set(index, cast_value); |
| 15327 } | 15339 } |
| 15328 array->set(index, cast_value); | |
| 15329 } | 15340 } |
| 15330 return array->GetIsolate()->factory()->NewNumberFromUint(cast_value); | 15341 return array->GetIsolate()->factory()->NewNumberFromUint(cast_value); |
| 15331 } | 15342 } |
| 15332 | 15343 |
| 15333 | 15344 |
| 15334 Handle<Object> ExternalFloat32Array::SetValue( | 15345 Handle<Object> ExternalFloat32Array::SetValue( |
| 15335 Handle<ExternalFloat32Array> array, | 15346 Handle<JSObject> holder, Handle<ExternalFloat32Array> array, uint32_t index, |
| 15336 uint32_t index, | |
| 15337 Handle<Object> value) { | 15347 Handle<Object> value) { |
| 15338 float cast_value = std::numeric_limits<float>::quiet_NaN(); | 15348 float cast_value = std::numeric_limits<float>::quiet_NaN(); |
| 15339 if (index < static_cast<uint32_t>(array->length())) { | 15349 Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder); |
| 15340 if (value->IsSmi()) { | 15350 if (!view->WasNeutered()) { |
| 15341 int int_value = Handle<Smi>::cast(value)->value(); | 15351 if (index < static_cast<uint32_t>(array->length())) { |
| 15342 cast_value = static_cast<float>(int_value); | 15352 if (value->IsSmi()) { |
| 15343 } else if (value->IsHeapNumber()) { | 15353 int int_value = Handle<Smi>::cast(value)->value(); |
| 15344 double double_value = Handle<HeapNumber>::cast(value)->value(); | 15354 cast_value = static_cast<float>(int_value); |
| 15345 cast_value = static_cast<float>(double_value); | 15355 } else if (value->IsHeapNumber()) { |
| 15346 } else { | 15356 double double_value = Handle<HeapNumber>::cast(value)->value(); |
| 15347 // Clamp undefined to NaN (default). All other types have been | 15357 cast_value = static_cast<float>(double_value); |
| 15348 // converted to a number type further up in the call chain. | 15358 } else { |
| 15349 DCHECK(value->IsUndefined()); | 15359 // Clamp undefined to NaN (default). All other types have been |
| 15360 // converted to a number type further up in the call chain. |
| 15361 DCHECK(value->IsUndefined()); |
| 15362 } |
| 15363 array->set(index, cast_value); |
| 15350 } | 15364 } |
| 15351 array->set(index, cast_value); | |
| 15352 } | 15365 } |
| 15353 return array->GetIsolate()->factory()->NewNumber(cast_value); | 15366 return array->GetIsolate()->factory()->NewNumber(cast_value); |
| 15354 } | 15367 } |
| 15355 | 15368 |
| 15356 | 15369 |
| 15357 Handle<Object> ExternalFloat64Array::SetValue( | 15370 Handle<Object> ExternalFloat64Array::SetValue( |
| 15358 Handle<ExternalFloat64Array> array, | 15371 Handle<JSObject> holder, Handle<ExternalFloat64Array> array, uint32_t index, |
| 15359 uint32_t index, | |
| 15360 Handle<Object> value) { | 15372 Handle<Object> value) { |
| 15361 double double_value = std::numeric_limits<double>::quiet_NaN(); | 15373 double double_value = std::numeric_limits<double>::quiet_NaN(); |
| 15362 if (index < static_cast<uint32_t>(array->length())) { | 15374 Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder); |
| 15363 if (value->IsNumber()) { | 15375 if (!view->WasNeutered()) { |
| 15364 double_value = value->Number(); | 15376 if (index < static_cast<uint32_t>(array->length())) { |
| 15365 } else { | 15377 if (value->IsNumber()) { |
| 15366 // Clamp undefined to NaN (default). All other types have been | 15378 double_value = value->Number(); |
| 15367 // converted to a number type further up in the call chain. | 15379 } else { |
| 15368 DCHECK(value->IsUndefined()); | 15380 // Clamp undefined to NaN (default). All other types have been |
| 15381 // converted to a number type further up in the call chain. |
| 15382 DCHECK(value->IsUndefined()); |
| 15383 } |
| 15384 array->set(index, double_value); |
| 15369 } | 15385 } |
| 15370 array->set(index, double_value); | |
| 15371 } | 15386 } |
| 15372 return array->GetIsolate()->factory()->NewNumber(double_value); | 15387 return array->GetIsolate()->factory()->NewNumber(double_value); |
| 15373 } | 15388 } |
| 15374 | 15389 |
| 15375 | 15390 |
| 15376 void GlobalObject::InvalidatePropertyCell(Handle<GlobalObject> global, | 15391 void GlobalObject::InvalidatePropertyCell(Handle<GlobalObject> global, |
| 15377 Handle<Name> name) { | 15392 Handle<Name> name) { |
| 15378 DCHECK(!global->HasFastProperties()); | 15393 DCHECK(!global->HasFastProperties()); |
| 15379 auto dictionary = handle(global->property_dictionary()); | 15394 auto dictionary = handle(global->property_dictionary()); |
| 15380 int entry = dictionary->FindEntry(name); | 15395 int entry = dictionary->FindEntry(name); |
| (...skipping 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16922 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 16937 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
| 16923 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 16938 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
| 16924 } | 16939 } |
| 16925 | 16940 |
| 16926 | 16941 |
| 16927 void JSArrayBuffer::Neuter() { | 16942 void JSArrayBuffer::Neuter() { |
| 16928 CHECK(is_neuterable()); | 16943 CHECK(is_neuterable()); |
| 16929 CHECK(is_external()); | 16944 CHECK(is_external()); |
| 16930 set_backing_store(NULL); | 16945 set_backing_store(NULL); |
| 16931 set_byte_length(Smi::FromInt(0)); | 16946 set_byte_length(Smi::FromInt(0)); |
| 16947 set_was_neutered(true); |
| 16932 } | 16948 } |
| 16933 | 16949 |
| 16934 | 16950 |
| 16935 void JSArrayBufferView::NeuterView() { | |
| 16936 CHECK(JSArrayBuffer::cast(buffer())->is_neuterable()); | |
| 16937 set_byte_offset(Smi::FromInt(0)); | |
| 16938 set_byte_length(Smi::FromInt(0)); | |
| 16939 } | |
| 16940 | |
| 16941 | |
| 16942 void JSDataView::Neuter() { | |
| 16943 NeuterView(); | |
| 16944 } | |
| 16945 | |
| 16946 | |
| 16947 void JSTypedArray::Neuter() { | |
| 16948 NeuterView(); | |
| 16949 set_length(Smi::FromInt(0)); | |
| 16950 set_elements(GetHeap()->EmptyExternalArrayForMap(map())); | |
| 16951 } | |
| 16952 | |
| 16953 | |
| 16954 static ElementsKind FixedToExternalElementsKind(ElementsKind elements_kind) { | 16951 static ElementsKind FixedToExternalElementsKind(ElementsKind elements_kind) { |
| 16955 switch (elements_kind) { | 16952 switch (elements_kind) { |
| 16956 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 16953 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
| 16957 case TYPE##_ELEMENTS: return EXTERNAL_##TYPE##_ELEMENTS; | 16954 case TYPE##_ELEMENTS: return EXTERNAL_##TYPE##_ELEMENTS; |
| 16958 | 16955 |
| 16959 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 16956 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
| 16960 #undef TYPED_ARRAY_CASE | 16957 #undef TYPED_ARRAY_CASE |
| 16961 | 16958 |
| 16962 default: | 16959 default: |
| 16963 UNREACHABLE(); | 16960 UNREACHABLE(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 16984 Runtime::SetupArrayBufferAllocatingData(isolate, buffer, | 16981 Runtime::SetupArrayBufferAllocatingData(isolate, buffer, |
| 16985 fixed_typed_array->DataSize(), false); | 16982 fixed_typed_array->DataSize(), false); |
| 16986 memcpy(buffer->backing_store(), | 16983 memcpy(buffer->backing_store(), |
| 16987 fixed_typed_array->DataPtr(), | 16984 fixed_typed_array->DataPtr(), |
| 16988 fixed_typed_array->DataSize()); | 16985 fixed_typed_array->DataSize()); |
| 16989 Handle<ExternalArray> new_elements = | 16986 Handle<ExternalArray> new_elements = |
| 16990 isolate->factory()->NewExternalArray( | 16987 isolate->factory()->NewExternalArray( |
| 16991 fixed_typed_array->length(), typed_array->type(), | 16988 fixed_typed_array->length(), typed_array->type(), |
| 16992 static_cast<uint8_t*>(buffer->backing_store())); | 16989 static_cast<uint8_t*>(buffer->backing_store())); |
| 16993 | 16990 |
| 16994 Heap* heap = isolate->heap(); | |
| 16995 if (heap->InNewSpace(*typed_array)) { | |
| 16996 DCHECK(typed_array->weak_next() == isolate->heap()->undefined_value()); | |
| 16997 typed_array->set_weak_next(heap->new_array_buffer_views_list()); | |
| 16998 heap->set_new_array_buffer_views_list(*typed_array); | |
| 16999 } else { | |
| 17000 buffer->set_weak_first_view(*typed_array); | |
| 17001 DCHECK(typed_array->weak_next() == isolate->heap()->undefined_value()); | |
| 17002 } | |
| 17003 typed_array->set_buffer(*buffer); | 16991 typed_array->set_buffer(*buffer); |
| 17004 JSObject::SetMapAndElements(typed_array, new_map, new_elements); | 16992 JSObject::SetMapAndElements(typed_array, new_map, new_elements); |
| 17005 | 16993 |
| 17006 return buffer; | 16994 return buffer; |
| 17007 } | 16995 } |
| 17008 | 16996 |
| 17009 | 16997 |
| 17010 Handle<JSArrayBuffer> JSTypedArray::GetBuffer() { | 16998 Handle<JSArrayBuffer> JSTypedArray::GetBuffer() { |
| 17011 Handle<Object> result(buffer(), GetIsolate()); | 16999 Handle<Object> result(buffer(), GetIsolate()); |
| 17012 if (*result != Smi::FromInt(0)) { | 17000 if (*result != Smi::FromInt(0)) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17130 void PropertyCell::SetValueWithInvalidation(Handle<PropertyCell> cell, | 17118 void PropertyCell::SetValueWithInvalidation(Handle<PropertyCell> cell, |
| 17131 Handle<Object> new_value) { | 17119 Handle<Object> new_value) { |
| 17132 if (cell->value() != *new_value) { | 17120 if (cell->value() != *new_value) { |
| 17133 cell->set_value(*new_value); | 17121 cell->set_value(*new_value); |
| 17134 Isolate* isolate = cell->GetIsolate(); | 17122 Isolate* isolate = cell->GetIsolate(); |
| 17135 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 17123 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 17136 isolate, DependentCode::kPropertyCellChangedGroup); | 17124 isolate, DependentCode::kPropertyCellChangedGroup); |
| 17137 } | 17125 } |
| 17138 } | 17126 } |
| 17139 } } // namespace v8::internal | 17127 } } // namespace v8::internal |
| OLD | NEW |