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

Side by Side Diff: src/objects-inl.h

Issue 1191313003: More cleanup related to setting array.length (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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/objects.cc ('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 // Review notes: 5 // Review notes:
6 // 6 //
7 // - The use of macros in these inline functions may seem superfluous 7 // - The use of macros in these inline functions may seem superfluous
8 // but it is absolutely needed to make sure gcc generates optimal 8 // but it is absolutely needed to make sure gcc generates optimal
9 // code. gcc is not happy when attempting to inline too deep. 9 // code. gcc is not happy when attempting to inline too deep.
10 // 10 //
(...skipping 6951 matching lines...) Expand 10 before | Expand all | Expand 10 after
6962 } 6962 }
6963 } 6963 }
6964 6964
6965 6965
6966 void JSArray::set_length(Smi* length) { 6966 void JSArray::set_length(Smi* length) {
6967 // Don't need a write barrier for a Smi. 6967 // Don't need a write barrier for a Smi.
6968 set_length(static_cast<Object*>(length), SKIP_WRITE_BARRIER); 6968 set_length(static_cast<Object*>(length), SKIP_WRITE_BARRIER);
6969 } 6969 }
6970 6970
6971 6971
6972 bool JSArray::SetElementsLengthWouldNormalize( 6972 bool JSArray::SetLengthWouldNormalize(Heap* heap, uint32_t new_length) {
6973 Heap* heap, Handle<Object> new_length_handle) {
6974 // If the new array won't fit in a some non-trivial fraction of the max old 6973 // If the new array won't fit in a some non-trivial fraction of the max old
6975 // space size, then force it to go dictionary mode. 6974 // space size, then force it to go dictionary mode.
6976 int max_fast_array_size = 6975 uint32_t max_fast_array_size =
6977 static_cast<int>((heap->MaxOldGenerationSize() / kDoubleSize) / 4); 6976 static_cast<uint32_t>((heap->MaxOldGenerationSize() / kDoubleSize) / 4);
6978 return new_length_handle->IsNumber() && 6977 return new_length >= max_fast_array_size;
6979 NumberToInt32(*new_length_handle) >= max_fast_array_size;
6980 } 6978 }
6981 6979
6982 6980
6983 bool JSArray::AllowsSetElementsLength() { 6981 bool JSArray::AllowsSetLength() {
6984 bool result = elements()->IsFixedArray() || elements()->IsFixedDoubleArray(); 6982 bool result = elements()->IsFixedArray() || elements()->IsFixedDoubleArray();
6985 DCHECK(result == !HasExternalArrayElements()); 6983 DCHECK(result == !HasExternalArrayElements());
6986 return result; 6984 return result;
6987 } 6985 }
6988 6986
6989 6987
6990 void JSArray::SetContent(Handle<JSArray> array, 6988 void JSArray::SetContent(Handle<JSArray> array,
6991 Handle<FixedArrayBase> storage) { 6989 Handle<FixedArrayBase> storage) {
6992 EnsureCanContainElements(array, storage, storage->length(), 6990 EnsureCanContainElements(array, storage, storage->length(),
6993 ALLOW_COPIED_DOUBLE_ELEMENTS); 6991 ALLOW_COPIED_DOUBLE_ELEMENTS);
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
7323 #undef READ_SHORT_FIELD 7321 #undef READ_SHORT_FIELD
7324 #undef WRITE_SHORT_FIELD 7322 #undef WRITE_SHORT_FIELD
7325 #undef READ_BYTE_FIELD 7323 #undef READ_BYTE_FIELD
7326 #undef WRITE_BYTE_FIELD 7324 #undef WRITE_BYTE_FIELD
7327 #undef NOBARRIER_READ_BYTE_FIELD 7325 #undef NOBARRIER_READ_BYTE_FIELD
7328 #undef NOBARRIER_WRITE_BYTE_FIELD 7326 #undef NOBARRIER_WRITE_BYTE_FIELD
7329 7327
7330 } } // namespace v8::internal 7328 } } // namespace v8::internal
7331 7329
7332 #endif // V8_OBJECTS_INL_H_ 7330 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/runtime/runtime-array.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698