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

Side by Side Diff: src/elements.cc

Issue 1409123003: [runtime] Avoid @@isConcatSpreadable lookup for fast path Array.prototype.concat (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: adding more tests Created 4 years, 8 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/heap/heap.h » ('j') | src/isolate.cc » ('J')
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 2924 matching lines...) Expand 10 before | Expand all | Expand 10 after
2935 2935
2936 2936
2937 void ElementsAccessor::TearDown() { 2937 void ElementsAccessor::TearDown() {
2938 if (elements_accessors_ == NULL) return; 2938 if (elements_accessors_ == NULL) return;
2939 #define ACCESSOR_DELETE(Class, Kind, Store) delete elements_accessors_[Kind]; 2939 #define ACCESSOR_DELETE(Class, Kind, Store) delete elements_accessors_[Kind];
2940 ELEMENTS_LIST(ACCESSOR_DELETE) 2940 ELEMENTS_LIST(ACCESSOR_DELETE)
2941 #undef ACCESSOR_DELETE 2941 #undef ACCESSOR_DELETE
2942 elements_accessors_ = NULL; 2942 elements_accessors_ = NULL;
2943 } 2943 }
2944 2944
2945
2946 Handle<JSArray> ElementsAccessor::Concat(Isolate* isolate, Arguments* args, 2945 Handle<JSArray> ElementsAccessor::Concat(Isolate* isolate, Arguments* args,
2947 uint32_t concat_size) { 2946 uint32_t concat_size,
2948 uint32_t result_len = 0; 2947 uint32_t result_len) {
2948 ElementsKind result_elements_kind = GetInitialFastElementsKind();
2949 bool has_raw_doubles = false; 2949 bool has_raw_doubles = false;
2950 ElementsKind result_elements_kind = GetInitialFastElementsKind();
2951 { 2950 {
2952 DisallowHeapAllocation no_gc; 2951 DisallowHeapAllocation no_gc;
2953 bool is_holey = false; 2952 bool is_holey = false;
2954 // Iterate through all the arguments performing checks
2955 // and calculating total length.
2956 for (uint32_t i = 0; i < concat_size; i++) { 2953 for (uint32_t i = 0; i < concat_size; i++) {
2957 JSArray* array = JSArray::cast((*args)[i]); 2954 Object* arg = (*args)[i];
2958 uint32_t len = 0; 2955 ElementsKind arg_kind = JSArray::cast(arg)->GetElementsKind();
2959 array->length()->ToArrayLength(&len);
2960
2961 // We shouldn't overflow when adding another len.
2962 const int kHalfOfMaxInt = 1 << (kBitsPerInt - 2);
2963 STATIC_ASSERT(FixedArray::kMaxLength < kHalfOfMaxInt);
2964 USE(kHalfOfMaxInt);
2965 result_len += len;
2966 DCHECK(0 <= result_len);
2967 DCHECK(result_len <= FixedDoubleArray::kMaxLength);
2968
2969 ElementsKind arg_kind = array->GetElementsKind();
2970 has_raw_doubles = has_raw_doubles || IsFastDoubleElementsKind(arg_kind); 2956 has_raw_doubles = has_raw_doubles || IsFastDoubleElementsKind(arg_kind);
2971 is_holey = is_holey || IsFastHoleyElementsKind(arg_kind); 2957 is_holey = is_holey || IsFastHoleyElementsKind(arg_kind);
2972 result_elements_kind = 2958 result_elements_kind =
2973 GetMoreGeneralElementsKind(result_elements_kind, arg_kind); 2959 GetMoreGeneralElementsKind(result_elements_kind, arg_kind);
2974 } 2960 }
2975 if (is_holey) { 2961 if (is_holey) {
2976 result_elements_kind = GetHoleyElementsKind(result_elements_kind); 2962 result_elements_kind = GetHoleyElementsKind(result_elements_kind);
2977 } 2963 }
2978 } 2964 }
2979 2965
(...skipping 24 matching lines...) Expand all
3004 insertion_index += len; 2990 insertion_index += len;
3005 } 2991 }
3006 2992
3007 DCHECK_EQ(insertion_index, result_len); 2993 DCHECK_EQ(insertion_index, result_len);
3008 return result_array; 2994 return result_array;
3009 } 2995 }
3010 2996
3011 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; 2997 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL;
3012 } // namespace internal 2998 } // namespace internal
3013 } // namespace v8 2999 } // namespace v8
OLDNEW
« no previous file with comments | « src/elements.h ('k') | src/heap/heap.h » ('j') | src/isolate.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698