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

Unified Diff: src/objects-inl.h

Issue 1086873003: Array() in optimized code can create with wrong ElementsKind in corner cases. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix a test expectation. Created 5 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 side-by-side diff with in-line comments
Download patch
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index e5e8235c292a15049f7afffd4ca0d0b9b9eb85fb..347597b5af8e7a52ae49fad9144f696eba5eaa69 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -7201,6 +7201,20 @@ void JSArray::set_length(Smi* length) {
}
+bool JSArray::SetElementsLengthWouldNormalize(
+ Heap* heap, Handle<Object> new_length_handle) {
+ // If the new array won't fit in a some non-trivial fraction of the max old
+ // space size, then force it to go dictionary mode.
+ int max_fast_array_size =
+ static_cast<int>((heap->MaxOldGenerationSize() / kDoubleSize) / 4);
+ if (new_length_handle->IsNumber() &&
Toon Verwaest 2015/04/15 12:56:23 return new_length_handle->IsNumber() && NumberToIn
mvstanton 2015/04/15 14:10:34 Done.
+ NumberToInt32(*new_length_handle) >= max_fast_array_size) {
+ return true;
+ }
+ return false;
+}
+
+
bool JSArray::AllowsSetElementsLength() {
bool result = elements()->IsFixedArray() || elements()->IsFixedDoubleArray();
DCHECK(result == !HasExternalArrayElements());
« no previous file with comments | « src/objects.cc ('k') | src/runtime/runtime-array.cc » ('j') | src/runtime/runtime-array.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698