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