| 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 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 os << "<FixedDoubleArray[" << FixedDoubleArray::cast(this)->length() | 1270 os << "<FixedDoubleArray[" << FixedDoubleArray::cast(this)->length() |
| 1271 << "]>"; | 1271 << "]>"; |
| 1272 break; | 1272 break; |
| 1273 case BYTE_ARRAY_TYPE: | 1273 case BYTE_ARRAY_TYPE: |
| 1274 os << "<ByteArray[" << ByteArray::cast(this)->length() << "]>"; | 1274 os << "<ByteArray[" << ByteArray::cast(this)->length() << "]>"; |
| 1275 break; | 1275 break; |
| 1276 case FREE_SPACE_TYPE: | 1276 case FREE_SPACE_TYPE: |
| 1277 os << "<FreeSpace[" << FreeSpace::cast(this)->Size() << "]>"; | 1277 os << "<FreeSpace[" << FreeSpace::cast(this)->Size() << "]>"; |
| 1278 break; | 1278 break; |
| 1279 #define TYPED_ARRAY_SHORT_PRINT(Type, type, TYPE, ctype, size) \ | 1279 #define TYPED_ARRAY_SHORT_PRINT(Type, type, TYPE, ctype, size) \ |
| 1280 case EXTERNAL_##TYPE##_ARRAY_TYPE: \ | |
| 1281 os << "<External" #Type "Array[" \ | |
| 1282 << External##Type##Array::cast(this)->length() << "]>"; \ | |
| 1283 break; \ | |
| 1284 case FIXED_##TYPE##_ARRAY_TYPE: \ | 1280 case FIXED_##TYPE##_ARRAY_TYPE: \ |
| 1285 os << "<Fixed" #Type "Array[" << Fixed##Type##Array::cast(this)->length() \ | 1281 os << "<Fixed" #Type "Array[" << Fixed##Type##Array::cast(this)->length() \ |
| 1286 << "]>"; \ | 1282 << "]>"; \ |
| 1287 break; | 1283 break; |
| 1288 | 1284 |
| 1289 TYPED_ARRAYS(TYPED_ARRAY_SHORT_PRINT) | 1285 TYPED_ARRAYS(TYPED_ARRAY_SHORT_PRINT) |
| 1290 #undef TYPED_ARRAY_SHORT_PRINT | 1286 #undef TYPED_ARRAY_SHORT_PRINT |
| 1291 | 1287 |
| 1292 case SHARED_FUNCTION_INFO_TYPE: { | 1288 case SHARED_FUNCTION_INFO_TYPE: { |
| 1293 SharedFunctionInfo* shared = SharedFunctionInfo::cast(this); | 1289 SharedFunctionInfo* shared = SharedFunctionInfo::cast(this); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1496 | 1492 |
| 1497 case HEAP_NUMBER_TYPE: | 1493 case HEAP_NUMBER_TYPE: |
| 1498 case MUTABLE_HEAP_NUMBER_TYPE: | 1494 case MUTABLE_HEAP_NUMBER_TYPE: |
| 1499 case FLOAT32X4_TYPE: | 1495 case FLOAT32X4_TYPE: |
| 1500 case FILLER_TYPE: | 1496 case FILLER_TYPE: |
| 1501 case BYTE_ARRAY_TYPE: | 1497 case BYTE_ARRAY_TYPE: |
| 1502 case FREE_SPACE_TYPE: | 1498 case FREE_SPACE_TYPE: |
| 1503 break; | 1499 break; |
| 1504 | 1500 |
| 1505 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 1501 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
| 1506 case EXTERNAL_##TYPE##_ARRAY_TYPE: \ | |
| 1507 break; \ | |
| 1508 \ | |
| 1509 case FIXED_##TYPE##_ARRAY_TYPE: \ | 1502 case FIXED_##TYPE##_ARRAY_TYPE: \ |
| 1510 reinterpret_cast<FixedTypedArrayBase*>(this) \ | 1503 reinterpret_cast<FixedTypedArrayBase*>(this) \ |
| 1511 ->FixedTypedArrayBaseIterateBody(v); \ | 1504 ->FixedTypedArrayBaseIterateBody(v); \ |
| 1512 break; | 1505 break; |
| 1513 | 1506 |
| 1514 | 1507 |
| 1515 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 1508 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
| 1516 #undef TYPED_ARRAY_CASE | 1509 #undef TYPED_ARRAY_CASE |
| 1517 | 1510 |
| 1518 case SHARED_FUNCTION_INFO_TYPE: { | 1511 case SHARED_FUNCTION_INFO_TYPE: { |
| (...skipping 1787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3306 // Fetch before transforming the object since the encoding may become | 3299 // Fetch before transforming the object since the encoding may become |
| 3307 // incompatible with what's cached in |it|. | 3300 // incompatible with what's cached in |it|. |
| 3308 bool is_observed = receiver->map()->is_observed() && | 3301 bool is_observed = receiver->map()->is_observed() && |
| 3309 (it->IsElement() || | 3302 (it->IsElement() || |
| 3310 !it->isolate()->IsInternallyUsedPropertyName(it->name())); | 3303 !it->isolate()->IsInternallyUsedPropertyName(it->name())); |
| 3311 MaybeHandle<Object> maybe_old; | 3304 MaybeHandle<Object> maybe_old; |
| 3312 if (is_observed) maybe_old = it->GetDataValue(); | 3305 if (is_observed) maybe_old = it->GetDataValue(); |
| 3313 | 3306 |
| 3314 Handle<Object> to_assign = value; | 3307 Handle<Object> to_assign = value; |
| 3315 // Convert the incoming value to a number for storing into typed arrays. | 3308 // Convert the incoming value to a number for storing into typed arrays. |
| 3316 if (it->IsElement() && (receiver->HasExternalArrayElements() || | 3309 if (it->IsElement() && receiver->HasFixedTypedArrayElements()) { |
| 3317 receiver->HasFixedTypedArrayElements())) { | |
| 3318 if (!value->IsNumber() && !value->IsUndefined()) { | 3310 if (!value->IsNumber() && !value->IsUndefined()) { |
| 3319 ASSIGN_RETURN_ON_EXCEPTION(it->isolate(), to_assign, | 3311 ASSIGN_RETURN_ON_EXCEPTION(it->isolate(), to_assign, |
| 3320 Execution::ToNumber(it->isolate(), value), | 3312 Execution::ToNumber(it->isolate(), value), |
| 3321 Object); | 3313 Object); |
| 3322 // ToNumber above might modify the receiver, causing the cached | 3314 // ToNumber above might modify the receiver, causing the cached |
| 3323 // holder_map to mismatch the actual holder->map() after this point. | 3315 // holder_map to mismatch the actual holder->map() after this point. |
| 3324 // Reload the map to be in consistent state. Other cached state cannot | 3316 // Reload the map to be in consistent state. Other cached state cannot |
| 3325 // have been invalidated since typed array elements cannot be reconfigured | 3317 // have been invalidated since typed array elements cannot be reconfigured |
| 3326 // in any way. | 3318 // in any way. |
| 3327 it->ReloadHolderMap(); | 3319 it->ReloadHolderMap(); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3419 | 3411 |
| 3420 if (it->IsElement()) { | 3412 if (it->IsElement()) { |
| 3421 if (receiver->IsJSArray()) { | 3413 if (receiver->IsJSArray()) { |
| 3422 Handle<JSArray> array = Handle<JSArray>::cast(receiver); | 3414 Handle<JSArray> array = Handle<JSArray>::cast(receiver); |
| 3423 if (JSArray::WouldChangeReadOnlyLength(array, it->index())) { | 3415 if (JSArray::WouldChangeReadOnlyLength(array, it->index())) { |
| 3424 if (is_sloppy(language_mode)) return value; | 3416 if (is_sloppy(language_mode)) return value; |
| 3425 return JSArray::ReadOnlyLengthError(array); | 3417 return JSArray::ReadOnlyLengthError(array); |
| 3426 } | 3418 } |
| 3427 | 3419 |
| 3428 if (FLAG_trace_external_array_abuse && | 3420 if (FLAG_trace_external_array_abuse && |
| 3429 (array->HasExternalArrayElements() || | 3421 array->HasFixedTypedArrayElements()) { |
| 3430 array->HasFixedTypedArrayElements())) { | |
| 3431 CheckArrayAbuse(array, "typed elements write", it->index(), true); | 3422 CheckArrayAbuse(array, "typed elements write", it->index(), true); |
| 3432 } | 3423 } |
| 3433 | 3424 |
| 3434 if (FLAG_trace_js_array_abuse && !array->HasExternalArrayElements() && | 3425 if (FLAG_trace_js_array_abuse && !array->HasFixedTypedArrayElements()) { |
| 3435 !array->HasFixedTypedArrayElements()) { | |
| 3436 CheckArrayAbuse(array, "elements write", it->index(), false); | 3426 CheckArrayAbuse(array, "elements write", it->index(), false); |
| 3437 } | 3427 } |
| 3438 } | 3428 } |
| 3439 | 3429 |
| 3440 MaybeHandle<Object> result = | 3430 MaybeHandle<Object> result = |
| 3441 JSObject::AddDataElement(receiver, it->index(), value, attributes); | 3431 JSObject::AddDataElement(receiver, it->index(), value, attributes); |
| 3442 JSObject::ValidateElements(receiver); | 3432 JSObject::ValidateElements(receiver); |
| 3443 return result; | 3433 return result; |
| 3444 } else { | 3434 } else { |
| 3445 // Migrate to the most up-to-date map that will be able to store |value| | 3435 // Migrate to the most up-to-date map that will be able to store |value| |
| (...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4254 case LookupIterator::DATA: { | 4244 case LookupIterator::DATA: { |
| 4255 PropertyDetails details = it->property_details(); | 4245 PropertyDetails details = it->property_details(); |
| 4256 Handle<Object> old_value = it->factory()->the_hole_value(); | 4246 Handle<Object> old_value = it->factory()->the_hole_value(); |
| 4257 // Regular property update if the attributes match. | 4247 // Regular property update if the attributes match. |
| 4258 if (details.attributes() == attributes) { | 4248 if (details.attributes() == attributes) { |
| 4259 return SetDataProperty(it, value); | 4249 return SetDataProperty(it, value); |
| 4260 } | 4250 } |
| 4261 | 4251 |
| 4262 // Special case: properties of typed arrays cannot be reconfigured to | 4252 // Special case: properties of typed arrays cannot be reconfigured to |
| 4263 // non-writable nor to non-enumerable. | 4253 // non-writable nor to non-enumerable. |
| 4264 if (it->IsElement() && (object->HasExternalArrayElements() || | 4254 if (it->IsElement() && object->HasFixedTypedArrayElements()) { |
| 4265 object->HasFixedTypedArrayElements())) { | |
| 4266 return RedefineNonconfigurableProperty(it->isolate(), it->GetName(), | 4255 return RedefineNonconfigurableProperty(it->isolate(), it->GetName(), |
| 4267 value, STRICT); | 4256 value, STRICT); |
| 4268 } | 4257 } |
| 4269 | 4258 |
| 4270 // Reconfigure the data property if the attributes mismatch. | 4259 // Reconfigure the data property if the attributes mismatch. |
| 4271 if (is_observed) old_value = it->GetDataValue(); | 4260 if (is_observed) old_value = it->GetDataValue(); |
| 4272 | 4261 |
| 4273 it->ReconfigureDataProperty(value, attributes); | 4262 it->ReconfigureDataProperty(value, attributes); |
| 4274 it->WriteDataValue(value); | 4263 it->WriteDataValue(value); |
| 4275 | 4264 |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4838 : elements->length(); | 4827 : elements->length(); |
| 4839 int used = object->GetFastElementsUsage(); | 4828 int used = object->GetFastElementsUsage(); |
| 4840 Handle<SeededNumberDictionary> dictionary = | 4829 Handle<SeededNumberDictionary> dictionary = |
| 4841 SeededNumberDictionary::New(isolate, used); | 4830 SeededNumberDictionary::New(isolate, used); |
| 4842 return CopyFastElementsToDictionary(elements, length, dictionary); | 4831 return CopyFastElementsToDictionary(elements, length, dictionary); |
| 4843 } | 4832 } |
| 4844 | 4833 |
| 4845 | 4834 |
| 4846 Handle<SeededNumberDictionary> JSObject::NormalizeElements( | 4835 Handle<SeededNumberDictionary> JSObject::NormalizeElements( |
| 4847 Handle<JSObject> object) { | 4836 Handle<JSObject> object) { |
| 4848 DCHECK(!object->HasExternalArrayElements() && | 4837 DCHECK(!object->HasFixedTypedArrayElements()); |
| 4849 !object->HasFixedTypedArrayElements()); | |
| 4850 Isolate* isolate = object->GetIsolate(); | 4838 Isolate* isolate = object->GetIsolate(); |
| 4851 | 4839 |
| 4852 // Find the backing store. | 4840 // Find the backing store. |
| 4853 Handle<FixedArrayBase> elements(object->elements(), isolate); | 4841 Handle<FixedArrayBase> elements(object->elements(), isolate); |
| 4854 bool is_arguments = object->HasSloppyArgumentsElements(); | 4842 bool is_arguments = object->HasSloppyArgumentsElements(); |
| 4855 if (is_arguments) { | 4843 if (is_arguments) { |
| 4856 FixedArray* parameter_map = FixedArray::cast(*elements); | 4844 FixedArray* parameter_map = FixedArray::cast(*elements); |
| 4857 elements = handle(FixedArrayBase::cast(parameter_map->get(1)), isolate); | 4845 elements = handle(FixedArrayBase::cast(parameter_map->get(1)), isolate); |
| 4858 } | 4846 } |
| 4859 | 4847 |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5344 if (!key->IsUndefined()) { | 5332 if (!key->IsUndefined()) { |
| 5345 return true; | 5333 return true; |
| 5346 } | 5334 } |
| 5347 | 5335 |
| 5348 // Check if the object is among the indexed properties. | 5336 // Check if the object is among the indexed properties. |
| 5349 ElementsKind kind = GetElementsKind(); | 5337 ElementsKind kind = GetElementsKind(); |
| 5350 switch (kind) { | 5338 switch (kind) { |
| 5351 // Raw pixels and external arrays do not reference other | 5339 // Raw pixels and external arrays do not reference other |
| 5352 // objects. | 5340 // objects. |
| 5353 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 5341 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
| 5354 case EXTERNAL_##TYPE##_ELEMENTS: \ | |
| 5355 case TYPE##_ELEMENTS: \ | 5342 case TYPE##_ELEMENTS: \ |
| 5356 break; | 5343 break; |
| 5357 | 5344 |
| 5358 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 5345 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
| 5359 #undef TYPED_ARRAY_CASE | 5346 #undef TYPED_ARRAY_CASE |
| 5360 | 5347 |
| 5361 case FAST_DOUBLE_ELEMENTS: | 5348 case FAST_DOUBLE_ELEMENTS: |
| 5362 case FAST_HOLEY_DOUBLE_ELEMENTS: | 5349 case FAST_HOLEY_DOUBLE_ELEMENTS: |
| 5363 break; | 5350 break; |
| 5364 case FAST_SMI_ELEMENTS: | 5351 case FAST_SMI_ELEMENTS: |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5454 | 5441 |
| 5455 if (object->IsJSGlobalProxy()) { | 5442 if (object->IsJSGlobalProxy()) { |
| 5456 PrototypeIterator iter(isolate, object); | 5443 PrototypeIterator iter(isolate, object); |
| 5457 if (iter.IsAtEnd()) return object; | 5444 if (iter.IsAtEnd()) return object; |
| 5458 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); | 5445 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); |
| 5459 return PreventExtensions( | 5446 return PreventExtensions( |
| 5460 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter))); | 5447 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter))); |
| 5461 } | 5448 } |
| 5462 | 5449 |
| 5463 // It's not possible to seal objects with external array elements | 5450 // It's not possible to seal objects with external array elements |
| 5464 if (object->HasExternalArrayElements() || | 5451 if (object->HasFixedTypedArrayElements()) { |
| 5465 object->HasFixedTypedArrayElements()) { | |
| 5466 THROW_NEW_ERROR( | 5452 THROW_NEW_ERROR( |
| 5467 isolate, NewTypeError(MessageTemplate::kCannotPreventExtExternalArray), | 5453 isolate, NewTypeError(MessageTemplate::kCannotPreventExtExternalArray), |
| 5468 Object); | 5454 Object); |
| 5469 } | 5455 } |
| 5470 | 5456 |
| 5471 // If there are fast elements we normalize. | 5457 // If there are fast elements we normalize. |
| 5472 Handle<SeededNumberDictionary> dictionary = NormalizeElements(object); | 5458 Handle<SeededNumberDictionary> dictionary = NormalizeElements(object); |
| 5473 DCHECK(object->HasDictionaryElements() || object->HasSlowArgumentsElements()); | 5459 DCHECK(object->HasDictionaryElements() || object->HasSlowArgumentsElements()); |
| 5474 | 5460 |
| 5475 // Make sure that we never go back to fast case. | 5461 // Make sure that we never go back to fast case. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5548 | 5534 |
| 5549 if (object->IsJSGlobalProxy()) { | 5535 if (object->IsJSGlobalProxy()) { |
| 5550 PrototypeIterator iter(isolate, object); | 5536 PrototypeIterator iter(isolate, object); |
| 5551 if (iter.IsAtEnd()) return object; | 5537 if (iter.IsAtEnd()) return object; |
| 5552 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); | 5538 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); |
| 5553 return PreventExtensionsWithTransition<attrs>( | 5539 return PreventExtensionsWithTransition<attrs>( |
| 5554 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter))); | 5540 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter))); |
| 5555 } | 5541 } |
| 5556 | 5542 |
| 5557 // It's not possible to seal or freeze objects with external array elements | 5543 // It's not possible to seal or freeze objects with external array elements |
| 5558 if (object->HasExternalArrayElements() || | 5544 if (object->HasFixedTypedArrayElements()) { |
| 5559 object->HasFixedTypedArrayElements()) { | |
| 5560 THROW_NEW_ERROR( | 5545 THROW_NEW_ERROR( |
| 5561 isolate, NewTypeError(MessageTemplate::kCannotPreventExtExternalArray), | 5546 isolate, NewTypeError(MessageTemplate::kCannotPreventExtExternalArray), |
| 5562 Object); | 5547 Object); |
| 5563 } | 5548 } |
| 5564 | 5549 |
| 5565 Handle<SeededNumberDictionary> new_element_dictionary; | 5550 Handle<SeededNumberDictionary> new_element_dictionary; |
| 5566 if (!object->HasDictionaryElements()) { | 5551 if (!object->HasDictionaryElements()) { |
| 5567 int length = | 5552 int length = |
| 5568 object->IsJSArray() | 5553 object->IsJSArray() |
| 5569 ? Smi::cast(Handle<JSArray>::cast(object)->length())->value() | 5554 ? Smi::cast(Handle<JSArray>::cast(object)->length())->value() |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5818 if (copying) { | 5803 if (copying) { |
| 5819 // Creating object copy for literals. No strict mode needed. | 5804 // Creating object copy for literals. No strict mode needed. |
| 5820 JSObject::SetProperty(copy, key_string, result, SLOPPY).Assert(); | 5805 JSObject::SetProperty(copy, key_string, result, SLOPPY).Assert(); |
| 5821 } | 5806 } |
| 5822 } | 5807 } |
| 5823 } | 5808 } |
| 5824 } | 5809 } |
| 5825 | 5810 |
| 5826 // Deep copy own elements. | 5811 // Deep copy own elements. |
| 5827 // Pixel elements cannot be created using an object literal. | 5812 // Pixel elements cannot be created using an object literal. |
| 5828 DCHECK(!copy->HasExternalArrayElements()); | 5813 DCHECK(!copy->HasFixedTypedArrayElements()); |
| 5829 switch (kind) { | 5814 switch (kind) { |
| 5830 case FAST_SMI_ELEMENTS: | 5815 case FAST_SMI_ELEMENTS: |
| 5831 case FAST_ELEMENTS: | 5816 case FAST_ELEMENTS: |
| 5832 case FAST_HOLEY_SMI_ELEMENTS: | 5817 case FAST_HOLEY_SMI_ELEMENTS: |
| 5833 case FAST_HOLEY_ELEMENTS: { | 5818 case FAST_HOLEY_ELEMENTS: { |
| 5834 Handle<FixedArray> elements(FixedArray::cast(copy->elements())); | 5819 Handle<FixedArray> elements(FixedArray::cast(copy->elements())); |
| 5835 if (elements->map() == isolate->heap()->fixed_cow_array_map()) { | 5820 if (elements->map() == isolate->heap()->fixed_cow_array_map()) { |
| 5836 #ifdef DEBUG | 5821 #ifdef DEBUG |
| 5837 for (int i = 0; i < elements->length(); i++) { | 5822 for (int i = 0; i < elements->length(); i++) { |
| 5838 DCHECK(!elements->get(i)->IsJSObject()); | 5823 DCHECK(!elements->get(i)->IsJSObject()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5880 } | 5865 } |
| 5881 break; | 5866 break; |
| 5882 } | 5867 } |
| 5883 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: | 5868 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: |
| 5884 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: | 5869 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: |
| 5885 UNIMPLEMENTED(); | 5870 UNIMPLEMENTED(); |
| 5886 break; | 5871 break; |
| 5887 | 5872 |
| 5888 | 5873 |
| 5889 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 5874 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
| 5890 case EXTERNAL_##TYPE##_ELEMENTS: \ | |
| 5891 case TYPE##_ELEMENTS: \ | 5875 case TYPE##_ELEMENTS: \ |
| 5892 | 5876 |
| 5893 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 5877 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
| 5894 #undef TYPED_ARRAY_CASE | 5878 #undef TYPED_ARRAY_CASE |
| 5895 | 5879 |
| 5896 case FAST_DOUBLE_ELEMENTS: | 5880 case FAST_DOUBLE_ELEMENTS: |
| 5897 case FAST_HOLEY_DOUBLE_ELEMENTS: | 5881 case FAST_HOLEY_DOUBLE_ELEMENTS: |
| 5898 // No contained objects, nothing to do. | 5882 // No contained objects, nothing to do. |
| 5899 break; | 5883 break; |
| 5900 } | 5884 } |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6283 if (it.state() == LookupIterator::ACCESS_CHECK) { | 6267 if (it.state() == LookupIterator::ACCESS_CHECK) { |
| 6284 if (!it.HasAccess()) { | 6268 if (!it.HasAccess()) { |
| 6285 isolate->ReportFailedAccessCheck(it.GetHolder<JSObject>()); | 6269 isolate->ReportFailedAccessCheck(it.GetHolder<JSObject>()); |
| 6286 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); | 6270 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 6287 return isolate->factory()->undefined_value(); | 6271 return isolate->factory()->undefined_value(); |
| 6288 } | 6272 } |
| 6289 it.Next(); | 6273 it.Next(); |
| 6290 } | 6274 } |
| 6291 | 6275 |
| 6292 // Ignore accessors on typed arrays. | 6276 // Ignore accessors on typed arrays. |
| 6293 if (it.IsElement() && (object->HasFixedTypedArrayElements() || | 6277 if (it.IsElement() && object->HasFixedTypedArrayElements()) { |
| 6294 object->HasExternalArrayElements())) { | |
| 6295 return it.factory()->undefined_value(); | 6278 return it.factory()->undefined_value(); |
| 6296 } | 6279 } |
| 6297 | 6280 |
| 6298 Handle<Object> old_value = isolate->factory()->the_hole_value(); | 6281 Handle<Object> old_value = isolate->factory()->the_hole_value(); |
| 6299 bool is_observed = object->map()->is_observed() && | 6282 bool is_observed = object->map()->is_observed() && |
| 6300 !isolate->IsInternallyUsedPropertyName(name); | 6283 !isolate->IsInternallyUsedPropertyName(name); |
| 6301 bool preexists = false; | 6284 bool preexists = false; |
| 6302 if (is_observed) { | 6285 if (is_observed) { |
| 6303 CHECK(GetPropertyAttributes(&it).IsJust()); | 6286 CHECK(GetPropertyAttributes(&it).IsJust()); |
| 6304 preexists = it.IsFound(); | 6287 preexists = it.IsFound(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6347 if (it.state() == LookupIterator::ACCESS_CHECK) { | 6330 if (it.state() == LookupIterator::ACCESS_CHECK) { |
| 6348 if (!it.HasAccess()) { | 6331 if (!it.HasAccess()) { |
| 6349 isolate->ReportFailedAccessCheck(object); | 6332 isolate->ReportFailedAccessCheck(object); |
| 6350 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); | 6333 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 6351 return it.factory()->undefined_value(); | 6334 return it.factory()->undefined_value(); |
| 6352 } | 6335 } |
| 6353 it.Next(); | 6336 it.Next(); |
| 6354 } | 6337 } |
| 6355 | 6338 |
| 6356 // Ignore accessors on typed arrays. | 6339 // Ignore accessors on typed arrays. |
| 6357 if (it.IsElement() && (object->HasFixedTypedArrayElements() || | 6340 if (it.IsElement() && object->HasFixedTypedArrayElements()) { |
| 6358 object->HasExternalArrayElements())) { | |
| 6359 return it.factory()->undefined_value(); | 6341 return it.factory()->undefined_value(); |
| 6360 } | 6342 } |
| 6361 | 6343 |
| 6362 CHECK(GetPropertyAttributes(&it).IsJust()); | 6344 CHECK(GetPropertyAttributes(&it).IsJust()); |
| 6363 | 6345 |
| 6364 // ES5 forbids turning a property into an accessor if it's not | 6346 // ES5 forbids turning a property into an accessor if it's not |
| 6365 // configurable. See 8.6.1 (Table 5). | 6347 // configurable. See 8.6.1 (Table 5). |
| 6366 if (it.IsFound() && !it.IsConfigurable()) { | 6348 if (it.IsFound() && !it.IsConfigurable()) { |
| 6367 return it.factory()->undefined_value(); | 6349 return it.factory()->undefined_value(); |
| 6368 } | 6350 } |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6765 | 6747 |
| 6766 return result; | 6748 return result; |
| 6767 } | 6749 } |
| 6768 | 6750 |
| 6769 | 6751 |
| 6770 Handle<Map> Map::CopyAsElementsKind(Handle<Map> map, ElementsKind kind, | 6752 Handle<Map> Map::CopyAsElementsKind(Handle<Map> map, ElementsKind kind, |
| 6771 TransitionFlag flag) { | 6753 TransitionFlag flag) { |
| 6772 Map* maybe_elements_transition_map = NULL; | 6754 Map* maybe_elements_transition_map = NULL; |
| 6773 if (flag == INSERT_TRANSITION) { | 6755 if (flag == INSERT_TRANSITION) { |
| 6774 maybe_elements_transition_map = map->ElementsTransitionMap(); | 6756 maybe_elements_transition_map = map->ElementsTransitionMap(); |
| 6775 DCHECK( | 6757 DCHECK(maybe_elements_transition_map == NULL || |
| 6776 maybe_elements_transition_map == NULL || | 6758 (maybe_elements_transition_map->elements_kind() == |
| 6777 ((maybe_elements_transition_map->elements_kind() == | 6759 DICTIONARY_ELEMENTS && |
| 6778 DICTIONARY_ELEMENTS || | 6760 kind == DICTIONARY_ELEMENTS)); |
| 6779 IsExternalArrayElementsKind( | |
| 6780 maybe_elements_transition_map->elements_kind())) && | |
| 6781 (kind == DICTIONARY_ELEMENTS || IsExternalArrayElementsKind(kind)))); | |
| 6782 DCHECK(!IsFastElementsKind(kind) || | 6761 DCHECK(!IsFastElementsKind(kind) || |
| 6783 IsMoreGeneralElementsKindTransition(map->elements_kind(), kind)); | 6762 IsMoreGeneralElementsKindTransition(map->elements_kind(), kind)); |
| 6784 DCHECK(kind != map->elements_kind()); | 6763 DCHECK(kind != map->elements_kind()); |
| 6785 } | 6764 } |
| 6786 | 6765 |
| 6787 bool insert_transition = flag == INSERT_TRANSITION && | 6766 bool insert_transition = flag == INSERT_TRANSITION && |
| 6788 TransitionArray::CanHaveMoreTransitions(map) && | 6767 TransitionArray::CanHaveMoreTransitions(map) && |
| 6789 maybe_elements_transition_map == NULL; | 6768 maybe_elements_transition_map == NULL; |
| 6790 | 6769 |
| 6791 if (insert_transition) { | 6770 if (insert_transition) { |
| (...skipping 5773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12565 case FAST_HOLEY_SMI_ELEMENTS: | 12544 case FAST_HOLEY_SMI_ELEMENTS: |
| 12566 case FAST_HOLEY_ELEMENTS: | 12545 case FAST_HOLEY_ELEMENTS: |
| 12567 return FastHoleyElementsUsage(this, FixedArray::cast(store)); | 12546 return FastHoleyElementsUsage(this, FixedArray::cast(store)); |
| 12568 case FAST_HOLEY_DOUBLE_ELEMENTS: | 12547 case FAST_HOLEY_DOUBLE_ELEMENTS: |
| 12569 if (elements()->length() == 0) return 0; | 12548 if (elements()->length() == 0) return 0; |
| 12570 return FastHoleyElementsUsage(this, FixedDoubleArray::cast(store)); | 12549 return FastHoleyElementsUsage(this, FixedDoubleArray::cast(store)); |
| 12571 | 12550 |
| 12572 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: | 12551 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: |
| 12573 case DICTIONARY_ELEMENTS: | 12552 case DICTIONARY_ELEMENTS: |
| 12574 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 12553 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
| 12575 case EXTERNAL_##TYPE##_ELEMENTS: \ | |
| 12576 case TYPE##_ELEMENTS: \ | 12554 case TYPE##_ELEMENTS: \ |
| 12577 | 12555 |
| 12578 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 12556 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
| 12579 #undef TYPED_ARRAY_CASE | 12557 #undef TYPED_ARRAY_CASE |
| 12580 UNREACHABLE(); | 12558 UNREACHABLE(); |
| 12581 } | 12559 } |
| 12582 return 0; | 12560 return 0; |
| 12583 } | 12561 } |
| 12584 | 12562 |
| 12585 | 12563 |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12999 storage->set(counter, Smi::FromInt(i)); | 12977 storage->set(counter, Smi::FromInt(i)); |
| 13000 } | 12978 } |
| 13001 counter++; | 12979 counter++; |
| 13002 } | 12980 } |
| 13003 } | 12981 } |
| 13004 DCHECK(!storage || storage->length() >= counter); | 12982 DCHECK(!storage || storage->length() >= counter); |
| 13005 break; | 12983 break; |
| 13006 } | 12984 } |
| 13007 | 12985 |
| 13008 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 12986 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
| 13009 case EXTERNAL_##TYPE##_ELEMENTS: \ | |
| 13010 case TYPE##_ELEMENTS: \ | 12987 case TYPE##_ELEMENTS: \ |
| 13011 | 12988 |
| 13012 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 12989 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
| 13013 #undef TYPED_ARRAY_CASE | 12990 #undef TYPED_ARRAY_CASE |
| 13014 { | 12991 { |
| 13015 int length = FixedArrayBase::cast(elements())->length(); | 12992 int length = FixedArrayBase::cast(elements())->length(); |
| 13016 while (counter < length) { | 12993 while (counter < length) { |
| 13017 if (storage != NULL) { | 12994 if (storage != NULL) { |
| 13018 storage->set(counter, Smi::FromInt(counter)); | 12995 storage->set(counter, Smi::FromInt(counter)); |
| 13019 } | 12996 } |
| (...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13821 JSObject::GetElementsTransitionMap(object, FAST_HOLEY_ELEMENTS); | 13798 JSObject::GetElementsTransitionMap(object, FAST_HOLEY_ELEMENTS); |
| 13822 | 13799 |
| 13823 PretenureFlag tenure = isolate->heap()->InNewSpace(*object) ? | 13800 PretenureFlag tenure = isolate->heap()->InNewSpace(*object) ? |
| 13824 NOT_TENURED: TENURED; | 13801 NOT_TENURED: TENURED; |
| 13825 Handle<FixedArray> fast_elements = | 13802 Handle<FixedArray> fast_elements = |
| 13826 isolate->factory()->NewFixedArray(dict->NumberOfElements(), tenure); | 13803 isolate->factory()->NewFixedArray(dict->NumberOfElements(), tenure); |
| 13827 dict->CopyValuesTo(*fast_elements); | 13804 dict->CopyValuesTo(*fast_elements); |
| 13828 JSObject::ValidateElements(object); | 13805 JSObject::ValidateElements(object); |
| 13829 | 13806 |
| 13830 JSObject::SetMapAndElements(object, new_map, fast_elements); | 13807 JSObject::SetMapAndElements(object, new_map, fast_elements); |
| 13831 } else if (object->HasExternalArrayElements() || | 13808 } else if (object->HasFixedTypedArrayElements()) { |
| 13832 object->HasFixedTypedArrayElements()) { | |
| 13833 // Typed arrays cannot have holes or undefined elements. | 13809 // Typed arrays cannot have holes or undefined elements. |
| 13834 return handle(Smi::FromInt( | 13810 return handle(Smi::FromInt( |
| 13835 FixedArrayBase::cast(object->elements())->length()), isolate); | 13811 FixedArrayBase::cast(object->elements())->length()), isolate); |
| 13836 } else if (!object->HasFastDoubleElements()) { | 13812 } else if (!object->HasFastDoubleElements()) { |
| 13837 EnsureWritableFastElements(object); | 13813 EnsureWritableFastElements(object); |
| 13838 } | 13814 } |
| 13839 DCHECK(object->HasFastSmiOrObjectElements() || | 13815 DCHECK(object->HasFastSmiOrObjectElements() || |
| 13840 object->HasFastDoubleElements()); | 13816 object->HasFastDoubleElements()); |
| 13841 | 13817 |
| 13842 // Collect holes at the end, undefined before that and the rest at the | 13818 // Collect holes at the end, undefined before that and the rest at the |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13925 } | 13901 } |
| 13926 } | 13902 } |
| 13927 | 13903 |
| 13928 return isolate->factory()->NewNumberFromUint(result); | 13904 return isolate->factory()->NewNumberFromUint(result); |
| 13929 } | 13905 } |
| 13930 | 13906 |
| 13931 | 13907 |
| 13932 ExternalArrayType JSTypedArray::type() { | 13908 ExternalArrayType JSTypedArray::type() { |
| 13933 switch (elements()->map()->instance_type()) { | 13909 switch (elements()->map()->instance_type()) { |
| 13934 #define INSTANCE_TYPE_TO_ARRAY_TYPE(Type, type, TYPE, ctype, size) \ | 13910 #define INSTANCE_TYPE_TO_ARRAY_TYPE(Type, type, TYPE, ctype, size) \ |
| 13935 case EXTERNAL_##TYPE##_ARRAY_TYPE: \ | |
| 13936 case FIXED_##TYPE##_ARRAY_TYPE: \ | 13911 case FIXED_##TYPE##_ARRAY_TYPE: \ |
| 13937 return kExternal##Type##Array; | 13912 return kExternal##Type##Array; |
| 13938 | 13913 |
| 13939 TYPED_ARRAYS(INSTANCE_TYPE_TO_ARRAY_TYPE) | 13914 TYPED_ARRAYS(INSTANCE_TYPE_TO_ARRAY_TYPE) |
| 13940 #undef INSTANCE_TYPE_TO_ARRAY_TYPE | 13915 #undef INSTANCE_TYPE_TO_ARRAY_TYPE |
| 13941 | 13916 |
| 13942 default: | 13917 default: |
| 13943 UNREACHABLE(); | 13918 UNREACHABLE(); |
| 13944 return static_cast<ExternalArrayType>(-1); | 13919 return static_cast<ExternalArrayType>(-1); |
| 13945 } | 13920 } |
| 13946 } | 13921 } |
| 13947 | 13922 |
| 13948 | 13923 |
| 13949 size_t JSTypedArray::element_size() { | 13924 size_t JSTypedArray::element_size() { |
| 13950 switch (elements()->map()->instance_type()) { | 13925 switch (elements()->map()->instance_type()) { |
| 13951 #define INSTANCE_TYPE_TO_ELEMENT_SIZE(Type, type, TYPE, ctype, size) \ | 13926 #define INSTANCE_TYPE_TO_ELEMENT_SIZE(Type, type, TYPE, ctype, size) \ |
| 13952 case EXTERNAL_##TYPE##_ARRAY_TYPE: \ | 13927 case FIXED_##TYPE##_ARRAY_TYPE: \ |
| 13953 return size; | 13928 return size; |
| 13954 | 13929 |
| 13955 TYPED_ARRAYS(INSTANCE_TYPE_TO_ELEMENT_SIZE) | 13930 TYPED_ARRAYS(INSTANCE_TYPE_TO_ELEMENT_SIZE) |
| 13956 #undef INSTANCE_TYPE_TO_ELEMENT_SIZE | 13931 #undef INSTANCE_TYPE_TO_ELEMENT_SIZE |
| 13957 | 13932 |
| 13958 default: | 13933 default: |
| 13959 UNREACHABLE(); | 13934 UNREACHABLE(); |
| 13960 return 0; | 13935 return 0; |
| 13961 } | 13936 } |
| 13962 } | 13937 } |
| 13963 | 13938 |
| 13964 | 13939 |
| 13965 void FixedArray::SetValue(uint32_t index, Object* value) { set(index, value); } | 13940 void FixedArray::SetValue(uint32_t index, Object* value) { set(index, value); } |
| 13966 | 13941 |
| 13967 | 13942 |
| 13968 void FixedDoubleArray::SetValue(uint32_t index, Object* value) { | 13943 void FixedDoubleArray::SetValue(uint32_t index, Object* value) { |
| 13969 set(index, value->Number()); | 13944 set(index, value->Number()); |
| 13970 } | 13945 } |
| 13971 | |
| 13972 | |
| 13973 void ExternalUint8ClampedArray::SetValue(uint32_t index, Object* value) { | |
| 13974 uint8_t clamped_value = 0; | |
| 13975 if (value->IsSmi()) { | |
| 13976 int int_value = Smi::cast(value)->value(); | |
| 13977 if (int_value < 0) { | |
| 13978 clamped_value = 0; | |
| 13979 } else if (int_value > 255) { | |
| 13980 clamped_value = 255; | |
| 13981 } else { | |
| 13982 clamped_value = static_cast<uint8_t>(int_value); | |
| 13983 } | |
| 13984 } else if (value->IsHeapNumber()) { | |
| 13985 double double_value = HeapNumber::cast(value)->value(); | |
| 13986 if (!(double_value > 0)) { | |
| 13987 // NaN and less than zero clamp to zero. | |
| 13988 clamped_value = 0; | |
| 13989 } else if (double_value > 255) { | |
| 13990 // Greater than 255 clamp to 255. | |
| 13991 clamped_value = 255; | |
| 13992 } else { | |
| 13993 // Other doubles are rounded to the nearest integer. | |
| 13994 clamped_value = static_cast<uint8_t>(lrint(double_value)); | |
| 13995 } | |
| 13996 } else { | |
| 13997 // Clamp undefined to zero (default). All other types have been | |
| 13998 // converted to a number type further up in the call chain. | |
| 13999 DCHECK(value->IsUndefined()); | |
| 14000 } | |
| 14001 set(index, clamped_value); | |
| 14002 } | |
| 14003 | |
| 14004 | |
| 14005 template <typename ExternalArrayClass, typename ValueType> | |
| 14006 static void ExternalArrayIntSetter(ExternalArrayClass* receiver, uint32_t index, | |
| 14007 Object* value) { | |
| 14008 ValueType cast_value = 0; | |
| 14009 if (value->IsSmi()) { | |
| 14010 int int_value = Smi::cast(value)->value(); | |
| 14011 cast_value = static_cast<ValueType>(int_value); | |
| 14012 } else if (value->IsHeapNumber()) { | |
| 14013 double double_value = HeapNumber::cast(value)->value(); | |
| 14014 cast_value = static_cast<ValueType>(DoubleToInt32(double_value)); | |
| 14015 } else { | |
| 14016 // Clamp undefined to zero (default). All other types have been | |
| 14017 // converted to a number type further up in the call chain. | |
| 14018 DCHECK(value->IsUndefined()); | |
| 14019 } | |
| 14020 receiver->set(index, cast_value); | |
| 14021 } | |
| 14022 | |
| 14023 | |
| 14024 void ExternalInt8Array::SetValue(uint32_t index, Object* value) { | |
| 14025 ExternalArrayIntSetter<ExternalInt8Array, int8_t>(this, index, value); | |
| 14026 } | |
| 14027 | |
| 14028 | |
| 14029 void ExternalUint8Array::SetValue(uint32_t index, Object* value) { | |
| 14030 ExternalArrayIntSetter<ExternalUint8Array, uint8_t>(this, index, value); | |
| 14031 } | |
| 14032 | |
| 14033 | |
| 14034 void ExternalInt16Array::SetValue(uint32_t index, Object* value) { | |
| 14035 ExternalArrayIntSetter<ExternalInt16Array, int16_t>(this, index, value); | |
| 14036 } | |
| 14037 | |
| 14038 | |
| 14039 void ExternalUint16Array::SetValue(uint32_t index, Object* value) { | |
| 14040 ExternalArrayIntSetter<ExternalUint16Array, uint16_t>(this, index, value); | |
| 14041 } | |
| 14042 | |
| 14043 | |
| 14044 void ExternalInt32Array::SetValue(uint32_t index, Object* value) { | |
| 14045 ExternalArrayIntSetter<ExternalInt32Array, int32_t>(this, index, value); | |
| 14046 } | |
| 14047 | |
| 14048 | |
| 14049 void ExternalUint32Array::SetValue(uint32_t index, Object* value) { | |
| 14050 uint32_t cast_value = 0; | |
| 14051 if (value->IsSmi()) { | |
| 14052 int int_value = Smi::cast(value)->value(); | |
| 14053 cast_value = static_cast<uint32_t>(int_value); | |
| 14054 } else if (value->IsHeapNumber()) { | |
| 14055 double double_value = HeapNumber::cast(value)->value(); | |
| 14056 cast_value = static_cast<uint32_t>(DoubleToUint32(double_value)); | |
| 14057 } else { | |
| 14058 // Clamp undefined to zero (default). All other types have been | |
| 14059 // converted to a number type further up in the call chain. | |
| 14060 DCHECK(value->IsUndefined()); | |
| 14061 } | |
| 14062 set(index, cast_value); | |
| 14063 } | |
| 14064 | |
| 14065 | |
| 14066 void ExternalFloat32Array::SetValue(uint32_t index, Object* value) { | |
| 14067 float cast_value = std::numeric_limits<float>::quiet_NaN(); | |
| 14068 if (value->IsSmi()) { | |
| 14069 int int_value = Smi::cast(value)->value(); | |
| 14070 cast_value = static_cast<float>(int_value); | |
| 14071 } else if (value->IsHeapNumber()) { | |
| 14072 double double_value = HeapNumber::cast(value)->value(); | |
| 14073 cast_value = static_cast<float>(double_value); | |
| 14074 } else { | |
| 14075 // Clamp undefined to NaN (default). All other types have been | |
| 14076 // converted to a number type further up in the call chain. | |
| 14077 DCHECK(value->IsUndefined()); | |
| 14078 } | |
| 14079 set(index, cast_value); | |
| 14080 } | |
| 14081 | |
| 14082 | |
| 14083 void ExternalFloat64Array::SetValue(uint32_t index, Object* value) { | |
| 14084 double double_value = std::numeric_limits<double>::quiet_NaN(); | |
| 14085 if (value->IsNumber()) { | |
| 14086 double_value = value->Number(); | |
| 14087 } else { | |
| 14088 // Clamp undefined to NaN (default). All other types have been | |
| 14089 // converted to a number type further up in the call chain. | |
| 14090 DCHECK(value->IsUndefined()); | |
| 14091 } | |
| 14092 set(index, double_value); | |
| 14093 } | |
| 14094 | |
| 14095 | |
| 14096 void GlobalObject::InvalidatePropertyCell(Handle<GlobalObject> global, | 13946 void GlobalObject::InvalidatePropertyCell(Handle<GlobalObject> global, |
| 14097 Handle<Name> name) { | 13947 Handle<Name> name) { |
| 14098 DCHECK(!global->HasFastProperties()); | 13948 DCHECK(!global->HasFastProperties()); |
| 14099 auto dictionary = handle(global->global_dictionary()); | 13949 auto dictionary = handle(global->global_dictionary()); |
| 14100 int entry = dictionary->FindEntry(name); | 13950 int entry = dictionary->FindEntry(name); |
| 14101 if (entry == GlobalDictionary::kNotFound) return; | 13951 if (entry == GlobalDictionary::kNotFound) return; |
| 14102 PropertyCell::InvalidateEntry(dictionary, entry); | 13952 PropertyCell::InvalidateEntry(dictionary, entry); |
| 14103 } | 13953 } |
| 14104 | 13954 |
| 14105 | 13955 |
| (...skipping 1591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15697 | 15547 |
| 15698 void JSArrayBuffer::Neuter() { | 15548 void JSArrayBuffer::Neuter() { |
| 15699 CHECK(is_neuterable()); | 15549 CHECK(is_neuterable()); |
| 15700 CHECK(is_external()); | 15550 CHECK(is_external()); |
| 15701 set_backing_store(NULL); | 15551 set_backing_store(NULL); |
| 15702 set_byte_length(Smi::FromInt(0)); | 15552 set_byte_length(Smi::FromInt(0)); |
| 15703 set_was_neutered(true); | 15553 set_was_neutered(true); |
| 15704 } | 15554 } |
| 15705 | 15555 |
| 15706 | 15556 |
| 15707 static ElementsKind FixedToExternalElementsKind(ElementsKind elements_kind) { | |
| 15708 switch (elements_kind) { | |
| 15709 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | |
| 15710 case TYPE##_ELEMENTS: return EXTERNAL_##TYPE##_ELEMENTS; | |
| 15711 | |
| 15712 TYPED_ARRAYS(TYPED_ARRAY_CASE) | |
| 15713 #undef TYPED_ARRAY_CASE | |
| 15714 | |
| 15715 default: | |
| 15716 UNREACHABLE(); | |
| 15717 return FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND; | |
| 15718 } | |
| 15719 } | |
| 15720 | |
| 15721 | |
| 15722 Handle<JSArrayBuffer> JSTypedArray::MaterializeArrayBuffer( | 15557 Handle<JSArrayBuffer> JSTypedArray::MaterializeArrayBuffer( |
| 15723 Handle<JSTypedArray> typed_array) { | 15558 Handle<JSTypedArray> typed_array) { |
| 15724 | 15559 |
| 15725 Handle<Map> map(typed_array->map()); | 15560 Handle<Map> map(typed_array->map()); |
| 15726 Isolate* isolate = typed_array->GetIsolate(); | 15561 Isolate* isolate = typed_array->GetIsolate(); |
| 15727 | 15562 |
| 15728 DCHECK(IsFixedTypedArrayElementsKind(map->elements_kind())); | 15563 DCHECK(IsFixedTypedArrayElementsKind(map->elements_kind())); |
| 15729 | 15564 |
| 15730 Handle<Map> new_map = Map::TransitionElementsTo( | |
| 15731 map, | |
| 15732 FixedToExternalElementsKind(map->elements_kind())); | |
| 15733 | |
| 15734 Handle<FixedTypedArrayBase> fixed_typed_array( | 15565 Handle<FixedTypedArrayBase> fixed_typed_array( |
| 15735 FixedTypedArrayBase::cast(typed_array->elements())); | 15566 FixedTypedArrayBase::cast(typed_array->elements())); |
| 15736 | 15567 |
| 15737 Handle<JSArrayBuffer> buffer(JSArrayBuffer::cast(typed_array->buffer()), | 15568 Handle<JSArrayBuffer> buffer(JSArrayBuffer::cast(typed_array->buffer()), |
| 15738 isolate); | 15569 isolate); |
| 15739 void* backing_store = | 15570 void* backing_store = |
| 15740 isolate->array_buffer_allocator()->AllocateUninitialized( | 15571 isolate->array_buffer_allocator()->AllocateUninitialized( |
| 15741 fixed_typed_array->DataSize()); | 15572 fixed_typed_array->DataSize()); |
| 15742 buffer->set_backing_store(backing_store); | 15573 buffer->set_backing_store(backing_store); |
| 15743 buffer->set_is_external(false); | 15574 buffer->set_is_external(false); |
| 15744 isolate->heap()->RegisterNewArrayBuffer(isolate->heap()->InNewSpace(*buffer), | 15575 isolate->heap()->RegisterNewArrayBuffer(isolate->heap()->InNewSpace(*buffer), |
| 15745 backing_store, | 15576 backing_store, |
| 15746 fixed_typed_array->DataSize()); | 15577 fixed_typed_array->DataSize()); |
| 15747 memcpy(buffer->backing_store(), | 15578 memcpy(buffer->backing_store(), |
| 15748 fixed_typed_array->DataPtr(), | 15579 fixed_typed_array->DataPtr(), |
| 15749 fixed_typed_array->DataSize()); | 15580 fixed_typed_array->DataSize()); |
| 15750 Handle<ExternalArray> new_elements = | 15581 Handle<FixedTypedArrayBase> new_elements = |
| 15751 isolate->factory()->NewExternalArray( | 15582 isolate->factory()->NewExternalArray( |
| 15752 fixed_typed_array->length(), typed_array->type(), | 15583 fixed_typed_array->length(), typed_array->type(), |
| 15753 static_cast<uint8_t*>(buffer->backing_store())); | 15584 static_cast<uint8_t*>(buffer->backing_store())); |
| 15754 | 15585 |
| 15755 JSObject::SetMapAndElements(typed_array, new_map, new_elements); | 15586 typed_array->set_elements(*new_elements); |
| 15756 | 15587 |
| 15757 return buffer; | 15588 return buffer; |
| 15758 } | 15589 } |
| 15759 | 15590 |
| 15760 | 15591 |
| 15761 Handle<JSArrayBuffer> JSTypedArray::GetBuffer() { | 15592 Handle<JSArrayBuffer> JSTypedArray::GetBuffer() { |
| 15762 if (IsExternalArrayElementsKind(map()->elements_kind())) { | 15593 if (JSArrayBuffer::cast(buffer())->backing_store() != nullptr) { |
| 15763 Handle<Object> result(buffer(), GetIsolate()); | 15594 Handle<Object> result(buffer(), GetIsolate()); |
| 15764 return Handle<JSArrayBuffer>::cast(result); | 15595 return Handle<JSArrayBuffer>::cast(result); |
| 15765 } | 15596 } |
| 15766 Handle<JSTypedArray> self(this); | 15597 Handle<JSTypedArray> self(this); |
| 15767 return MaterializeArrayBuffer(self); | 15598 return MaterializeArrayBuffer(self); |
| 15768 } | 15599 } |
| 15769 | 15600 |
| 15770 | 15601 |
| 15771 Handle<PropertyCell> PropertyCell::InvalidateEntry( | 15602 Handle<PropertyCell> PropertyCell::InvalidateEntry( |
| 15772 Handle<GlobalDictionary> dictionary, int entry) { | 15603 Handle<GlobalDictionary> dictionary, int entry) { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15896 Handle<Object> new_value) { | 15727 Handle<Object> new_value) { |
| 15897 if (cell->value() != *new_value) { | 15728 if (cell->value() != *new_value) { |
| 15898 cell->set_value(*new_value); | 15729 cell->set_value(*new_value); |
| 15899 Isolate* isolate = cell->GetIsolate(); | 15730 Isolate* isolate = cell->GetIsolate(); |
| 15900 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 15731 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 15901 isolate, DependentCode::kPropertyCellChangedGroup); | 15732 isolate, DependentCode::kPropertyCellChangedGroup); |
| 15902 } | 15733 } |
| 15903 } | 15734 } |
| 15904 } // namespace internal | 15735 } // namespace internal |
| 15905 } // namespace v8 | 15736 } // namespace v8 |
| OLD | NEW |