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

Side by Side Diff: src/elements.cc

Issue 2164573003: [turbofan] Introduce a TransitionElementsKind simplified operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix the runtime fallback. Created 4 years, 5 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
« no previous file with comments | « src/elements.h ('k') | src/runtime/runtime-array.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/elements.h" 5 #include "src/elements.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/factory.h" 9 #include "src/factory.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 if (IsFastPackedElementsKind(from_kind) && object->IsJSArray()) { 776 if (IsFastPackedElementsKind(from_kind) && object->IsJSArray()) {
777 packed_size = Smi::cast(JSArray::cast(*object)->length())->value(); 777 packed_size = Smi::cast(JSArray::cast(*object)->length())->value();
778 } 778 }
779 779
780 Subclass::CopyElementsImpl(*old_elements, src_index, *new_elements, 780 Subclass::CopyElementsImpl(*old_elements, src_index, *new_elements,
781 from_kind, dst_index, packed_size, copy_size); 781 from_kind, dst_index, packed_size, copy_size);
782 782
783 return new_elements; 783 return new_elements;
784 } 784 }
785 785
786 static void TransitionElementsKindImpl(Handle<JSObject> object,
787 Handle<Map> to_map) {
788 Handle<Map> from_map = handle(object->map());
789 ElementsKind from_kind = from_map->elements_kind();
790 ElementsKind to_kind = to_map->elements_kind();
791 if (IsFastHoleyElementsKind(from_kind)) {
792 to_kind = GetHoleyElementsKind(to_kind);
793 }
794 if (from_kind != to_kind) {
795 // This method should never be called for any other case.
796 DCHECK(IsFastElementsKind(from_kind));
797 DCHECK(IsFastElementsKind(to_kind));
798 DCHECK_NE(TERMINAL_FAST_ELEMENTS_KIND, from_kind);
799
800 Handle<FixedArrayBase> from_elements(object->elements());
801 if (object->elements() == object->GetHeap()->empty_fixed_array() ||
802 IsFastDoubleElementsKind(from_kind) ==
803 IsFastDoubleElementsKind(to_kind)) {
804 // No change is needed to the elements() buffer, the transition
805 // only requires a map change.
806 JSObject::MigrateToMap(object, to_map);
807 } else {
808 DCHECK((IsFastSmiElementsKind(from_kind) &&
809 IsFastDoubleElementsKind(to_kind)) ||
810 (IsFastDoubleElementsKind(from_kind) &&
811 IsFastObjectElementsKind(to_kind)));
812 uint32_t capacity = static_cast<uint32_t>(object->elements()->length());
813 Handle<FixedArrayBase> elements = ConvertElementsWithCapacity(
814 object, from_elements, from_kind, capacity);
815 JSObject::SetMapAndElements(object, to_map, elements);
816 }
817 if (FLAG_trace_elements_transitions) {
818 JSObject::PrintElementsTransition(stdout, object, from_kind,
819 from_elements, to_kind,
820 handle(object->elements()));
821 }
822 }
823 }
824
786 static void GrowCapacityAndConvertImpl(Handle<JSObject> object, 825 static void GrowCapacityAndConvertImpl(Handle<JSObject> object,
787 uint32_t capacity) { 826 uint32_t capacity) {
788 ElementsKind from_kind = object->GetElementsKind(); 827 ElementsKind from_kind = object->GetElementsKind();
789 if (IsFastSmiOrObjectElementsKind(from_kind)) { 828 if (IsFastSmiOrObjectElementsKind(from_kind)) {
790 // Array optimizations rely on the prototype lookups of Array objects 829 // Array optimizations rely on the prototype lookups of Array objects
791 // always returning undefined. If there is a store to the initial 830 // always returning undefined. If there is a store to the initial
792 // prototype object, make sure all of these optimizations are invalidated. 831 // prototype object, make sure all of these optimizations are invalidated.
793 object->GetIsolate()->UpdateArrayProtectorOnSetLength(object); 832 object->GetIsolate()->UpdateArrayProtectorOnSetLength(object);
794 } 833 }
795 Handle<FixedArrayBase> old_elements(object->elements()); 834 Handle<FixedArrayBase> old_elements(object->elements());
(...skipping 19 matching lines...) Expand all
815 854
816 // Transition through the allocation site as well if present. 855 // Transition through the allocation site as well if present.
817 JSObject::UpdateAllocationSite(object, to_kind); 856 JSObject::UpdateAllocationSite(object, to_kind);
818 857
819 if (FLAG_trace_elements_transitions) { 858 if (FLAG_trace_elements_transitions) {
820 JSObject::PrintElementsTransition(stdout, object, from_kind, old_elements, 859 JSObject::PrintElementsTransition(stdout, object, from_kind, old_elements,
821 to_kind, elements); 860 to_kind, elements);
822 } 861 }
823 } 862 }
824 863
864 void TransitionElementsKind(Handle<JSObject> object, Handle<Map> map) final {
865 Subclass::TransitionElementsKindImpl(object, map);
866 }
867
825 void GrowCapacityAndConvert(Handle<JSObject> object, 868 void GrowCapacityAndConvert(Handle<JSObject> object,
826 uint32_t capacity) final { 869 uint32_t capacity) final {
827 Subclass::GrowCapacityAndConvertImpl(object, capacity); 870 Subclass::GrowCapacityAndConvertImpl(object, capacity);
828 } 871 }
829 872
830 void Delete(Handle<JSObject> obj, uint32_t entry) final { 873 void Delete(Handle<JSObject> obj, uint32_t entry) final {
831 Subclass::DeleteImpl(obj, entry); 874 Subclass::DeleteImpl(obj, entry);
832 } 875 }
833 876
834 static void CopyElementsImpl(FixedArrayBase* from, uint32_t from_start, 877 static void CopyElementsImpl(FixedArrayBase* from, uint32_t from_start,
(...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after
2248 AliasedArgumentsEntry* alias = AliasedArgumentsEntry::cast(*result); 2291 AliasedArgumentsEntry* alias = AliasedArgumentsEntry::cast(*result);
2249 Context* context = Context::cast(parameter_map->get(0)); 2292 Context* context = Context::cast(parameter_map->get(0));
2250 int context_entry = alias->aliased_context_slot(); 2293 int context_entry = alias->aliased_context_slot();
2251 DCHECK(!context->get(context_entry)->IsTheHole(isolate)); 2294 DCHECK(!context->get(context_entry)->IsTheHole(isolate));
2252 return handle(context->get(context_entry), isolate); 2295 return handle(context->get(context_entry), isolate);
2253 } 2296 }
2254 return result; 2297 return result;
2255 } 2298 }
2256 } 2299 }
2257 2300
2301 static void TransitionElementsKindImpl(Handle<JSObject> object,
2302 Handle<Map> map) {
2303 UNREACHABLE();
2304 }
2305
2258 static void GrowCapacityAndConvertImpl(Handle<JSObject> object, 2306 static void GrowCapacityAndConvertImpl(Handle<JSObject> object,
2259 uint32_t capacity) { 2307 uint32_t capacity) {
2260 UNREACHABLE(); 2308 UNREACHABLE();
2261 } 2309 }
2262 2310
2263 static inline void SetImpl(Handle<JSObject> holder, uint32_t entry, 2311 static inline void SetImpl(Handle<JSObject> holder, uint32_t entry,
2264 Object* value) { 2312 Object* value) {
2265 SetImpl(holder->elements(), entry, value); 2313 SetImpl(holder->elements(), entry, value);
2266 } 2314 }
2267 2315
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
3030 insertion_index += len; 3078 insertion_index += len;
3031 } 3079 }
3032 3080
3033 DCHECK_EQ(insertion_index, result_len); 3081 DCHECK_EQ(insertion_index, result_len);
3034 return result_array; 3082 return result_array;
3035 } 3083 }
3036 3084
3037 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; 3085 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL;
3038 } // namespace internal 3086 } // namespace internal
3039 } // namespace v8 3087 } // namespace v8
OLDNEW
« no previous file with comments | « src/elements.h ('k') | src/runtime/runtime-array.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698