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