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

Side by Side Diff: src/elements.cc

Issue 7849017: Mechanical refactor to move ElementsKind type out of JSObject. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: latest changes 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 | « src/elements.h ('k') | src/heap.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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 : public ElementsAccessorBase<DictionaryElementsAccessor, 394 : public ElementsAccessorBase<DictionaryElementsAccessor,
395 NumberDictionary> { 395 NumberDictionary> {
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() == JSObject::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 NumberDictionary* dictionary = NumberDictionary::cast(backing_store);
409 int entry = dictionary->FindEntry(key); 409 int entry = dictionary->FindEntry(key);
410 if (entry != NumberDictionary::kNotFound) { 410 if (entry != NumberDictionary::kNotFound) {
411 Object* result = dictionary->DeleteProperty(entry, mode); 411 Object* result = dictionary->DeleteProperty(entry, mode);
412 if (result == heap->true_value()) { 412 if (result == heap->true_value()) {
413 MaybeObject* maybe_elements = dictionary->Shrink(key); 413 MaybeObject* maybe_elements = dictionary->Shrink(key);
414 FixedArray* new_elements = NULL; 414 FixedArray* new_elements = NULL;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 ? parameter_map->get(key + 2) 558 ? parameter_map->get(key + 2)
559 : parameter_map->GetHeap()->the_hole_value(); 559 : parameter_map->GetHeap()->the_hole_value();
560 } 560 }
561 }; 561 };
562 562
563 563
564 ElementsAccessor* ElementsAccessor::ForArray(FixedArrayBase* array) { 564 ElementsAccessor* ElementsAccessor::ForArray(FixedArrayBase* array) {
565 switch (array->map()->instance_type()) { 565 switch (array->map()->instance_type()) {
566 case FIXED_ARRAY_TYPE: 566 case FIXED_ARRAY_TYPE:
567 if (array->IsDictionary()) { 567 if (array->IsDictionary()) {
568 return elements_accessors_[JSObject::DICTIONARY_ELEMENTS]; 568 return elements_accessors_[DICTIONARY_ELEMENTS];
569 } else { 569 } else {
570 return elements_accessors_[JSObject::FAST_ELEMENTS]; 570 return elements_accessors_[FAST_ELEMENTS];
571 } 571 }
572 case EXTERNAL_BYTE_ARRAY_TYPE: 572 case EXTERNAL_BYTE_ARRAY_TYPE:
573 return elements_accessors_[JSObject::EXTERNAL_BYTE_ELEMENTS]; 573 return elements_accessors_[EXTERNAL_BYTE_ELEMENTS];
574 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: 574 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE:
575 return elements_accessors_[JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS]; 575 return elements_accessors_[EXTERNAL_UNSIGNED_BYTE_ELEMENTS];
576 case EXTERNAL_SHORT_ARRAY_TYPE: 576 case EXTERNAL_SHORT_ARRAY_TYPE:
577 return elements_accessors_[JSObject::EXTERNAL_SHORT_ELEMENTS]; 577 return elements_accessors_[EXTERNAL_SHORT_ELEMENTS];
578 case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: 578 case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE:
579 return elements_accessors_[JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS]; 579 return elements_accessors_[EXTERNAL_UNSIGNED_SHORT_ELEMENTS];
580 case EXTERNAL_INT_ARRAY_TYPE: 580 case EXTERNAL_INT_ARRAY_TYPE:
581 return elements_accessors_[JSObject::EXTERNAL_INT_ELEMENTS]; 581 return elements_accessors_[EXTERNAL_INT_ELEMENTS];
582 case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: 582 case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE:
583 return elements_accessors_[JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS]; 583 return elements_accessors_[EXTERNAL_UNSIGNED_INT_ELEMENTS];
584 case EXTERNAL_FLOAT_ARRAY_TYPE: 584 case EXTERNAL_FLOAT_ARRAY_TYPE:
585 return elements_accessors_[JSObject::EXTERNAL_FLOAT_ELEMENTS]; 585 return elements_accessors_[EXTERNAL_FLOAT_ELEMENTS];
586 case EXTERNAL_DOUBLE_ARRAY_TYPE: 586 case EXTERNAL_DOUBLE_ARRAY_TYPE:
587 return elements_accessors_[JSObject::EXTERNAL_DOUBLE_ELEMENTS]; 587 return elements_accessors_[EXTERNAL_DOUBLE_ELEMENTS];
588 case EXTERNAL_PIXEL_ARRAY_TYPE: 588 case EXTERNAL_PIXEL_ARRAY_TYPE:
589 return elements_accessors_[JSObject::EXTERNAL_PIXEL_ELEMENTS]; 589 return elements_accessors_[EXTERNAL_PIXEL_ELEMENTS];
590 default: 590 default:
591 UNREACHABLE(); 591 UNREACHABLE();
592 return NULL; 592 return NULL;
593 } 593 }
594 } 594 }
595 595
596 596
597 void ElementsAccessor::InitializeOncePerProcess() { 597 void ElementsAccessor::InitializeOncePerProcess() {
598 static struct ConcreteElementsAccessors { 598 static struct ConcreteElementsAccessors {
599 FastElementsAccessor fast_elements_handler; 599 FastElementsAccessor fast_elements_handler;
(...skipping 25 matching lines...) Expand all
625 &element_accessors.float_elements_handler, 625 &element_accessors.float_elements_handler,
626 &element_accessors.double_elements_handler, 626 &element_accessors.double_elements_handler,
627 &element_accessors.pixel_elements_handler 627 &element_accessors.pixel_elements_handler
628 }; 628 };
629 629
630 elements_accessors_ = accessor_array; 630 elements_accessors_ = accessor_array;
631 } 631 }
632 632
633 633
634 } } // namespace v8::internal 634 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/elements.h ('k') | src/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698