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

Side by Side Diff: src/elements.cc

Issue 9190001: Backport @10366 to 3.6 Base URL: http://v8.googlecode.com/svn/branches/3.6/
Patch Set: '' Created 8 years, 11 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
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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 385
386 386
387 class PixelElementsAccessor 387 class PixelElementsAccessor
388 : public ExternalElementsAccessor<PixelElementsAccessor, 388 : public ExternalElementsAccessor<PixelElementsAccessor,
389 ExternalPixelArray> { 389 ExternalPixelArray> {
390 }; 390 };
391 391
392 392
393 class DictionaryElementsAccessor 393 class DictionaryElementsAccessor
394 : public ElementsAccessorBase<DictionaryElementsAccessor, 394 : public ElementsAccessorBase<DictionaryElementsAccessor,
395 NumberDictionary> { 395 SeededNumberDictionary> {
396 public: 396 public:
397 static MaybeObject* DeleteCommon(JSObject* obj, 397 static MaybeObject* DeleteCommon(JSObject* obj,
398 uint32_t key, 398 uint32_t key,
399 JSReceiver::DeleteMode mode) { 399 JSReceiver::DeleteMode mode) {
400 Isolate* isolate = obj->GetIsolate(); 400 Isolate* isolate = obj->GetIsolate();
401 Heap* heap = isolate->heap(); 401 Heap* heap = isolate->heap();
402 FixedArray* backing_store = FixedArray::cast(obj->elements()); 402 FixedArray* backing_store = FixedArray::cast(obj->elements());
403 bool is_arguments = 403 bool is_arguments =
404 (obj->GetElementsKind() == NON_STRICT_ARGUMENTS_ELEMENTS); 404 (obj->GetElementsKind() == NON_STRICT_ARGUMENTS_ELEMENTS);
405 if (is_arguments) { 405 if (is_arguments) {
406 backing_store = FixedArray::cast(backing_store->get(1)); 406 backing_store = FixedArray::cast(backing_store->get(1));
407 } 407 }
408 NumberDictionary* dictionary = NumberDictionary::cast(backing_store); 408 SeededNumberDictionary* dictionary =
409 SeededNumberDictionary::cast(backing_store);
409 int entry = dictionary->FindEntry(key); 410 int entry = dictionary->FindEntry(key);
410 if (entry != NumberDictionary::kNotFound) { 411 if (entry != SeededNumberDictionary::kNotFound) {
411 Object* result = dictionary->DeleteProperty(entry, mode); 412 Object* result = dictionary->DeleteProperty(entry, mode);
412 if (result == heap->true_value()) { 413 if (result == heap->true_value()) {
413 MaybeObject* maybe_elements = dictionary->Shrink(key); 414 MaybeObject* maybe_elements = dictionary->Shrink(key);
414 FixedArray* new_elements = NULL; 415 FixedArray* new_elements = NULL;
415 if (!maybe_elements->To(&new_elements)) { 416 if (!maybe_elements->To(&new_elements)) {
416 return maybe_elements; 417 return maybe_elements;
417 } 418 }
418 if (is_arguments) { 419 if (is_arguments) {
419 FixedArray::cast(obj->elements())->set(1, new_elements); 420 FixedArray::cast(obj->elements())->set(1, new_elements);
420 } else { 421 } else {
(...skipping 12 matching lines...) Expand all
433 isolate->factory()->NewTypeError("strict_delete_property", 434 isolate->factory()->NewTypeError("strict_delete_property",
434 HandleVector(args, 2)); 435 HandleVector(args, 2));
435 return isolate->Throw(*error); 436 return isolate->Throw(*error);
436 } 437 }
437 } 438 }
438 return heap->true_value(); 439 return heap->true_value();
439 } 440 }
440 441
441 protected: 442 protected:
442 friend class ElementsAccessorBase<DictionaryElementsAccessor, 443 friend class ElementsAccessorBase<DictionaryElementsAccessor,
443 NumberDictionary>; 444 SeededNumberDictionary>;
444 445
445 virtual MaybeObject* Delete(JSObject* obj, 446 virtual MaybeObject* Delete(JSObject* obj,
446 uint32_t key, 447 uint32_t key,
447 JSReceiver::DeleteMode mode) { 448 JSReceiver::DeleteMode mode) {
448 return DeleteCommon(obj, key, mode); 449 return DeleteCommon(obj, key, mode);
449 } 450 }
450 451
451 static MaybeObject* Get(NumberDictionary* backing_store, 452 static MaybeObject* Get(SeededNumberDictionary* backing_store,
452 uint32_t key, 453 uint32_t key,
453 JSObject* obj, 454 JSObject* obj,
454 Object* receiver) { 455 Object* receiver) {
455 int entry = backing_store->FindEntry(key); 456 int entry = backing_store->FindEntry(key);
456 if (entry != NumberDictionary::kNotFound) { 457 if (entry != SeededNumberDictionary::kNotFound) {
457 Object* element = backing_store->ValueAt(entry); 458 Object* element = backing_store->ValueAt(entry);
458 PropertyDetails details = backing_store->DetailsAt(entry); 459 PropertyDetails details = backing_store->DetailsAt(entry);
459 if (details.type() == CALLBACKS) { 460 if (details.type() == CALLBACKS) {
460 return obj->GetElementWithCallback(receiver, 461 return obj->GetElementWithCallback(receiver,
461 element, 462 element,
462 key, 463 key,
463 obj); 464 obj);
464 } else { 465 } else {
465 return element; 466 return element;
466 } 467 }
467 } 468 }
468 return obj->GetHeap()->the_hole_value(); 469 return obj->GetHeap()->the_hole_value();
469 } 470 }
470 471
471 static uint32_t GetKeyForIndex(NumberDictionary* dict, 472 static uint32_t GetKeyForIndex(SeededNumberDictionary* dict,
472 uint32_t index) { 473 uint32_t index) {
473 Object* key = dict->KeyAt(index); 474 Object* key = dict->KeyAt(index);
474 return Smi::cast(key)->value(); 475 return Smi::cast(key)->value();
475 } 476 }
476 }; 477 };
477 478
478 479
479 class NonStrictArgumentsElementsAccessor 480 class NonStrictArgumentsElementsAccessor
480 : public ElementsAccessorBase<NonStrictArgumentsElementsAccessor, 481 : public ElementsAccessorBase<NonStrictArgumentsElementsAccessor,
481 FixedArray> { 482 FixedArray> {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 &element_accessors.float_elements_handler, 626 &element_accessors.float_elements_handler,
626 &element_accessors.double_elements_handler, 627 &element_accessors.double_elements_handler,
627 &element_accessors.pixel_elements_handler 628 &element_accessors.pixel_elements_handler
628 }; 629 };
629 630
630 elements_accessors_ = accessor_array; 631 elements_accessors_ = accessor_array;
631 } 632 }
632 633
633 634
634 } } // namespace v8::internal 635 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698