OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 3247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3258 return true; | 3258 return true; |
3259 } | 3259 } |
3260 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*hidden_props)); | 3260 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*hidden_props)); |
3261 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); | 3261 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
3262 return i::DeleteProperty(js_obj, key_obj)->IsTrue(); | 3262 return i::DeleteProperty(js_obj, key_obj)->IsTrue(); |
3263 } | 3263 } |
3264 | 3264 |
3265 | 3265 |
3266 namespace { | 3266 namespace { |
3267 | 3267 |
| 3268 static i::ElementsKind GetElementsKindFromExternalArrayType( |
| 3269 ExternalArrayType array_type) { |
| 3270 switch (array_type) { |
| 3271 case kExternalByteArray: |
| 3272 return i::EXTERNAL_BYTE_ELEMENTS; |
| 3273 break; |
| 3274 case kExternalUnsignedByteArray: |
| 3275 return i::EXTERNAL_UNSIGNED_BYTE_ELEMENTS; |
| 3276 break; |
| 3277 case kExternalShortArray: |
| 3278 return i::EXTERNAL_SHORT_ELEMENTS; |
| 3279 break; |
| 3280 case kExternalUnsignedShortArray: |
| 3281 return i::EXTERNAL_UNSIGNED_SHORT_ELEMENTS; |
| 3282 break; |
| 3283 case kExternalIntArray: |
| 3284 return i::EXTERNAL_INT_ELEMENTS; |
| 3285 break; |
| 3286 case kExternalUnsignedIntArray: |
| 3287 return i::EXTERNAL_UNSIGNED_INT_ELEMENTS; |
| 3288 break; |
| 3289 case kExternalFloatArray: |
| 3290 return i::EXTERNAL_FLOAT_ELEMENTS; |
| 3291 break; |
| 3292 case kExternalDoubleArray: |
| 3293 return i::EXTERNAL_DOUBLE_ELEMENTS; |
| 3294 break; |
| 3295 case kExternalPixelArray: |
| 3296 return i::EXTERNAL_PIXEL_ELEMENTS; |
| 3297 break; |
| 3298 } |
| 3299 UNREACHABLE(); |
| 3300 return i::DICTIONARY_ELEMENTS; |
| 3301 } |
| 3302 |
| 3303 |
3268 void PrepareExternalArrayElements(i::Handle<i::JSObject> object, | 3304 void PrepareExternalArrayElements(i::Handle<i::JSObject> object, |
3269 void* data, | 3305 void* data, |
3270 ExternalArrayType array_type, | 3306 ExternalArrayType array_type, |
3271 int length) { | 3307 int length) { |
3272 i::Isolate* isolate = object->GetIsolate(); | 3308 i::Isolate* isolate = object->GetIsolate(); |
3273 i::Handle<i::ExternalArray> array = | 3309 i::Handle<i::ExternalArray> array = |
3274 isolate->factory()->NewExternalArray(length, array_type, data); | 3310 isolate->factory()->NewExternalArray(length, array_type, data); |
3275 | 3311 |
3276 // If the object already has external elements, create a new, unique | 3312 // If the object already has external elements, create a new, unique |
3277 // map if the element type is now changing, because assumptions about | 3313 // map if the element type is now changing, because assumptions about |
3278 // generated code based on the receiver's map will be invalid. | 3314 // generated code based on the receiver's map will be invalid. |
3279 i::Handle<i::HeapObject> elements(object->elements()); | 3315 i::Handle<i::HeapObject> elements(object->elements()); |
3280 bool cant_reuse_map = | 3316 bool cant_reuse_map = |
3281 elements->map()->IsUndefined() || | 3317 elements->map()->IsUndefined() || |
3282 !elements->map()->has_external_array_elements() || | 3318 !elements->map()->has_external_array_elements() || |
3283 elements->map() != isolate->heap()->MapForExternalArrayType(array_type); | 3319 elements->map() != isolate->heap()->MapForExternalArrayType(array_type); |
3284 if (cant_reuse_map) { | 3320 if (cant_reuse_map) { |
3285 i::Handle<i::Map> external_array_map = | 3321 i::Handle<i::Map> external_array_map = |
3286 isolate->factory()->GetExternalArrayElementsMap( | 3322 isolate->factory()->GetElementsTransitionMap( |
3287 i::Handle<i::Map>(object->map()), | 3323 i::Handle<i::Map>(object->map()), |
3288 array_type, | 3324 GetElementsKindFromExternalArrayType(array_type), |
3289 object->HasFastProperties()); | 3325 object->HasFastProperties()); |
3290 object->set_map(*external_array_map); | 3326 object->set_map(*external_array_map); |
3291 } | 3327 } |
3292 object->set_elements(*array); | 3328 object->set_elements(*array); |
3293 } | 3329 } |
3294 | 3330 |
3295 } // namespace | 3331 } // namespace |
3296 | 3332 |
3297 | 3333 |
3298 void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) { | 3334 void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3340 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 3376 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
3341 ON_BAILOUT(self->GetIsolate(), "v8::GetIndexedPropertiesPixelDataLength()", | 3377 ON_BAILOUT(self->GetIsolate(), "v8::GetIndexedPropertiesPixelDataLength()", |
3342 return -1); | 3378 return -1); |
3343 if (self->HasExternalPixelElements()) { | 3379 if (self->HasExternalPixelElements()) { |
3344 return i::ExternalPixelArray::cast(self->elements())->length(); | 3380 return i::ExternalPixelArray::cast(self->elements())->length(); |
3345 } else { | 3381 } else { |
3346 return -1; | 3382 return -1; |
3347 } | 3383 } |
3348 } | 3384 } |
3349 | 3385 |
| 3386 |
3350 void v8::Object::SetIndexedPropertiesToExternalArrayData( | 3387 void v8::Object::SetIndexedPropertiesToExternalArrayData( |
3351 void* data, | 3388 void* data, |
3352 ExternalArrayType array_type, | 3389 ExternalArrayType array_type, |
3353 int length) { | 3390 int length) { |
3354 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3391 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3355 ON_BAILOUT(isolate, "v8::SetIndexedPropertiesToExternalArrayData()", return); | 3392 ON_BAILOUT(isolate, "v8::SetIndexedPropertiesToExternalArrayData()", return); |
3356 ENTER_V8(isolate); | 3393 ENTER_V8(isolate); |
3357 i::HandleScope scope(isolate); | 3394 i::HandleScope scope(isolate); |
3358 if (!ApiCheck(length <= i::ExternalArray::kMaxLength, | 3395 if (!ApiCheck(length <= i::ExternalArray::kMaxLength, |
3359 "v8::Object::SetIndexedPropertiesToExternalArrayData()", | 3396 "v8::Object::SetIndexedPropertiesToExternalArrayData()", |
(...skipping 2678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6038 | 6075 |
6039 | 6076 |
6040 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 6077 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
6041 HandleScopeImplementer* scope_implementer = | 6078 HandleScopeImplementer* scope_implementer = |
6042 reinterpret_cast<HandleScopeImplementer*>(storage); | 6079 reinterpret_cast<HandleScopeImplementer*>(storage); |
6043 scope_implementer->IterateThis(v); | 6080 scope_implementer->IterateThis(v); |
6044 return storage + ArchiveSpacePerThread(); | 6081 return storage + ArchiveSpacePerThread(); |
6045 } | 6082 } |
6046 | 6083 |
6047 } } // namespace v8::internal | 6084 } } // namespace v8::internal |
OLD | NEW |