From e058354294ba2a87557c4b62df8242bd1f3e6ce4 Mon Sep 17 00:00:00 2001 From: "keith_miller@apple.com" Date: Fri, 4 May 2018 20:47:57 +0000 Subject: [PATCH] isCacheableArrayLength should return true for undecided arrays https://bugs.webkit.org/show_bug.cgi?id=185309 Reviewed by Michael Saboff. JSTests: * stress/get-array-length-undecided.js: Added. (test): Source/JavaScriptCore: Undecided arrays have butterflies so there is no reason why we should not be able to cache their length. * bytecode/InlineAccess.cpp: (JSC::InlineAccess::isCacheableArrayLength): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231375 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- JSTests/ChangeLog | 10 ++++++++++ JSTests/stress/get-array-length-undecided.js | 10 ++++++++++ Source/JavaScriptCore/ChangeLog | 13 +++++++++++++ Source/JavaScriptCore/bytecode/InlineAccess.cpp | 4 +--- 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 JSTests/stress/get-array-length-undecided.js diff --git a/JSTests/ChangeLog b/JSTests/ChangeLog index e616a3b..3cc1a48 100644 --- a/JSTests/ChangeLog +++ b/JSTests/ChangeLog @@ -1,3 +1,13 @@ +2018-05-04 Keith Miller + + isCacheableArrayLength should return true for undecided arrays + https://bugs.webkit.org/show_bug.cgi?id=185309 + + Reviewed by Michael Saboff. + + * stress/get-array-length-undecided.js: Added. + (test): + 2018-05-04 Dominik Infuehr Disable tests on systems with limited memory diff --git a/JSTests/stress/get-array-length-undecided.js b/JSTests/stress/get-array-length-undecided.js new file mode 100644 index 0000000..2ea3943 --- /dev/null +++ b/JSTests/stress/get-array-length-undecided.js @@ -0,0 +1,10 @@ +function test(array) { + return array.length; +} +noInline(test); + +let array = new Array(10); +for (let i = 0; i < 10000; i++) { + if (test(array) !== 10) + throw new Error("bad result"); +} diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog index 2dbcc93..e61aafe 100644 --- a/Source/JavaScriptCore/ChangeLog +++ b/Source/JavaScriptCore/ChangeLog @@ -1,3 +1,16 @@ +2018-05-04 Keith Miller + + isCacheableArrayLength should return true for undecided arrays + https://bugs.webkit.org/show_bug.cgi?id=185309 + + Reviewed by Michael Saboff. + + Undecided arrays have butterflies so there is no reason why we + should not be able to cache their length. + + * bytecode/InlineAccess.cpp: + (JSC::InlineAccess::isCacheableArrayLength): + 2018-05-03 Yusuke Suzuki Remove std::random_shuffle diff --git a/Source/JavaScriptCore/bytecode/InlineAccess.cpp b/Source/JavaScriptCore/bytecode/InlineAccess.cpp index d3dcfe0..9130b1e 100644 --- a/Source/JavaScriptCore/bytecode/InlineAccess.cpp +++ b/Source/JavaScriptCore/bytecode/InlineAccess.cpp @@ -249,9 +249,7 @@ bool InlineAccess::isCacheableArrayLength(StructureStubInfo& stubInfo, JSArray* if (!hasFreeRegister(stubInfo)) return false; - return array->indexingType() == ArrayWithInt32 - || array->indexingType() == ArrayWithDouble - || array->indexingType() == ArrayWithContiguous; + return !hasAnyArrayStorage(array->indexingType()) && array->indexingType() != ArrayClass; } bool InlineAccess::generateArrayLength(StructureStubInfo& stubInfo, JSArray* array) -- 1.8.3.1