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

Side by Side Diff: src/elements.cc

Issue 760883002: Add interceptor support for symbols (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix test Created 6 years 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
« no previous file with comments | « src/elements.h ('k') | src/ic/ic.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/conversions.h" 8 #include "src/conversions.h"
9 #include "src/elements.h" 9 #include "src/elements.h"
10 #include "src/objects.h" 10 #include "src/objects.h"
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 // 759 //
760 // Details: The idea is that allocations actually happen only in case of 760 // Details: The idea is that allocations actually happen only in case of
761 // copying from object with fast double elements to object with object 761 // copying from object with fast double elements to object with object
762 // elements. In all the other cases there are no allocations performed and 762 // elements. In all the other cases there are no allocations performed and
763 // handle creation causes noticeable performance degradation of the builtin. 763 // handle creation causes noticeable performance degradation of the builtin.
764 ElementsAccessorSubclass::CopyElementsImpl( 764 ElementsAccessorSubclass::CopyElementsImpl(
765 from, from_start, *to, from_kind, to_start, packed_size, copy_size); 765 from, from_start, *to, from_kind, to_start, packed_size, copy_size);
766 } 766 }
767 767
768 virtual MaybeHandle<FixedArray> AddElementsToFixedArray( 768 virtual MaybeHandle<FixedArray> AddElementsToFixedArray(
769 Handle<Object> receiver, 769 Handle<Object> receiver, Handle<JSObject> holder, Handle<FixedArray> to,
770 Handle<JSObject> holder, 770 Handle<FixedArrayBase> from,
771 Handle<FixedArray> to, 771 FixedArray::KeyFilter filter) FINAL OVERRIDE {
772 Handle<FixedArrayBase> from) FINAL OVERRIDE {
773 int len0 = to->length(); 772 int len0 = to->length();
774 #ifdef ENABLE_SLOW_DCHECKS 773 #ifdef ENABLE_SLOW_DCHECKS
775 if (FLAG_enable_slow_asserts) { 774 if (FLAG_enable_slow_asserts) {
776 for (int i = 0; i < len0; i++) { 775 for (int i = 0; i < len0; i++) {
777 DCHECK(!to->get(i)->IsTheHole()); 776 DCHECK(!to->get(i)->IsTheHole());
778 } 777 }
779 } 778 }
780 #endif 779 #endif
781 780
782 // Optimize if 'other' is empty. 781 // Optimize if 'other' is empty.
783 // We cannot optimize if 'this' is empty, as other may have holes. 782 // We cannot optimize if 'this' is empty, as other may have holes.
784 uint32_t len1 = ElementsAccessorSubclass::GetCapacityImpl(from); 783 uint32_t len1 = ElementsAccessorSubclass::GetCapacityImpl(from);
785 if (len1 == 0) return to; 784 if (len1 == 0) return to;
786 785
787 Isolate* isolate = from->GetIsolate(); 786 Isolate* isolate = from->GetIsolate();
788 787
789 // Compute how many elements are not in other. 788 // Compute how many elements are not in other.
790 uint32_t extra = 0; 789 uint32_t extra = 0;
791 for (uint32_t y = 0; y < len1; y++) { 790 for (uint32_t y = 0; y < len1; y++) {
792 uint32_t key = ElementsAccessorSubclass::GetKeyForIndexImpl(from, y); 791 uint32_t key = ElementsAccessorSubclass::GetKeyForIndexImpl(from, y);
793 if (ElementsAccessorSubclass::HasElementImpl( 792 if (ElementsAccessorSubclass::HasElementImpl(
794 receiver, holder, key, from)) { 793 receiver, holder, key, from)) {
795 Handle<Object> value; 794 Handle<Object> value;
796 ASSIGN_RETURN_ON_EXCEPTION( 795 ASSIGN_RETURN_ON_EXCEPTION(
797 isolate, value, 796 isolate, value,
798 ElementsAccessorSubclass::GetImpl(receiver, holder, key, from), 797 ElementsAccessorSubclass::GetImpl(receiver, holder, key, from),
799 FixedArray); 798 FixedArray);
800 799
801 DCHECK(!value->IsTheHole()); 800 DCHECK(!value->IsTheHole());
801 if (filter == FixedArray::NON_SYMBOL_KEYS && value->IsSymbol()) {
802 continue;
803 }
802 if (!HasKey(to, value)) { 804 if (!HasKey(to, value)) {
803 extra++; 805 extra++;
804 } 806 }
805 } 807 }
806 } 808 }
807 809
808 if (extra == 0) return to; 810 if (extra == 0) return to;
809 811
810 // Allocate the result 812 // Allocate the result
811 Handle<FixedArray> result = isolate->factory()->NewFixedArray(len0 + extra); 813 Handle<FixedArray> result = isolate->factory()->NewFixedArray(len0 + extra);
(...skipping 13 matching lines...) Expand all
825 for (uint32_t y = 0; y < len1; y++) { 827 for (uint32_t y = 0; y < len1; y++) {
826 uint32_t key = 828 uint32_t key =
827 ElementsAccessorSubclass::GetKeyForIndexImpl(from, y); 829 ElementsAccessorSubclass::GetKeyForIndexImpl(from, y);
828 if (ElementsAccessorSubclass::HasElementImpl( 830 if (ElementsAccessorSubclass::HasElementImpl(
829 receiver, holder, key, from)) { 831 receiver, holder, key, from)) {
830 Handle<Object> value; 832 Handle<Object> value;
831 ASSIGN_RETURN_ON_EXCEPTION( 833 ASSIGN_RETURN_ON_EXCEPTION(
832 isolate, value, 834 isolate, value,
833 ElementsAccessorSubclass::GetImpl(receiver, holder, key, from), 835 ElementsAccessorSubclass::GetImpl(receiver, holder, key, from),
834 FixedArray); 836 FixedArray);
837 if (filter == FixedArray::NON_SYMBOL_KEYS && value->IsSymbol()) {
838 continue;
839 }
835 if (!value->IsTheHole() && !HasKey(to, value)) { 840 if (!value->IsTheHole() && !HasKey(to, value)) {
836 result->set(len0 + index, *value); 841 result->set(len0 + index, *value);
837 index++; 842 index++;
838 } 843 }
839 } 844 }
840 } 845 }
841 DCHECK(extra == index); 846 DCHECK(extra == index);
842 return result; 847 return result;
843 } 848 }
844 849
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 UNREACHABLE(); 1916 UNREACHABLE();
1912 break; 1917 break;
1913 } 1918 }
1914 1919
1915 array->set_elements(*elms); 1920 array->set_elements(*elms);
1916 array->set_length(Smi::FromInt(number_of_elements)); 1921 array->set_length(Smi::FromInt(number_of_elements));
1917 return array; 1922 return array;
1918 } 1923 }
1919 1924
1920 } } // namespace v8::internal 1925 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/elements.h ('k') | src/ic/ic.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698