Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/api.cc

Issue 7787007: Key external array map transitions on ElementsKind instead of ExternalArrayType (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: review feedback Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3248 matching lines...) Expand 10 before | Expand all | Expand 10 after
3259 return true; 3259 return true;
3260 } 3260 }
3261 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*hidden_props)); 3261 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*hidden_props));
3262 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 3262 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
3263 return i::DeleteProperty(js_obj, key_obj)->IsTrue(); 3263 return i::DeleteProperty(js_obj, key_obj)->IsTrue();
3264 } 3264 }
3265 3265
3266 3266
3267 namespace { 3267 namespace {
3268 3268
3269 static i::ElementsKind GetElementsKindFromExternalArrayType(
3270 ExternalArrayType array_type) {
3271 switch (array_type) {
3272 case kExternalByteArray:
3273 return i::EXTERNAL_BYTE_ELEMENTS;
3274 break;
3275 case kExternalUnsignedByteArray:
3276 return i::EXTERNAL_UNSIGNED_BYTE_ELEMENTS;
3277 break;
3278 case kExternalShortArray:
3279 return i::EXTERNAL_SHORT_ELEMENTS;
3280 break;
3281 case kExternalUnsignedShortArray:
3282 return i::EXTERNAL_UNSIGNED_SHORT_ELEMENTS;
3283 break;
3284 case kExternalIntArray:
3285 return i::EXTERNAL_INT_ELEMENTS;
3286 break;
3287 case kExternalUnsignedIntArray:
3288 return i::EXTERNAL_UNSIGNED_INT_ELEMENTS;
3289 break;
3290 case kExternalFloatArray:
3291 return i::EXTERNAL_FLOAT_ELEMENTS;
3292 break;
3293 case kExternalDoubleArray:
3294 return i::EXTERNAL_DOUBLE_ELEMENTS;
3295 break;
3296 case kExternalPixelArray:
3297 return i::EXTERNAL_PIXEL_ELEMENTS;
3298 break;
3299 }
3300 UNREACHABLE();
3301 return i::DICTIONARY_ELEMENTS;
3302 }
3303
3304
3269 void PrepareExternalArrayElements(i::Handle<i::JSObject> object, 3305 void PrepareExternalArrayElements(i::Handle<i::JSObject> object,
3270 void* data, 3306 void* data,
3271 ExternalArrayType array_type, 3307 ExternalArrayType array_type,
3272 int length) { 3308 int length) {
3273 i::Isolate* isolate = object->GetIsolate(); 3309 i::Isolate* isolate = object->GetIsolate();
3274 i::Handle<i::ExternalArray> array = 3310 i::Handle<i::ExternalArray> array =
3275 isolate->factory()->NewExternalArray(length, array_type, data); 3311 isolate->factory()->NewExternalArray(length, array_type, data);
3276 3312
3277 // If the object already has external elements, create a new, unique 3313 // If the object already has external elements, create a new, unique
3278 // map if the element type is now changing, because assumptions about 3314 // map if the element type is now changing, because assumptions about
3279 // generated code based on the receiver's map will be invalid. 3315 // generated code based on the receiver's map will be invalid.
3280 i::Handle<i::HeapObject> elements(object->elements()); 3316 i::Handle<i::HeapObject> elements(object->elements());
3281 bool cant_reuse_map = 3317 bool cant_reuse_map =
3282 elements->map()->IsUndefined() || 3318 elements->map()->IsUndefined() ||
3283 !elements->map()->has_external_array_elements() || 3319 !elements->map()->has_external_array_elements() ||
3284 elements->map() != isolate->heap()->MapForExternalArrayType(array_type); 3320 elements->map() != isolate->heap()->MapForExternalArrayType(array_type);
3285 if (cant_reuse_map) { 3321 if (cant_reuse_map) {
3286 i::Handle<i::Map> external_array_map = 3322 i::Handle<i::Map> external_array_map =
3287 isolate->factory()->GetExternalArrayElementsMap( 3323 isolate->factory()->GetElementsTransitionMap(
3288 i::Handle<i::Map>(object->map()), 3324 i::Handle<i::Map>(object->map()),
3289 array_type, 3325 GetElementsKindFromExternalArrayType(array_type),
3290 object->HasFastProperties()); 3326 object->HasFastProperties());
3291 object->set_map(*external_array_map); 3327 object->set_map(*external_array_map);
3292 } 3328 }
3293 object->set_elements(*array); 3329 object->set_elements(*array);
3294 } 3330 }
3295 3331
3296 } // namespace 3332 } // namespace
3297 3333
3298 3334
3299 void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) { 3335 void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3341 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3377 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3342 ON_BAILOUT(self->GetIsolate(), "v8::GetIndexedPropertiesPixelDataLength()", 3378 ON_BAILOUT(self->GetIsolate(), "v8::GetIndexedPropertiesPixelDataLength()",
3343 return -1); 3379 return -1);
3344 if (self->HasExternalPixelElements()) { 3380 if (self->HasExternalPixelElements()) {
3345 return i::ExternalPixelArray::cast(self->elements())->length(); 3381 return i::ExternalPixelArray::cast(self->elements())->length();
3346 } else { 3382 } else {
3347 return -1; 3383 return -1;
3348 } 3384 }
3349 } 3385 }
3350 3386
3387
3351 void v8::Object::SetIndexedPropertiesToExternalArrayData( 3388 void v8::Object::SetIndexedPropertiesToExternalArrayData(
3352 void* data, 3389 void* data,
3353 ExternalArrayType array_type, 3390 ExternalArrayType array_type,
3354 int length) { 3391 int length) {
3355 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3392 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3356 ON_BAILOUT(isolate, "v8::SetIndexedPropertiesToExternalArrayData()", return); 3393 ON_BAILOUT(isolate, "v8::SetIndexedPropertiesToExternalArrayData()", return);
3357 ENTER_V8(isolate); 3394 ENTER_V8(isolate);
3358 i::HandleScope scope(isolate); 3395 i::HandleScope scope(isolate);
3359 if (!ApiCheck(length <= i::ExternalArray::kMaxLength, 3396 if (!ApiCheck(length <= i::ExternalArray::kMaxLength,
3360 "v8::Object::SetIndexedPropertiesToExternalArrayData()", 3397 "v8::Object::SetIndexedPropertiesToExternalArrayData()",
(...skipping 2678 matching lines...) Expand 10 before | Expand all | Expand 10 after
6039 6076
6040 6077
6041 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 6078 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
6042 HandleScopeImplementer* scope_implementer = 6079 HandleScopeImplementer* scope_implementer =
6043 reinterpret_cast<HandleScopeImplementer*>(storage); 6080 reinterpret_cast<HandleScopeImplementer*>(storage);
6044 scope_implementer->IterateThis(v); 6081 scope_implementer->IterateThis(v);
6045 return storage + ArchiveSpacePerThread(); 6082 return storage + ArchiveSpacePerThread();
6046 } 6083 }
6047 6084
6048 } } // namespace v8::internal 6085 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698