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

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: fixing 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
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 2987 matching lines...) Expand 10 before | Expand all | Expand 10 after
2998 2998
2999 2999
3000 void ElementsAccessor::TearDown() { 3000 void ElementsAccessor::TearDown() {
3001 if (elements_accessors_ == NULL) return; 3001 if (elements_accessors_ == NULL) return;
3002 #define ACCESSOR_DELETE(Class, Kind, Store) delete elements_accessors_[Kind]; 3002 #define ACCESSOR_DELETE(Class, Kind, Store) delete elements_accessors_[Kind];
3003 ELEMENTS_LIST(ACCESSOR_DELETE) 3003 ELEMENTS_LIST(ACCESSOR_DELETE)
3004 #undef ACCESSOR_DELETE 3004 #undef ACCESSOR_DELETE
3005 elements_accessors_ = NULL; 3005 elements_accessors_ = NULL;
3006 } 3006 }
3007 3007
3008
3009 Handle<JSArray> ElementsAccessor::Concat(Isolate* isolate, Arguments* args, 3008 Handle<JSArray> ElementsAccessor::Concat(Isolate* isolate, Arguments* args,
3010 uint32_t concat_size) { 3009 uint32_t concat_size,
3011 const int kHalfOfMaxInt = 1 << (kBitsPerInt - 2); 3010 uint32_t result_len) {
3012 STATIC_ASSERT(FixedDoubleArray::kMaxLength < kHalfOfMaxInt); 3011 ElementsKind result_elements_kind = GetInitialFastElementsKind();
3013 USE(kHalfOfMaxInt);
3014 uint32_t result_len = 0;
3015 bool has_raw_doubles = false; 3012 bool has_raw_doubles = false;
3016 ElementsKind result_elements_kind = GetInitialFastElementsKind();
3017 { 3013 {
3018 DisallowHeapAllocation no_gc; 3014 DisallowHeapAllocation no_gc;
3019 bool is_holey = false; 3015 bool is_holey = false;
3020 // Iterate through all the arguments performing checks
3021 // and calculating total length.
3022 for (uint32_t i = 0; i < concat_size; i++) { 3016 for (uint32_t i = 0; i < concat_size; i++) {
3023 JSArray* array = JSArray::cast((*args)[i]); 3017 Object* arg = (*args)[i];
3024 uint32_t len = 0; 3018 ElementsKind arg_kind = JSArray::cast(arg)->GetElementsKind();
3025 array->length()->ToArrayLength(&len);
3026
3027 // We shouldn't overflow when adding another len.
3028 result_len += len;
3029 DCHECK(0 <= result_len);
3030 DCHECK(result_len <= FixedDoubleArray::kMaxLength);
3031
3032 ElementsKind arg_kind = array->GetElementsKind();
3033 has_raw_doubles = has_raw_doubles || IsFastDoubleElementsKind(arg_kind); 3019 has_raw_doubles = has_raw_doubles || IsFastDoubleElementsKind(arg_kind);
3034 is_holey = is_holey || IsFastHoleyElementsKind(arg_kind); 3020 is_holey = is_holey || IsFastHoleyElementsKind(arg_kind);
3035 result_elements_kind = 3021 result_elements_kind =
3036 GetMoreGeneralElementsKind(result_elements_kind, arg_kind); 3022 GetMoreGeneralElementsKind(result_elements_kind, arg_kind);
3037 } 3023 }
3038 if (is_holey) { 3024 if (is_holey) {
3039 result_elements_kind = GetHoleyElementsKind(result_elements_kind); 3025 result_elements_kind = GetHoleyElementsKind(result_elements_kind);
3040 } 3026 }
3041 } 3027 }
3042 3028
(...skipping 24 matching lines...) Expand all
3067 insertion_index += len; 3053 insertion_index += len;
3068 } 3054 }
3069 3055
3070 DCHECK_EQ(insertion_index, result_len); 3056 DCHECK_EQ(insertion_index, result_len);
3071 return result_array; 3057 return result_array;
3072 } 3058 }
3073 3059
3074 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; 3060 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL;
3075 } // namespace internal 3061 } // namespace internal
3076 } // namespace v8 3062 } // namespace v8
OLDNEW
« src/builtins.cc ('K') | « src/elements.h ('k') | src/heap/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698