From 1d2a4b8333027a90d07eb5f3ed618dc9bbea7dec Mon Sep 17 00:00:00 2001 From: "danno@chromium.org" Date: Fri, 18 Jul 2014 07:17:21 +0000 Subject: [PATCH] Remove experimental flags that are now required R=mstarzinger@chromium.org Review URL: https://codereview.chromium.org/397253002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22461 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/elements-kind.cc | 9 - src/elements-kind.h | 2 +- src/flag-definitions.h | 2 - src/objects.cc | 8 +- src/runtime.cc | 17 +- test/mjsunit/allocation-site-info.js | 738 +++++++++++++-------------- test/mjsunit/array-construct-transition.js | 18 +- test/mjsunit/array-constructor-feedback.js | 313 ++++++------ test/mjsunit/array-feedback.js | 313 ++++++------ test/mjsunit/array-literal-feedback.js | 103 ++-- test/mjsunit/array-literal-transitions.js | 203 ++++---- test/mjsunit/array-natives-elements.js | 25 +- test/mjsunit/elements-kind-depends.js | 2 +- test/mjsunit/elements-kind.js | 333 ++++++------ test/mjsunit/elements-transition-hoisting.js | 20 +- test/mjsunit/elements-transition.js | 164 +++--- test/mjsunit/opt-elements-kind.js | 23 +- test/mjsunit/osr-elements-kind.js | 103 ++-- test/mjsunit/packed-elements.js | 18 +- test/mjsunit/regress/regress-320532.js | 2 +- test/mjsunit/regress/regress-crbug-245480.js | 38 +- 21 files changed, 1088 insertions(+), 1366 deletions(-) diff --git a/src/elements-kind.cc b/src/elements-kind.cc index 96d66af..689a89c 100644 --- a/src/elements-kind.cc +++ b/src/elements-kind.cc @@ -65,15 +65,6 @@ const char* ElementsKindToString(ElementsKind kind) { } -ElementsKind GetInitialFastElementsKind() { - if (FLAG_packed_arrays) { - return FAST_SMI_ELEMENTS; - } else { - return FAST_HOLEY_SMI_ELEMENTS; - } -} - - struct InitializeFastElementsKindSequence { static void Construct( ElementsKind** fast_elements_kind_sequence_ptr) { diff --git a/src/elements-kind.h b/src/elements-kind.h index 25d910f..318addd 100644 --- a/src/elements-kind.h +++ b/src/elements-kind.h @@ -76,7 +76,7 @@ int ElementsKindToShiftSize(ElementsKind elements_kind); int GetDefaultHeaderSizeForElementsKind(ElementsKind elements_kind); const char* ElementsKindToString(ElementsKind kind); -ElementsKind GetInitialFastElementsKind(); +inline ElementsKind GetInitialFastElementsKind() { return FAST_SMI_ELEMENTS; } ElementsKind GetFastElementsKindFromSequenceIndex(int sequence_number); int GetSequenceIndexFromFastElementsKind(ElementsKind elements_kind); diff --git a/src/flag-definitions.h b/src/flag-definitions.h index 30464ef..6c2d614 100644 --- a/src/flag-definitions.h +++ b/src/flag-definitions.h @@ -187,8 +187,6 @@ DEFINE_IMPLICATION(es_staging, harmony_symbols) DEFINE_IMPLICATION(es_staging, harmony_collections) // Flags for experimental implementation features. -DEFINE_BOOL(packed_arrays, true, "optimizes arrays that have no holes") -DEFINE_BOOL(smi_only_arrays, true, "tracks arrays with only smi values") DEFINE_BOOL(compiled_keyed_dictionary_loads, true, "use optimizing compiler to generate keyed dictionary load stubs") DEFINE_BOOL(compiled_keyed_generic_loads, false, diff --git a/src/objects.cc b/src/objects.cc index 43288ad..b423560 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -12647,15 +12647,11 @@ MaybeHandle JSObject::SetDictionaryElement( } else { new_length = dictionary->max_number_key() + 1; } - SetFastElementsCapacitySmiMode smi_mode = FLAG_smi_only_arrays - ? kAllowSmiElements - : kDontAllowSmiElements; bool has_smi_only_elements = false; bool should_convert_to_fast_double_elements = object->ShouldConvertToFastDoubleElements(&has_smi_only_elements); - if (has_smi_only_elements) { - smi_mode = kForceSmiElements; - } + SetFastElementsCapacitySmiMode smi_mode = + has_smi_only_elements ? kForceSmiElements : kAllowSmiElements; if (should_convert_to_fast_double_elements) { SetFastDoubleElementsCapacityAndLength(object, new_length, new_length); diff --git a/src/runtime.cc b/src/runtime.cc index 17bc34a..08af524 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -369,7 +369,6 @@ MaybeHandle Runtime::CreateArrayLiteralBoilerplate( Handle copied_elements_values; if (IsFastDoubleElementsKind(constant_elements_kind)) { - ASSERT(FLAG_smi_only_arrays); copied_elements_values = isolate->factory()->CopyFixedDoubleArray( Handle::cast(constant_elements_values)); } else { @@ -410,20 +409,6 @@ MaybeHandle Runtime::CreateArrayLiteralBoilerplate( object->set_elements(*copied_elements_values); object->set_length(Smi::FromInt(copied_elements_values->length())); - // Ensure that the boilerplate object has FAST_*_ELEMENTS, unless the flag is - // on or the object is larger than the threshold. - if (!FLAG_smi_only_arrays && - constant_elements_values->length() < kSmiLiteralMinimumLength) { - ElementsKind elements_kind = object->GetElementsKind(); - if (!IsFastObjectElementsKind(elements_kind)) { - if (IsFastHoleyElementsKind(elements_kind)) { - TransitionElements(object, FAST_HOLEY_ELEMENTS, isolate).Check(); - } else { - TransitionElements(object, FAST_ELEMENTS, isolate).Check(); - } - } - } - JSObject::ValidateElements(object); return object; } @@ -4837,7 +4822,7 @@ RUNTIME_FUNCTION(Runtime_KeyedGetProperty) { // If value is the hole (meaning, absent) do the general lookup. } } - } else if (FLAG_smi_only_arrays && key_obj->IsSmi()) { + } else if (key_obj->IsSmi()) { // JSObject without a name key. If the key is a Smi, check for a // definite out-of-bounds access to elements, which is a strong indicator // that subsequent accesses will also call the runtime. Proactively diff --git a/test/mjsunit/allocation-site-info.js b/test/mjsunit/allocation-site-info.js index 0545754..8fa4941 100644 --- a/test/mjsunit/allocation-site-info.js +++ b/test/mjsunit/allocation-site-info.js @@ -25,25 +25,9 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --smi-only-arrays --expose-gc +// Flags: --allow-natives-syntax --expose-gc // Flags: --noalways-opt -// Test element kind of objects. -// Since --smi-only-arrays affects builtins, its default setting at compile -// time sticks if built with snapshot. If --smi-only-arrays is deactivated -// by default, only a no-snapshot build actually has smi-only arrays enabled -// in this test case. Depending on whether smi-only arrays are actually -// enabled, this test takes the appropriate code path to check smi-only arrays. - -// support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8)); -support_smi_only_arrays = true; - -if (support_smi_only_arrays) { - print("Tests include smi-only arrays."); -} else { - print("Tests do NOT include smi-only arrays."); -} - var elements_kind = { fast_smi_only : 'fast smi only elements', fast : 'fast elements', @@ -73,10 +57,6 @@ function isHoley(obj) { } function assertKind(expected, obj, name_opt) { - if (!support_smi_only_arrays && - expected == elements_kind.fast_smi_only) { - expected = elements_kind.fast; - } assertEquals(expected, getKind(obj), name_opt); } @@ -88,408 +68,406 @@ function assertNotHoley(obj, name_opt) { assertEquals(false, isHoley(obj), name_opt); } -if (support_smi_only_arrays) { - obj = []; - assertNotHoley(obj); - assertKind(elements_kind.fast_smi_only, obj); +obj = []; +assertNotHoley(obj); +assertKind(elements_kind.fast_smi_only, obj); - obj = [1, 2, 3]; - assertNotHoley(obj); - assertKind(elements_kind.fast_smi_only, obj); +obj = [1, 2, 3]; +assertNotHoley(obj); +assertKind(elements_kind.fast_smi_only, obj); - obj = new Array(); - assertNotHoley(obj); - assertKind(elements_kind.fast_smi_only, obj); +obj = new Array(); +assertNotHoley(obj); +assertKind(elements_kind.fast_smi_only, obj); - obj = new Array(0); - assertNotHoley(obj); - assertKind(elements_kind.fast_smi_only, obj); +obj = new Array(0); +assertNotHoley(obj); +assertKind(elements_kind.fast_smi_only, obj); - obj = new Array(2); - assertHoley(obj); - assertKind(elements_kind.fast_smi_only, obj); +obj = new Array(2); +assertHoley(obj); +assertKind(elements_kind.fast_smi_only, obj); - obj = new Array(1,2,3); - assertNotHoley(obj); - assertKind(elements_kind.fast_smi_only, obj); +obj = new Array(1,2,3); +assertNotHoley(obj); +assertKind(elements_kind.fast_smi_only, obj); - obj = new Array(1, "hi", 2, undefined); - assertNotHoley(obj); - assertKind(elements_kind.fast, obj); +obj = new Array(1, "hi", 2, undefined); +assertNotHoley(obj); +assertKind(elements_kind.fast, obj); - function fastliteralcase(literal, value) { - literal[0] = value; - return literal; - } +function fastliteralcase(literal, value) { + literal[0] = value; + return literal; +} - function get_standard_literal() { - var literal = [1, 2, 3]; - return literal; - } +function get_standard_literal() { + var literal = [1, 2, 3]; + return literal; +} - // Case: [1,2,3] as allocation site - obj = fastliteralcase(get_standard_literal(), 1); - assertKind(elements_kind.fast_smi_only, obj); - obj = fastliteralcase(get_standard_literal(), 1.5); +// Case: [1,2,3] as allocation site +obj = fastliteralcase(get_standard_literal(), 1); +assertKind(elements_kind.fast_smi_only, obj); +obj = fastliteralcase(get_standard_literal(), 1.5); +assertKind(elements_kind.fast_double, obj); +obj = fastliteralcase(get_standard_literal(), 2); +assertKind(elements_kind.fast_double, obj); + +// The test below is in a loop because arrays that live +// at global scope without the chance of being recreated +// don't have allocation site information attached. +for (i = 0; i < 2; i++) { + obj = fastliteralcase([5, 3, 2], 1.5); assertKind(elements_kind.fast_double, obj); - obj = fastliteralcase(get_standard_literal(), 2); + obj = fastliteralcase([3, 6, 2], 1.5); assertKind(elements_kind.fast_double, obj); - // The test below is in a loop because arrays that live - // at global scope without the chance of being recreated - // don't have allocation site information attached. - for (i = 0; i < 2; i++) { - obj = fastliteralcase([5, 3, 2], 1.5); - assertKind(elements_kind.fast_double, obj); - obj = fastliteralcase([3, 6, 2], 1.5); - assertKind(elements_kind.fast_double, obj); - - // Note: thanks to pessimistic transition store stubs, we'll attempt - // to transition to the most general elements kind seen at a particular - // store site. So, the elements kind will be double. - obj = fastliteralcase([2, 6, 3], 2); - assertKind(elements_kind.fast_double, obj); - } + // Note: thanks to pessimistic transition store stubs, we'll attempt + // to transition to the most general elements kind seen at a particular + // store site. So, the elements kind will be double. + obj = fastliteralcase([2, 6, 3], 2); + assertKind(elements_kind.fast_double, obj); +} - // Verify that we will not pretransition the double->fast path. - obj = fastliteralcase(get_standard_literal(), "elliot"); - assertKind(elements_kind.fast, obj); - obj = fastliteralcase(get_standard_literal(), 3); - assertKind(elements_kind.fast, obj); +// Verify that we will not pretransition the double->fast path. +obj = fastliteralcase(get_standard_literal(), "elliot"); +assertKind(elements_kind.fast, obj); +obj = fastliteralcase(get_standard_literal(), 3); +assertKind(elements_kind.fast, obj); - // Make sure this works in crankshafted code too. +// Make sure this works in crankshafted code too. %OptimizeFunctionOnNextCall(get_standard_literal); - get_standard_literal(); - obj = get_standard_literal(); - assertKind(elements_kind.fast, obj); +get_standard_literal(); +obj = get_standard_literal(); +assertKind(elements_kind.fast, obj); + +function fastliteralcase_smifast(value) { + var literal = [1, 2, 3, 4]; + literal[0] = value; + return literal; +} - function fastliteralcase_smifast(value) { - var literal = [1, 2, 3, 4]; - literal[0] = value; - return literal; - } +obj = fastliteralcase_smifast(1); +assertKind(elements_kind.fast_smi_only, obj); +obj = fastliteralcase_smifast("carter"); +assertKind(elements_kind.fast, obj); +obj = fastliteralcase_smifast(2); +assertKind(elements_kind.fast, obj); + +// Case: make sure transitions from packed to holey are tracked +function fastliteralcase_smiholey(index, value) { + var literal = [1, 2, 3, 4]; + literal[index] = value; + return literal; +} - obj = fastliteralcase_smifast(1); - assertKind(elements_kind.fast_smi_only, obj); - obj = fastliteralcase_smifast("carter"); - assertKind(elements_kind.fast, obj); - obj = fastliteralcase_smifast(2); - assertKind(elements_kind.fast, obj); +obj = fastliteralcase_smiholey(5, 1); +assertKind(elements_kind.fast_smi_only, obj); +assertHoley(obj); +obj = fastliteralcase_smiholey(0, 1); +assertKind(elements_kind.fast_smi_only, obj); +assertHoley(obj); + +function newarraycase_smidouble(value) { + var a = new Array(); + a[0] = value; + return a; +} - // Case: make sure transitions from packed to holey are tracked - function fastliteralcase_smiholey(index, value) { - var literal = [1, 2, 3, 4]; - literal[index] = value; - return literal; - } +// Case: new Array() as allocation site, smi->double +obj = newarraycase_smidouble(1); +assertKind(elements_kind.fast_smi_only, obj); +obj = newarraycase_smidouble(1.5); +assertKind(elements_kind.fast_double, obj); +obj = newarraycase_smidouble(2); +assertKind(elements_kind.fast_double, obj); + +function newarraycase_smiobj(value) { + var a = new Array(); + a[0] = value; + return a; +} - obj = fastliteralcase_smiholey(5, 1); - assertKind(elements_kind.fast_smi_only, obj); - assertHoley(obj); - obj = fastliteralcase_smiholey(0, 1); - assertKind(elements_kind.fast_smi_only, obj); - assertHoley(obj); +// Case: new Array() as allocation site, smi->fast +obj = newarraycase_smiobj(1); +assertKind(elements_kind.fast_smi_only, obj); +obj = newarraycase_smiobj("gloria"); +assertKind(elements_kind.fast, obj); +obj = newarraycase_smiobj(2); +assertKind(elements_kind.fast, obj); + +function newarraycase_length_smidouble(value) { + var a = new Array(3); + a[0] = value; + return a; +} - function newarraycase_smidouble(value) { - var a = new Array(); - a[0] = value; - return a; - } +// Case: new Array(length) as allocation site +obj = newarraycase_length_smidouble(1); +assertKind(elements_kind.fast_smi_only, obj); +obj = newarraycase_length_smidouble(1.5); +assertKind(elements_kind.fast_double, obj); +obj = newarraycase_length_smidouble(2); +assertKind(elements_kind.fast_double, obj); + +// Try to continue the transition to fast object. +// TODO(mvstanton): re-enable commented out code when +// FLAG_pretenuring_call_new is turned on in the build. +obj = newarraycase_length_smidouble("coates"); +assertKind(elements_kind.fast, obj); +obj = newarraycase_length_smidouble(2); +// assertKind(elements_kind.fast, obj); + +function newarraycase_length_smiobj(value) { + var a = new Array(3); + a[0] = value; + return a; +} - // Case: new Array() as allocation site, smi->double - obj = newarraycase_smidouble(1); - assertKind(elements_kind.fast_smi_only, obj); - obj = newarraycase_smidouble(1.5); - assertKind(elements_kind.fast_double, obj); - obj = newarraycase_smidouble(2); - assertKind(elements_kind.fast_double, obj); +// Case: new Array() as allocation site, smi->fast +obj = newarraycase_length_smiobj(1); +assertKind(elements_kind.fast_smi_only, obj); +obj = newarraycase_length_smiobj("gloria"); +assertKind(elements_kind.fast, obj); +obj = newarraycase_length_smiobj(2); +assertKind(elements_kind.fast, obj); + +function newarraycase_list_smidouble(value) { + var a = new Array(1, 2, 3); + a[0] = value; + return a; +} + +obj = newarraycase_list_smidouble(1); +assertKind(elements_kind.fast_smi_only, obj); +obj = newarraycase_list_smidouble(1.5); +assertKind(elements_kind.fast_double, obj); +obj = newarraycase_list_smidouble(2); +assertKind(elements_kind.fast_double, obj); + +function newarraycase_list_smiobj(value) { + var a = new Array(4, 5, 6); + a[0] = value; + return a; +} - function newarraycase_smiobj(value) { - var a = new Array(); - a[0] = value; +obj = newarraycase_list_smiobj(1); +assertKind(elements_kind.fast_smi_only, obj); +obj = newarraycase_list_smiobj("coates"); +assertKind(elements_kind.fast, obj); +obj = newarraycase_list_smiobj(2); +assertKind(elements_kind.fast, obj); + +// Case: array constructor calls with out of date feedback. +// The boilerplate should incorporate all feedback, but the input array +// should be minimally transitioned based on immediate need. +(function() { + function foo(i) { + // We have two cases, one for literals one for constructed arrays. + var a = (i == 0) + ? [1, 2, 3] + : new Array(1, 2, 3); return a; } - // Case: new Array() as allocation site, smi->fast - obj = newarraycase_smiobj(1); - assertKind(elements_kind.fast_smi_only, obj); - obj = newarraycase_smiobj("gloria"); - assertKind(elements_kind.fast, obj); - obj = newarraycase_smiobj(2); - assertKind(elements_kind.fast, obj); - - function newarraycase_length_smidouble(value) { - var a = new Array(3); - a[0] = value; - return a; + for (i = 0; i < 2; i++) { + a = foo(i); + b = foo(i); + b[5] = 1; // boilerplate goes holey + assertHoley(foo(i)); + a[0] = 3.5; // boilerplate goes holey double + assertKind(elements_kind.fast_double, a); + assertNotHoley(a); + c = foo(i); + assertKind(elements_kind.fast_double, c); + assertHoley(c); } +})(); - // Case: new Array(length) as allocation site - obj = newarraycase_length_smidouble(1); - assertKind(elements_kind.fast_smi_only, obj); - obj = newarraycase_length_smidouble(1.5); - assertKind(elements_kind.fast_double, obj); - obj = newarraycase_length_smidouble(2); - assertKind(elements_kind.fast_double, obj); +function newarraycase_onearg(len, value) { + var a = new Array(len); + a[0] = value; + return a; +} - // Try to continue the transition to fast object. - // TODO(mvstanton): re-enable commented out code when - // FLAG_pretenuring_call_new is turned on in the build. - obj = newarraycase_length_smidouble("coates"); - assertKind(elements_kind.fast, obj); - obj = newarraycase_length_smidouble(2); - // assertKind(elements_kind.fast, obj); +obj = newarraycase_onearg(5, 3.5); +assertKind(elements_kind.fast_double, obj); +obj = newarraycase_onearg(10, 5); +assertKind(elements_kind.fast_double, obj); +obj = newarraycase_onearg(0, 5); +assertKind(elements_kind.fast_double, obj); +// Now pass a length that forces the dictionary path. +obj = newarraycase_onearg(100000, 5); +assertKind(elements_kind.dictionary, obj); +assertTrue(obj.length == 100000); + +// Verify that cross context calls work +var realmA = Realm.current(); +var realmB = Realm.create(); +assertEquals(0, realmA); +assertEquals(1, realmB); + +function instanceof_check(type) { + assertTrue(new type() instanceof type); + assertTrue(new type(5) instanceof type); + assertTrue(new type(1,2,3) instanceof type); +} - function newarraycase_length_smiobj(value) { - var a = new Array(3); - a[0] = value; - return a; - } +function instanceof_check2(type) { + assertTrue(new type() instanceof type); + assertTrue(new type(5) instanceof type); + assertTrue(new type(1,2,3) instanceof type); +} - // Case: new Array() as allocation site, smi->fast - obj = newarraycase_length_smiobj(1); - assertKind(elements_kind.fast_smi_only, obj); - obj = newarraycase_length_smiobj("gloria"); - assertKind(elements_kind.fast, obj); - obj = newarraycase_length_smiobj(2); - assertKind(elements_kind.fast, obj); +var realmBArray = Realm.eval(realmB, "Array"); +instanceof_check(Array); +instanceof_check(realmBArray); - function newarraycase_list_smidouble(value) { - var a = new Array(1, 2, 3); - a[0] = value; - return a; - } +// instanceof_check2 is here because the call site goes through a state. +// Since instanceof_check(Array) was first called with the current context +// Array function, it went from (uninit->Array) then (Array->megamorphic). +// We'll get a different state traversal if we start with realmBArray. +// It'll go (uninit->realmBArray) then (realmBArray->megamorphic). Recognize +// that state "Array" implies an AllocationSite is present, and code is +// configured to use it. +instanceof_check2(realmBArray); +instanceof_check2(Array); - obj = newarraycase_list_smidouble(1); - assertKind(elements_kind.fast_smi_only, obj); - obj = newarraycase_list_smidouble(1.5); - assertKind(elements_kind.fast_double, obj); - obj = newarraycase_list_smidouble(2); - assertKind(elements_kind.fast_double, obj); + %OptimizeFunctionOnNextCall(instanceof_check); - function newarraycase_list_smiobj(value) { - var a = new Array(4, 5, 6); - a[0] = value; - return a; +// No de-opt will occur because HCallNewArray wasn't selected, on account of +// the call site not being monomorphic to Array. +instanceof_check(Array); +assertOptimized(instanceof_check); +instanceof_check(realmBArray); +assertOptimized(instanceof_check); + +// Try to optimize again, but first clear all type feedback, and allow it +// to be monomorphic on first call. Only after crankshafting do we introduce +// realmBArray. This should deopt the method. + %DeoptimizeFunction(instanceof_check); + %ClearFunctionTypeFeedback(instanceof_check); +instanceof_check(Array); +instanceof_check(Array); + %OptimizeFunctionOnNextCall(instanceof_check); +instanceof_check(Array); +assertOptimized(instanceof_check); + +instanceof_check(realmBArray); +assertUnoptimized(instanceof_check); + +// Case: make sure nested arrays benefit from allocation site feedback as +// well. +(function() { + // Make sure we handle nested arrays + function get_nested_literal() { + var literal = [[1,2,3,4], [2], [3]]; + return literal; } - obj = newarraycase_list_smiobj(1); - assertKind(elements_kind.fast_smi_only, obj); - obj = newarraycase_list_smiobj("coates"); - assertKind(elements_kind.fast, obj); - obj = newarraycase_list_smiobj(2); + obj = get_nested_literal(); assertKind(elements_kind.fast, obj); - - // Case: array constructor calls with out of date feedback. - // The boilerplate should incorporate all feedback, but the input array - // should be minimally transitioned based on immediate need. - (function() { - function foo(i) { - // We have two cases, one for literals one for constructed arrays. - var a = (i == 0) - ? [1, 2, 3] - : new Array(1, 2, 3); - return a; - } - - for (i = 0; i < 2; i++) { - a = foo(i); - b = foo(i); - b[5] = 1; // boilerplate goes holey - assertHoley(foo(i)); - a[0] = 3.5; // boilerplate goes holey double - assertKind(elements_kind.fast_double, a); - assertNotHoley(a); - c = foo(i); - assertKind(elements_kind.fast_double, c); - assertHoley(c); - } - })(); - - function newarraycase_onearg(len, value) { - var a = new Array(len); - a[0] = value; - return a; + obj[0][0] = 3.5; + obj[2][0] = "hello"; + obj = get_nested_literal(); + assertKind(elements_kind.fast_double, obj[0]); + assertKind(elements_kind.fast_smi_only, obj[1]); + assertKind(elements_kind.fast, obj[2]); + + // A more complex nested literal case. + function get_deep_nested_literal() { + var literal = [[1], [[2], "hello"], 3, [4]]; + return literal; } - obj = newarraycase_onearg(5, 3.5); - assertKind(elements_kind.fast_double, obj); - obj = newarraycase_onearg(10, 5); - assertKind(elements_kind.fast_double, obj); - obj = newarraycase_onearg(0, 5); - assertKind(elements_kind.fast_double, obj); - // Now pass a length that forces the dictionary path. - obj = newarraycase_onearg(100000, 5); - assertKind(elements_kind.dictionary, obj); - assertTrue(obj.length == 100000); - - // Verify that cross context calls work - var realmA = Realm.current(); - var realmB = Realm.create(); - assertEquals(0, realmA); - assertEquals(1, realmB); - - function instanceof_check(type) { - assertTrue(new type() instanceof type); - assertTrue(new type(5) instanceof type); - assertTrue(new type(1,2,3) instanceof type); + obj = get_deep_nested_literal(); + assertKind(elements_kind.fast_smi_only, obj[1][0]); + obj[0][0] = 3.5; + obj[1][0][0] = "goodbye"; + assertKind(elements_kind.fast_double, obj[0]); + assertKind(elements_kind.fast, obj[1][0]); + + obj = get_deep_nested_literal(); + assertKind(elements_kind.fast_double, obj[0]); + assertKind(elements_kind.fast, obj[1][0]); +})(); + +// Perform a gc because without it the test below can experience an +// allocation failure at an inconvenient point. Allocation mementos get +// cleared on gc, and they can't deliver elements kind feedback when that +// happens. +gc(); + +// Make sure object literals with array fields benefit from the type feedback +// that allocation mementos provide. +(function() { + // A literal in an object + function get_object_literal() { + var literal = { + array: [1,2,3], + data: 3.5 + }; + return literal; } - function instanceof_check2(type) { - assertTrue(new type() instanceof type); - assertTrue(new type(5) instanceof type); - assertTrue(new type(1,2,3) instanceof type); + obj = get_object_literal(); + assertKind(elements_kind.fast_smi_only, obj.array); + obj.array[1] = 3.5; + assertKind(elements_kind.fast_double, obj.array); + obj = get_object_literal(); + assertKind(elements_kind.fast_double, obj.array); + + function get_nested_object_literal() { + var literal = { + array: [[1],[2],[3]], + data: 3.5 + }; + return literal; } - var realmBArray = Realm.eval(realmB, "Array"); - instanceof_check(Array); - instanceof_check(realmBArray); - - // instanceof_check2 is here because the call site goes through a state. - // Since instanceof_check(Array) was first called with the current context - // Array function, it went from (uninit->Array) then (Array->megamorphic). - // We'll get a different state traversal if we start with realmBArray. - // It'll go (uninit->realmBArray) then (realmBArray->megamorphic). Recognize - // that state "Array" implies an AllocationSite is present, and code is - // configured to use it. - instanceof_check2(realmBArray); - instanceof_check2(Array); + obj = get_nested_object_literal(); + assertKind(elements_kind.fast, obj.array); + assertKind(elements_kind.fast_smi_only, obj.array[1]); + obj.array[1][0] = 3.5; + assertKind(elements_kind.fast_double, obj.array[1]); + obj = get_nested_object_literal(); + assertKind(elements_kind.fast_double, obj.array[1]); - %OptimizeFunctionOnNextCall(instanceof_check); + %OptimizeFunctionOnNextCall(get_nested_object_literal); + get_nested_object_literal(); + obj = get_nested_object_literal(); + assertKind(elements_kind.fast_double, obj.array[1]); - // No de-opt will occur because HCallNewArray wasn't selected, on account of - // the call site not being monomorphic to Array. - instanceof_check(Array); - assertOptimized(instanceof_check); - instanceof_check(realmBArray); - assertOptimized(instanceof_check); + // Make sure we handle nested arrays + function get_nested_literal() { + var literal = [[1,2,3,4], [2], [3]]; + return literal; + } - // Try to optimize again, but first clear all type feedback, and allow it - // to be monomorphic on first call. Only after crankshafting do we introduce - // realmBArray. This should deopt the method. - %DeoptimizeFunction(instanceof_check); - %ClearFunctionTypeFeedback(instanceof_check); - instanceof_check(Array); - instanceof_check(Array); - %OptimizeFunctionOnNextCall(instanceof_check); - instanceof_check(Array); - assertOptimized(instanceof_check); - - instanceof_check(realmBArray); - assertUnoptimized(instanceof_check); - - // Case: make sure nested arrays benefit from allocation site feedback as - // well. - (function() { - // Make sure we handle nested arrays - function get_nested_literal() { - var literal = [[1,2,3,4], [2], [3]]; - return literal; - } - - obj = get_nested_literal(); - assertKind(elements_kind.fast, obj); - obj[0][0] = 3.5; - obj[2][0] = "hello"; - obj = get_nested_literal(); - assertKind(elements_kind.fast_double, obj[0]); - assertKind(elements_kind.fast_smi_only, obj[1]); - assertKind(elements_kind.fast, obj[2]); - - // A more complex nested literal case. - function get_deep_nested_literal() { - var literal = [[1], [[2], "hello"], 3, [4]]; - return literal; - } - - obj = get_deep_nested_literal(); - assertKind(elements_kind.fast_smi_only, obj[1][0]); - obj[0][0] = 3.5; - obj[1][0][0] = "goodbye"; - assertKind(elements_kind.fast_double, obj[0]); - assertKind(elements_kind.fast, obj[1][0]); - - obj = get_deep_nested_literal(); - assertKind(elements_kind.fast_double, obj[0]); - assertKind(elements_kind.fast, obj[1][0]); - })(); - - // Perform a gc because without it the test below can experience an - // allocation failure at an inconvenient point. Allocation mementos get - // cleared on gc, and they can't deliver elements kind feedback when that - // happens. - gc(); - - // Make sure object literals with array fields benefit from the type feedback - // that allocation mementos provide. - (function() { - // A literal in an object - function get_object_literal() { - var literal = { - array: [1,2,3], - data: 3.5 - }; - return literal; - } - - obj = get_object_literal(); - assertKind(elements_kind.fast_smi_only, obj.array); - obj.array[1] = 3.5; - assertKind(elements_kind.fast_double, obj.array); - obj = get_object_literal(); - assertKind(elements_kind.fast_double, obj.array); - - function get_nested_object_literal() { - var literal = { - array: [[1],[2],[3]], - data: 3.5 - }; - return literal; - } - - obj = get_nested_object_literal(); - assertKind(elements_kind.fast, obj.array); - assertKind(elements_kind.fast_smi_only, obj.array[1]); - obj.array[1][0] = 3.5; - assertKind(elements_kind.fast_double, obj.array[1]); - obj = get_nested_object_literal(); - assertKind(elements_kind.fast_double, obj.array[1]); + obj = get_nested_literal(); + assertKind(elements_kind.fast, obj); + obj[0][0] = 3.5; + obj[2][0] = "hello"; + obj = get_nested_literal(); + assertKind(elements_kind.fast_double, obj[0]); + assertKind(elements_kind.fast_smi_only, obj[1]); + assertKind(elements_kind.fast, obj[2]); + + // A more complex nested literal case. + function get_deep_nested_literal() { + var literal = [[1], [[2], "hello"], 3, [4]]; + return literal; + } - %OptimizeFunctionOnNextCall(get_nested_object_literal); - get_nested_object_literal(); - obj = get_nested_object_literal(); - assertKind(elements_kind.fast_double, obj.array[1]); - - // Make sure we handle nested arrays - function get_nested_literal() { - var literal = [[1,2,3,4], [2], [3]]; - return literal; - } - - obj = get_nested_literal(); - assertKind(elements_kind.fast, obj); - obj[0][0] = 3.5; - obj[2][0] = "hello"; - obj = get_nested_literal(); - assertKind(elements_kind.fast_double, obj[0]); - assertKind(elements_kind.fast_smi_only, obj[1]); - assertKind(elements_kind.fast, obj[2]); - - // A more complex nested literal case. - function get_deep_nested_literal() { - var literal = [[1], [[2], "hello"], 3, [4]]; - return literal; - } - - obj = get_deep_nested_literal(); - assertKind(elements_kind.fast_smi_only, obj[1][0]); - obj[0][0] = 3.5; - obj[1][0][0] = "goodbye"; - assertKind(elements_kind.fast_double, obj[0]); - assertKind(elements_kind.fast, obj[1][0]); - - obj = get_deep_nested_literal(); - assertKind(elements_kind.fast_double, obj[0]); - assertKind(elements_kind.fast, obj[1][0]); - })(); -} + obj = get_deep_nested_literal(); + assertKind(elements_kind.fast_smi_only, obj[1][0]); + obj[0][0] = 3.5; + obj[1][0][0] = "goodbye"; + assertKind(elements_kind.fast_double, obj[0]); + assertKind(elements_kind.fast, obj[1][0]); + + obj = get_deep_nested_literal(); + assertKind(elements_kind.fast_double, obj[0]); + assertKind(elements_kind.fast, obj[1][0]); +})(); diff --git a/test/mjsunit/array-construct-transition.js b/test/mjsunit/array-construct-transition.js index f8d7c83..3847f94 100644 --- a/test/mjsunit/array-construct-transition.js +++ b/test/mjsunit/array-construct-transition.js @@ -25,15 +25,11 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --smi-only-arrays +// Flags: --allow-natives-syntax -support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6)); - -if (support_smi_only_arrays) { - var a = new Array(0, 1, 2); - assertTrue(%HasFastSmiElements(a)); - var b = new Array(0.5, 1.2, 2.3); - assertTrue(%HasFastDoubleElements(b)); - var c = new Array(0.5, 1.2, new Object()); - assertTrue(%HasFastObjectElements(c)); -} +var a = new Array(0, 1, 2); +assertTrue(%HasFastSmiElements(a)); +var b = new Array(0.5, 1.2, 2.3); +assertTrue(%HasFastDoubleElements(b)); +var c = new Array(0.5, 1.2, new Object()); +assertTrue(%HasFastObjectElements(c)); diff --git a/test/mjsunit/array-constructor-feedback.js b/test/mjsunit/array-constructor-feedback.js index 9bc62e4..d216731 100644 --- a/test/mjsunit/array-constructor-feedback.js +++ b/test/mjsunit/array-constructor-feedback.js @@ -25,24 +25,10 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --smi-only-arrays --expose-gc +// Flags: --allow-natives-syntax --expose-gc // Flags: --noalways-opt // Test element kind of objects. -// Since --smi-only-arrays affects builtins, its default setting at compile -// time sticks if built with snapshot. If --smi-only-arrays is deactivated -// by default, only a no-snapshot build actually has smi-only arrays enabled -// in this test case. Depending on whether smi-only arrays are actually -// enabled, this test takes the appropriate code path to check smi-only arrays. - -// support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8)); -support_smi_only_arrays = true; - -if (support_smi_only_arrays) { - print("Tests include smi-only arrays."); -} else { - print("Tests do NOT include smi-only arrays."); -} var elements_kind = { fast_smi_only : 'fast smi only elements', @@ -73,169 +59,162 @@ function isHoley(obj) { } function assertKind(expected, obj, name_opt) { - if (!support_smi_only_arrays && - expected == elements_kind.fast_smi_only) { - expected = elements_kind.fast; - } assertEquals(expected, getKind(obj), name_opt); } -if (support_smi_only_arrays) { - - // Test: If a call site goes megamorphic, it retains the ability to - // use allocation site feedback (if FLAG_allocation_site_pretenuring - // is on). - (function() { - function bar(t, len) { - return new t(len); - } - - a = bar(Array, 10); - a[0] = 3.5; - b = bar(Array, 1); - assertKind(elements_kind.fast_double, b); - c = bar(Object, 3); - b = bar(Array, 10); - // TODO(mvstanton): re-enable when FLAG_allocation_site_pretenuring - // is on in the build. - // assertKind(elements_kind.fast_double, b); - })(); - - - // Test: ensure that crankshafted array constructor sites are deopted - // if another function is used. - (function() { - function bar0(t) { - return new t(); - } - a = bar0(Array); - a[0] = 3.5; - b = bar0(Array); - assertKind(elements_kind.fast_double, b); +// Test: If a call site goes megamorphic, it retains the ability to +// use allocation site feedback (if FLAG_allocation_site_pretenuring +// is on). +(function() { + function bar(t, len) { + return new t(len); + } + + a = bar(Array, 10); + a[0] = 3.5; + b = bar(Array, 1); + assertKind(elements_kind.fast_double, b); + c = bar(Object, 3); + b = bar(Array, 10); + // TODO(mvstanton): re-enable when FLAG_allocation_site_pretenuring + // is on in the build. + // assertKind(elements_kind.fast_double, b); +})(); + + +// Test: ensure that crankshafted array constructor sites are deopted +// if another function is used. +(function() { + function bar0(t) { + return new t(); + } + a = bar0(Array); + a[0] = 3.5; + b = bar0(Array); + assertKind(elements_kind.fast_double, b); %OptimizeFunctionOnNextCall(bar0); - b = bar0(Array); - assertKind(elements_kind.fast_double, b); - assertOptimized(bar0); - // bar0 should deopt - b = bar0(Object); - assertUnoptimized(bar0) - // When it's re-optimized, we should call through the full stub - bar0(Array); + b = bar0(Array); + assertKind(elements_kind.fast_double, b); + assertOptimized(bar0); + // bar0 should deopt + b = bar0(Object); + assertUnoptimized(bar0) + // When it's re-optimized, we should call through the full stub + bar0(Array); %OptimizeFunctionOnNextCall(bar0); - b = bar0(Array); - // This only makes sense to test if we allow crankshafting - if (4 != %GetOptimizationStatus(bar0)) { - // We also lost our ability to record kind feedback, as the site - // is megamorphic now. - assertKind(elements_kind.fast_smi_only, b); - assertOptimized(bar0); - b[0] = 3.5; - c = bar0(Array); - assertKind(elements_kind.fast_smi_only, c); - } - })(); - - - // Test: Ensure that inlined array calls in crankshaft learn from deopts - // based on the move to a dictionary for the array. - (function() { - function bar(len) { - return new Array(len); - } - a = bar(10); - a[0] = "a string"; - a = bar(10); - assertKind(elements_kind.fast, a); - %OptimizeFunctionOnNextCall(bar); - a = bar(10); - assertKind(elements_kind.fast, a); - assertOptimized(bar); - a = bar(100000); - assertKind(elements_kind.dictionary, a); - assertOptimized(bar); + b = bar0(Array); + // This only makes sense to test if we allow crankshafting + if (4 != %GetOptimizationStatus(bar0)) { + // We also lost our ability to record kind feedback, as the site + // is megamorphic now. + assertKind(elements_kind.fast_smi_only, b); + assertOptimized(bar0); + b[0] = 3.5; + c = bar0(Array); + assertKind(elements_kind.fast_smi_only, c); + } +})(); - // If the argument isn't a smi, things should still work. - a = bar("oops"); - assertOptimized(bar); - assertKind(elements_kind.fast, a); - function barn(one, two, three) { - return new Array(one, two, three); - } +// Test: Ensure that inlined array calls in crankshaft learn from deopts +// based on the move to a dictionary for the array. +(function() { + function bar(len) { + return new Array(len); + } + a = bar(10); + a[0] = "a string"; + a = bar(10); + assertKind(elements_kind.fast, a); + %OptimizeFunctionOnNextCall(bar); + a = bar(10); + assertKind(elements_kind.fast, a); + assertOptimized(bar); + a = bar(100000); + assertKind(elements_kind.dictionary, a); + assertOptimized(bar); + + // If the argument isn't a smi, things should still work. + a = bar("oops"); + assertOptimized(bar); + assertKind(elements_kind.fast, a); + + function barn(one, two, three) { + return new Array(one, two, three); + } - barn(1, 2, 3); - barn(1, 2, 3); + barn(1, 2, 3); + barn(1, 2, 3); %OptimizeFunctionOnNextCall(barn); - barn(1, 2, 3); - assertOptimized(barn); - a = barn(1, "oops", 3); - assertOptimized(barn); - })(); - - - // Test: When a method with array constructor is crankshafted, the type - // feedback for elements kind is baked in. Verify that transitions don't - // change it anymore - (function() { - function bar() { - return new Array(); - } - a = bar(); - bar(); + barn(1, 2, 3); + assertOptimized(barn); + a = barn(1, "oops", 3); + assertOptimized(barn); +})(); + + +// Test: When a method with array constructor is crankshafted, the type +// feedback for elements kind is baked in. Verify that transitions don't +// change it anymore +(function() { + function bar() { + return new Array(); + } + a = bar(); + bar(); %OptimizeFunctionOnNextCall(bar); - b = bar(); - // This only makes sense to test if we allow crankshafting - if (4 != %GetOptimizationStatus(bar)) { - assertOptimized(bar); + b = bar(); + // This only makes sense to test if we allow crankshafting + if (4 != %GetOptimizationStatus(bar)) { + assertOptimized(bar); %DebugPrint(3); - b[0] = 3.5; - c = bar(); - assertKind(elements_kind.fast_smi_only, c); - assertOptimized(bar); - } - })(); - - - // Test: create arrays in two contexts, verifying that the correct - // map for Array in that context will be used. - (function() { - function bar() { return new Array(); } - bar(); - bar(); + b[0] = 3.5; + c = bar(); + assertKind(elements_kind.fast_smi_only, c); + assertOptimized(bar); + } +})(); + + +// Test: create arrays in two contexts, verifying that the correct +// map for Array in that context will be used. +(function() { + function bar() { return new Array(); } + bar(); + bar(); %OptimizeFunctionOnNextCall(bar); - a = bar(); - assertTrue(a instanceof Array); - - var contextB = Realm.create(); - Realm.eval(contextB, "function bar2() { return new Array(); };"); - Realm.eval(contextB, "bar2(); bar2();"); - Realm.eval(contextB, "%OptimizeFunctionOnNextCall(bar2);"); - Realm.eval(contextB, "bar2();"); - assertFalse(Realm.eval(contextB, "bar2();") instanceof Array); - assertTrue(Realm.eval(contextB, "bar2() instanceof Array")); - })(); - - // Test: create array with packed feedback, then optimize function, which - // should deal with arguments that create holey arrays. - (function() { - function bar(len) { return new Array(len); } - bar(0); - bar(0); + a = bar(); + assertTrue(a instanceof Array); + + var contextB = Realm.create(); + Realm.eval(contextB, "function bar2() { return new Array(); };"); + Realm.eval(contextB, "bar2(); bar2();"); + Realm.eval(contextB, "%OptimizeFunctionOnNextCall(bar2);"); + Realm.eval(contextB, "bar2();"); + assertFalse(Realm.eval(contextB, "bar2();") instanceof Array); + assertTrue(Realm.eval(contextB, "bar2() instanceof Array")); +})(); + +// Test: create array with packed feedback, then optimize function, which +// should deal with arguments that create holey arrays. +(function() { + function bar(len) { return new Array(len); } + bar(0); + bar(0); %OptimizeFunctionOnNextCall(bar); - a = bar(0); - assertOptimized(bar); + a = bar(0); + assertOptimized(bar); + assertFalse(isHoley(a)); + a = bar(1); // ouch! + assertOptimized(bar); + assertTrue(isHoley(a)); + a = bar(100); + assertTrue(isHoley(a)); + a = bar(0); + assertOptimized(bar); + // Crankshafted functions don't use mementos, so feedback still + // indicates a packed array is desired. (unless --nocrankshaft is in use). + if (4 != %GetOptimizationStatus(bar)) { assertFalse(isHoley(a)); - a = bar(1); // ouch! - assertOptimized(bar); - assertTrue(isHoley(a)); - a = bar(100); - assertTrue(isHoley(a)); - a = bar(0); - assertOptimized(bar); - // Crankshafted functions don't use mementos, so feedback still - // indicates a packed array is desired. (unless --nocrankshaft is in use). - if (4 != %GetOptimizationStatus(bar)) { - assertFalse(isHoley(a)); - } - })(); -} + } +})(); diff --git a/test/mjsunit/array-feedback.js b/test/mjsunit/array-feedback.js index 75a5358..bae6046 100644 --- a/test/mjsunit/array-feedback.js +++ b/test/mjsunit/array-feedback.js @@ -25,25 +25,9 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --smi-only-arrays --expose-gc +// Flags: --allow-natives-syntax --expose-gc // Flags: --noalways-opt -// Test element kind of objects. -// Since --smi-only-arrays affects builtins, its default setting at compile -// time sticks if built with snapshot. If --smi-only-arrays is deactivated -// by default, only a no-snapshot build actually has smi-only arrays enabled -// in this test case. Depending on whether smi-only arrays are actually -// enabled, this test takes the appropriate code path to check smi-only arrays. - -// support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8)); -support_smi_only_arrays = true; - -if (support_smi_only_arrays) { - print("Tests include smi-only arrays."); -} else { - print("Tests do NOT include smi-only arrays."); -} - var elements_kind = { fast_smi_only : 'fast smi only elements', fast : 'fast elements', @@ -73,160 +57,153 @@ function isHoley(obj) { } function assertKind(expected, obj, name_opt) { - if (!support_smi_only_arrays && - expected == elements_kind.fast_smi_only) { - expected = elements_kind.fast; - } assertEquals(expected, getKind(obj), name_opt); } -if (support_smi_only_arrays) { - - // Verify that basic elements kind feedback works for non-constructor - // array calls (as long as the call is made through an IC, and not - // a CallStub). - (function (){ - function create0() { - return Array(); - } - - // Calls through ICs need warm up through uninitialized, then - // premonomorphic first. - create0(); - a = create0(); - assertKind(elements_kind.fast_smi_only, a); - a[0] = 3.5; - b = create0(); - assertKind(elements_kind.fast_double, b); - - function create1(arg) { - return Array(arg); - } - - create1(0); - create1(0); - a = create1(0); - assertFalse(isHoley(a)); - assertKind(elements_kind.fast_smi_only, a); - a[0] = "hello"; - b = create1(10); - assertTrue(isHoley(b)); - assertKind(elements_kind.fast, b); - - a = create1(100000); - assertKind(elements_kind.dictionary, a); - - function create3(arg1, arg2, arg3) { - return Array(arg1, arg2, arg3); - } - - create3(1,2,3); - create3(1,2,3); - a = create3(1,2,3); - a[0] = 3.035; - assertKind(elements_kind.fast_double, a); - b = create3(1,2,3); - assertKind(elements_kind.fast_double, b); - assertFalse(isHoley(b)); - })(); - - - // Verify that keyed calls work - (function (){ - function create0(name) { - return this[name](); - } - - name = "Array"; - create0(name); - create0(name); - a = create0(name); - a[0] = 3.5; - b = create0(name); - assertKind(elements_kind.fast_double, b); - })(); - - - // Verify that feedback is turned off if the call site goes megamorphic. - (function (){ - function foo(arg) { return arg(); } - foo(Array); - foo(function() {}); - foo(Array); - - gc(); - - a = foo(Array); - a[0] = 3.5; - b = foo(Array); - // b doesn't benefit from elements kind feedback at a megamorphic site. - assertKind(elements_kind.fast_smi_only, b); - })(); - - - // Verify that crankshaft consumes type feedback. - (function (){ - function create0() { - return Array(); - } - - create0(); - create0(); - a = create0(); - a[0] = 3.5; +// Verify that basic elements kind feedback works for non-constructor +// array calls (as long as the call is made through an IC, and not +// a CallStub). +(function (){ + function create0() { + return Array(); + } + + // Calls through ICs need warm up through uninitialized, then + // premonomorphic first. + create0(); + a = create0(); + assertKind(elements_kind.fast_smi_only, a); + a[0] = 3.5; + b = create0(); + assertKind(elements_kind.fast_double, b); + + function create1(arg) { + return Array(arg); + } + + create1(0); + create1(0); + a = create1(0); + assertFalse(isHoley(a)); + assertKind(elements_kind.fast_smi_only, a); + a[0] = "hello"; + b = create1(10); + assertTrue(isHoley(b)); + assertKind(elements_kind.fast, b); + + a = create1(100000); + assertKind(elements_kind.dictionary, a); + + function create3(arg1, arg2, arg3) { + return Array(arg1, arg2, arg3); + } + + create3(1,2,3); + create3(1,2,3); + a = create3(1,2,3); + a[0] = 3.035; + assertKind(elements_kind.fast_double, a); + b = create3(1,2,3); + assertKind(elements_kind.fast_double, b); + assertFalse(isHoley(b)); +})(); + + +// Verify that keyed calls work +(function (){ + function create0(name) { + return this[name](); + } + + name = "Array"; + create0(name); + create0(name); + a = create0(name); + a[0] = 3.5; + b = create0(name); + assertKind(elements_kind.fast_double, b); +})(); + + +// Verify that feedback is turned off if the call site goes megamorphic. +(function (){ + function foo(arg) { return arg(); } + foo(Array); + foo(function() {}); + foo(Array); + + gc(); + + a = foo(Array); + a[0] = 3.5; + b = foo(Array); + // b doesn't benefit from elements kind feedback at a megamorphic site. + assertKind(elements_kind.fast_smi_only, b); +})(); + + +// Verify that crankshaft consumes type feedback. +(function (){ + function create0() { + return Array(); + } + + create0(); + create0(); + a = create0(); + a[0] = 3.5; %OptimizeFunctionOnNextCall(create0); - create0(); - create0(); - b = create0(); - assertKind(elements_kind.fast_double, b); - assertOptimized(create0); - - function create1(arg) { - return Array(arg); - } - - create1(8); - create1(8); - a = create1(8); - a[0] = 3.5; + create0(); + create0(); + b = create0(); + assertKind(elements_kind.fast_double, b); + assertOptimized(create0); + + function create1(arg) { + return Array(arg); + } + + create1(8); + create1(8); + a = create1(8); + a[0] = 3.5; %OptimizeFunctionOnNextCall(create1); - b = create1(8); - assertKind(elements_kind.fast_double, b); - assertOptimized(create1); - - function createN(arg1, arg2, arg3) { - return Array(arg1, arg2, arg3); - } - - createN(1, 2, 3); - createN(1, 2, 3); - a = createN(1, 2, 3); - a[0] = 3.5; + b = create1(8); + assertKind(elements_kind.fast_double, b); + assertOptimized(create1); + + function createN(arg1, arg2, arg3) { + return Array(arg1, arg2, arg3); + } + + createN(1, 2, 3); + createN(1, 2, 3); + a = createN(1, 2, 3); + a[0] = 3.5; %OptimizeFunctionOnNextCall(createN); - b = createN(1, 2, 3); - assertKind(elements_kind.fast_double, b); - assertOptimized(createN); - })(); - - // Verify that cross context calls work - (function (){ - var realmA = Realm.current(); - var realmB = Realm.create(); - assertEquals(0, realmA); - assertEquals(1, realmB); - - function instanceof_check(type) { - assertTrue(type() instanceof type); - assertTrue(type(5) instanceof type); - assertTrue(type(1,2,3) instanceof type); - } - - var realmBArray = Realm.eval(realmB, "Array"); - instanceof_check(Array); - instanceof_check(Array); - instanceof_check(Array); - instanceof_check(realmBArray); - instanceof_check(realmBArray); - instanceof_check(realmBArray); - })(); -} + b = createN(1, 2, 3); + assertKind(elements_kind.fast_double, b); + assertOptimized(createN); +})(); + +// Verify that cross context calls work +(function (){ + var realmA = Realm.current(); + var realmB = Realm.create(); + assertEquals(0, realmA); + assertEquals(1, realmB); + + function instanceof_check(type) { + assertTrue(type() instanceof type); + assertTrue(type(5) instanceof type); + assertTrue(type(1,2,3) instanceof type); + } + + var realmBArray = Realm.eval(realmB, "Array"); + instanceof_check(Array); + instanceof_check(Array); + instanceof_check(Array); + instanceof_check(realmBArray); + instanceof_check(realmBArray); + instanceof_check(realmBArray); +})(); diff --git a/test/mjsunit/array-literal-feedback.js b/test/mjsunit/array-literal-feedback.js index cfda0f6..ed9c4e8 100644 --- a/test/mjsunit/array-literal-feedback.js +++ b/test/mjsunit/array-literal-feedback.js @@ -25,25 +25,9 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --smi-only-arrays --expose-gc +// Flags: --allow-natives-syntax --expose-gc // Flags: --noalways-opt -// Test element kind of objects. -// Since --smi-only-arrays affects builtins, its default setting at compile -// time sticks if built with snapshot. If --smi-only-arrays is deactivated -// by default, only a no-snapshot build actually has smi-only arrays enabled -// in this test case. Depending on whether smi-only arrays are actually -// enabled, this test takes the appropriate code path to check smi-only arrays. - -// support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8)); -support_smi_only_arrays = true; - -if (support_smi_only_arrays) { - print("Tests include smi-only arrays."); -} else { - print("Tests do NOT include smi-only arrays."); -} - var elements_kind = { fast_smi_only : 'fast smi only elements', fast : 'fast elements', @@ -73,58 +57,51 @@ function isHoley(obj) { } function assertKind(expected, obj, name_opt) { - if (!support_smi_only_arrays && - expected == elements_kind.fast_smi_only) { - expected = elements_kind.fast; - } assertEquals(expected, getKind(obj), name_opt); } -if (support_smi_only_arrays) { - - function get_literal(x) { - var literal = [1, 2, x]; - return literal; - } +function get_literal(x) { + var literal = [1, 2, x]; + return literal; +} - get_literal(3); - // It's important to store a from before we crankshaft get_literal, because - // mementos won't be created from crankshafted code at all. - a = get_literal(3); +get_literal(3); +// It's important to store a from before we crankshaft get_literal, because +// mementos won't be created from crankshafted code at all. +a = get_literal(3); %OptimizeFunctionOnNextCall(get_literal); - get_literal(3); - assertOptimized(get_literal); - assertTrue(%HasFastSmiElements(a)); - // a has a memento so the transition caused by the store will affect the - // boilerplate. - a[0] = 3.5; - - // We should have transitioned the boilerplate array to double, and - // crankshafted code should de-opt on the unexpected elements kind - b = get_literal(3); - assertTrue(%HasFastDoubleElements(b)); - assertEquals([1, 2, 3], b); - assertUnoptimized(get_literal); - - // Optimize again - get_literal(3); +get_literal(3); +assertOptimized(get_literal); +assertTrue(%HasFastSmiElements(a)); +// a has a memento so the transition caused by the store will affect the +// boilerplate. +a[0] = 3.5; + +// We should have transitioned the boilerplate array to double, and +// crankshafted code should de-opt on the unexpected elements kind +b = get_literal(3); +assertTrue(%HasFastDoubleElements(b)); +assertEquals([1, 2, 3], b); +assertUnoptimized(get_literal); + +// Optimize again +get_literal(3); %OptimizeFunctionOnNextCall(get_literal); - b = get_literal(3); - assertTrue(%HasFastDoubleElements(b)); - assertOptimized(get_literal); +b = get_literal(3); +assertTrue(%HasFastDoubleElements(b)); +assertOptimized(get_literal); - // Test: make sure allocation site information is updated through a - // transition from SMI->DOUBLE->FAST - (function() { - function bar(a, b, c) { - return [a, b, c]; - } +// Test: make sure allocation site information is updated through a +// transition from SMI->DOUBLE->FAST +(function() { + function bar(a, b, c) { + return [a, b, c]; + } - a = bar(1, 2, 3); - a[0] = 3.5; - a[1] = 'hi'; - b = bar(1, 2, 3); - assertKind(elements_kind.fast, b); - })(); -} + a = bar(1, 2, 3); + a[0] = 3.5; + a[1] = 'hi'; + b = bar(1, 2, 3); + assertKind(elements_kind.fast, b); +})(); diff --git a/test/mjsunit/array-literal-transitions.js b/test/mjsunit/array-literal-transitions.js index ca6033b..e162455 100644 --- a/test/mjsunit/array-literal-transitions.js +++ b/test/mjsunit/array-literal-transitions.js @@ -25,22 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --smi-only-arrays --expose-gc - -// Test element kind of objects. -// Since --smi-only-arrays affects builtins, its default setting at compile -// time sticks if built with snapshot. If --smi-only-arrays is deactivated -// by default, only a no-snapshot build actually has smi-only arrays enabled -// in this test case. Depending on whether smi-only arrays are actually -// enabled, this test takes the appropriate code path to check smi-only arrays. - -support_smi_only_arrays = %HasFastSmiElements([1,2,3,4,5,6,7,8,9,10]); - -if (support_smi_only_arrays) { - print("Tests include smi-only arrays."); -} else { - print("Tests do NOT include smi-only arrays."); -} +// Flags: --allow-natives-syntax --expose-gc // IC and Crankshaft support for smi-only elements in dynamic array literals. function get(foo) { return foo; } // Used to generate dynamic values. @@ -94,114 +79,112 @@ function array_literal_test() { assertEquals(1, f0[0]); } -if (support_smi_only_arrays) { - for (var i = 0; i < 3; i++) { - array_literal_test(); - } - %OptimizeFunctionOnNextCall(array_literal_test); +for (var i = 0; i < 3; i++) { array_literal_test(); +} + %OptimizeFunctionOnNextCall(array_literal_test); +array_literal_test(); + +function test_large_literal() { - function test_large_literal() { - - function d() { - gc(); - return 2.5; - } - - function o() { - gc(); - return new Object(); - } - - large = - [ 0, 1, 2, 3, 4, 5, d(), d(), d(), d(), d(), d(), o(), o(), o(), o() ]; - assertFalse(%HasDictionaryElements(large)); - assertFalse(%HasFastSmiElements(large)); - assertFalse(%HasFastDoubleElements(large)); - assertTrue(%HasFastObjectElements(large)); - assertEquals(large, - [0, 1, 2, 3, 4, 5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, - new Object(), new Object(), new Object(), new Object()]); + function d() { + gc(); + return 2.5; } - for (var i = 0; i < 3; i++) { - test_large_literal(); + function o() { + gc(); + return new Object(); } - %OptimizeFunctionOnNextCall(test_large_literal); + + large = + [ 0, 1, 2, 3, 4, 5, d(), d(), d(), d(), d(), d(), o(), o(), o(), o() ]; + assertFalse(%HasDictionaryElements(large)); + assertFalse(%HasFastSmiElements(large)); + assertFalse(%HasFastDoubleElements(large)); + assertTrue(%HasFastObjectElements(large)); + assertEquals(large, + [0, 1, 2, 3, 4, 5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, + new Object(), new Object(), new Object(), new Object()]); +} + +for (var i = 0; i < 3; i++) { test_large_literal(); +} + %OptimizeFunctionOnNextCall(test_large_literal); +test_large_literal(); - function deopt_array(use_literal) { - if (use_literal) { - return [.5, 3, 4]; - } else { - return new Array(); - } +function deopt_array(use_literal) { + if (use_literal) { + return [.5, 3, 4]; + } else { + return new Array(); } +} - deopt_array(false); - deopt_array(false); - deopt_array(false); +deopt_array(false); +deopt_array(false); +deopt_array(false); %OptimizeFunctionOnNextCall(deopt_array); - var array = deopt_array(false); - assertOptimized(deopt_array); - deopt_array(true); - assertOptimized(deopt_array); - array = deopt_array(false); - assertOptimized(deopt_array); - - // Check that unexpected changes in the objects stored into the boilerplate - // also force a deopt. - function deopt_array_literal_all_smis(a) { - return [0, 1, a]; - } +var array = deopt_array(false); +assertOptimized(deopt_array); +deopt_array(true); +assertOptimized(deopt_array); +array = deopt_array(false); +assertOptimized(deopt_array); + +// Check that unexpected changes in the objects stored into the boilerplate +// also force a deopt. +function deopt_array_literal_all_smis(a) { + return [0, 1, a]; +} - deopt_array_literal_all_smis(2); - deopt_array_literal_all_smis(3); - deopt_array_literal_all_smis(4); - array = deopt_array_literal_all_smis(4); - assertEquals(0, array[0]); - assertEquals(1, array[1]); - assertEquals(4, array[2]); +deopt_array_literal_all_smis(2); +deopt_array_literal_all_smis(3); +deopt_array_literal_all_smis(4); +array = deopt_array_literal_all_smis(4); +assertEquals(0, array[0]); +assertEquals(1, array[1]); +assertEquals(4, array[2]); %OptimizeFunctionOnNextCall(deopt_array_literal_all_smis); - array = deopt_array_literal_all_smis(5); - array = deopt_array_literal_all_smis(6); - assertOptimized(deopt_array_literal_all_smis); - assertEquals(0, array[0]); - assertEquals(1, array[1]); - assertEquals(6, array[2]); - - array = deopt_array_literal_all_smis(.5); - assertUnoptimized(deopt_array_literal_all_smis); - assertEquals(0, array[0]); - assertEquals(1, array[1]); - assertEquals(.5, array[2]); - - function deopt_array_literal_all_doubles(a) { - return [0.5, 1, a]; - } +array = deopt_array_literal_all_smis(5); +array = deopt_array_literal_all_smis(6); +assertOptimized(deopt_array_literal_all_smis); +assertEquals(0, array[0]); +assertEquals(1, array[1]); +assertEquals(6, array[2]); + +array = deopt_array_literal_all_smis(.5); +assertUnoptimized(deopt_array_literal_all_smis); +assertEquals(0, array[0]); +assertEquals(1, array[1]); +assertEquals(.5, array[2]); + +function deopt_array_literal_all_doubles(a) { + return [0.5, 1, a]; +} - deopt_array_literal_all_doubles(.5); - deopt_array_literal_all_doubles(.5); - deopt_array_literal_all_doubles(.5); - array = deopt_array_literal_all_doubles(0.5); - assertEquals(0.5, array[0]); - assertEquals(1, array[1]); - assertEquals(0.5, array[2]); +deopt_array_literal_all_doubles(.5); +deopt_array_literal_all_doubles(.5); +deopt_array_literal_all_doubles(.5); +array = deopt_array_literal_all_doubles(0.5); +assertEquals(0.5, array[0]); +assertEquals(1, array[1]); +assertEquals(0.5, array[2]); %OptimizeFunctionOnNextCall(deopt_array_literal_all_doubles); - array = deopt_array_literal_all_doubles(5); - array = deopt_array_literal_all_doubles(6); - assertOptimized(deopt_array_literal_all_doubles); - assertEquals(0.5, array[0]); - assertEquals(1, array[1]); - assertEquals(6, array[2]); - - var foo = new Object(); - array = deopt_array_literal_all_doubles(foo); - assertUnoptimized(deopt_array_literal_all_doubles); - assertEquals(0.5, array[0]); - assertEquals(1, array[1]); - assertEquals(foo, array[2]); -} +array = deopt_array_literal_all_doubles(5); +array = deopt_array_literal_all_doubles(6); +assertOptimized(deopt_array_literal_all_doubles); +assertEquals(0.5, array[0]); +assertEquals(1, array[1]); +assertEquals(6, array[2]); + +var foo = new Object(); +array = deopt_array_literal_all_doubles(foo); +assertUnoptimized(deopt_array_literal_all_doubles); +assertEquals(0.5, array[0]); +assertEquals(1, array[1]); +assertEquals(foo, array[2]); (function literals_after_osr() { var color = [0]; diff --git a/test/mjsunit/array-natives-elements.js b/test/mjsunit/array-natives-elements.js index f64818d..d63346d 100644 --- a/test/mjsunit/array-natives-elements.js +++ b/test/mjsunit/array-natives-elements.js @@ -25,22 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --smi-only-arrays - -// Test element kind of objects. -// Since --smi-only-arrays affects builtins, its default setting at compile time -// sticks if built with snapshot. If --smi-only-arrays is deactivated by -// default, only a no-snapshot build actually has smi-only arrays enabled in -// this test case. Depending on whether smi-only arrays are actually enabled, -// this test takes the appropriate code path to check smi-only arrays. - -support_smi_only_arrays = %HasFastSmiElements([1,2,3,4,5,6,7,8,9,10]); - -if (support_smi_only_arrays) { - print("Tests include smi-only arrays."); -} else { - print("Tests do NOT include smi-only arrays."); -} +// Flags: --allow-natives-syntax // IC and Crankshaft support for smi-only elements in dynamic array literals. function get(foo) { return foo; } // Used to generate dynamic values. @@ -308,10 +293,8 @@ function array_natives_test() { assertEquals([1.1,{},2,3], a4); } -if (support_smi_only_arrays) { - for (var i = 0; i < 3; i++) { - array_natives_test(); - } - %OptimizeFunctionOnNextCall(array_natives_test); +for (var i = 0; i < 3; i++) { array_natives_test(); } +%OptimizeFunctionOnNextCall(array_natives_test); +array_natives_test(); diff --git a/test/mjsunit/elements-kind-depends.js b/test/mjsunit/elements-kind-depends.js index 82f188b7..539fbd0 100644 --- a/test/mjsunit/elements-kind-depends.js +++ b/test/mjsunit/elements-kind-depends.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --smi-only-arrays +// Flags: --allow-natives-syntax function burn() { var a = new Array(3); diff --git a/test/mjsunit/elements-kind.js b/test/mjsunit/elements-kind.js index 3aa513a..e7a597d 100644 --- a/test/mjsunit/elements-kind.js +++ b/test/mjsunit/elements-kind.js @@ -25,22 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --smi-only-arrays --expose-gc --nostress-opt --typed-array-max_size_in-heap=2048 - -// Test element kind of objects. -// Since --smi-only-arrays affects builtins, its default setting at compile -// time sticks if built with snapshot. If --smi-only-arrays is deactivated -// by default, only a no-snapshot build actually has smi-only arrays enabled -// in this test case. Depending on whether smi-only arrays are actually -// enabled, this test takes the appropriate code path to check smi-only arrays. - -support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8)); - -if (support_smi_only_arrays) { - print("Tests include smi-only arrays."); -} else { - print("Tests do NOT include smi-only arrays."); -} +// Flags: --allow-natives-syntax --expose-gc --nostress-opt --typed-array-max_size_in-heap=2048 var elements_kind = { fast_smi_only : 'fast smi only elements', @@ -131,10 +116,6 @@ function getKind(obj) { } function assertKind(expected, obj, name_opt) { - if (!support_smi_only_arrays && - expected == elements_kind.fast_smi_only) { - expected = elements_kind.fast; - } assertEquals(expected, getKind(obj), name_opt); } @@ -144,13 +125,11 @@ me.dance = 0xD15C0; me.drink = 0xC0C0A; assertKind(elements_kind.fast, me); -if (support_smi_only_arrays) { - var too = [1,2,3]; - assertKind(elements_kind.fast_smi_only, too); - too.dance = 0xD15C0; - too.drink = 0xC0C0A; - assertKind(elements_kind.fast_smi_only, too); -} +var too = [1,2,3]; +assertKind(elements_kind.fast_smi_only, too); +too.dance = 0xD15C0; +too.drink = 0xC0C0A; +assertKind(elements_kind.fast_smi_only, too); // Make sure the element kind transitions from smi when a non-smi is stored. function test_wrapper() { @@ -217,111 +196,106 @@ function test_wrapper() { test_wrapper(); %ClearFunctionTypeFeedback(test_wrapper); -if (support_smi_only_arrays) { - %NeverOptimizeFunction(construct_smis); +%NeverOptimizeFunction(construct_smis); - // This code exists to eliminate the learning influence of AllocationSites - // on the following tests. - var __sequence = 0; - function make_array_string() { - this.__sequence = this.__sequence + 1; - return "/* " + this.__sequence + " */ [0, 0, 0];" - } - function make_array() { - return eval(make_array_string()); - } +// This code exists to eliminate the learning influence of AllocationSites +// on the following tests. +var __sequence = 0; +function make_array_string() { + this.__sequence = this.__sequence + 1; + return "/* " + this.__sequence + " */ [0, 0, 0];" +} +function make_array() { + return eval(make_array_string()); +} - function construct_smis() { - var a = make_array(); - a[0] = 0; // Send the COW array map to the steak house. - assertKind(elements_kind.fast_smi_only, a); - return a; - } +function construct_smis() { + var a = make_array(); + a[0] = 0; // Send the COW array map to the steak house. + assertKind(elements_kind.fast_smi_only, a); + return a; +} %NeverOptimizeFunction(construct_doubles); - function construct_doubles() { - var a = construct_smis(); - a[0] = 1.5; - assertKind(elements_kind.fast_double, a); - return a; - } +function construct_doubles() { + var a = construct_smis(); + a[0] = 1.5; + assertKind(elements_kind.fast_double, a); + return a; +} %NeverOptimizeFunction(construct_objects); - function construct_objects() { - var a = construct_smis(); - a[0] = "one"; - assertKind(elements_kind.fast, a); - return a; - } +function construct_objects() { + var a = construct_smis(); + a[0] = "one"; + assertKind(elements_kind.fast, a); + return a; +} - // Test crankshafted transition SMI->DOUBLE. +// Test crankshafted transition SMI->DOUBLE. %NeverOptimizeFunction(convert_to_double); - function convert_to_double(array) { - array[1] = 2.5; - assertKind(elements_kind.fast_double, array); - assertEquals(2.5, array[1]); - } - var smis = construct_smis(); - for (var i = 0; i < 3; i++) convert_to_double(smis); +function convert_to_double(array) { + array[1] = 2.5; + assertKind(elements_kind.fast_double, array); + assertEquals(2.5, array[1]); +} +var smis = construct_smis(); +for (var i = 0; i < 3; i++) convert_to_double(smis); %OptimizeFunctionOnNextCall(convert_to_double); - smis = construct_smis(); - convert_to_double(smis); - // Test crankshafted transitions SMI->FAST and DOUBLE->FAST. +smis = construct_smis(); +convert_to_double(smis); +// Test crankshafted transitions SMI->FAST and DOUBLE->FAST. %NeverOptimizeFunction(convert_to_fast); - function convert_to_fast(array) { - array[1] = "two"; - assertKind(elements_kind.fast, array); - assertEquals("two", array[1]); - } - smis = construct_smis(); - for (var i = 0; i < 3; i++) convert_to_fast(smis); - var doubles = construct_doubles(); - for (var i = 0; i < 3; i++) convert_to_fast(doubles); - smis = construct_smis(); - doubles = construct_doubles(); +function convert_to_fast(array) { + array[1] = "two"; + assertKind(elements_kind.fast, array); + assertEquals("two", array[1]); +} +smis = construct_smis(); +for (var i = 0; i < 3; i++) convert_to_fast(smis); +var doubles = construct_doubles(); +for (var i = 0; i < 3; i++) convert_to_fast(doubles); +smis = construct_smis(); +doubles = construct_doubles(); %OptimizeFunctionOnNextCall(convert_to_fast); - convert_to_fast(smis); - convert_to_fast(doubles); - // Test transition chain SMI->DOUBLE->FAST (crankshafted function will - // transition to FAST directly). +convert_to_fast(smis); +convert_to_fast(doubles); +// Test transition chain SMI->DOUBLE->FAST (crankshafted function will +// transition to FAST directly). %NeverOptimizeFunction(convert_mixed); - function convert_mixed(array, value, kind) { - array[1] = value; - assertKind(kind, array); - assertEquals(value, array[1]); - } - smis = construct_smis(); - for (var i = 0; i < 3; i++) { - convert_mixed(smis, 1.5, elements_kind.fast_double); - } - doubles = construct_doubles(); - for (var i = 0; i < 3; i++) { - convert_mixed(doubles, "three", elements_kind.fast); - } - convert_mixed(construct_smis(), "three", elements_kind.fast); - convert_mixed(construct_doubles(), "three", elements_kind.fast); - %OptimizeFunctionOnNextCall(convert_mixed); - smis = construct_smis(); - doubles = construct_doubles(); - convert_mixed(smis, 1, elements_kind.fast); - convert_mixed(doubles, 1, elements_kind.fast); - assertTrue(%HaveSameMap(smis, doubles)); +function convert_mixed(array, value, kind) { + array[1] = value; + assertKind(kind, array); + assertEquals(value, array[1]); +} +smis = construct_smis(); +for (var i = 0; i < 3; i++) { + convert_mixed(smis, 1.5, elements_kind.fast_double); } +doubles = construct_doubles(); +for (var i = 0; i < 3; i++) { + convert_mixed(doubles, "three", elements_kind.fast); +} +convert_mixed(construct_smis(), "three", elements_kind.fast); +convert_mixed(construct_doubles(), "three", elements_kind.fast); + %OptimizeFunctionOnNextCall(convert_mixed); +smis = construct_smis(); +doubles = construct_doubles(); +convert_mixed(smis, 1, elements_kind.fast); +convert_mixed(doubles, 1, elements_kind.fast); +assertTrue(%HaveSameMap(smis, doubles)); // Crankshaft support for smi-only elements in dynamic array literals. function get(foo) { return foo; } // Used to generate dynamic values. function crankshaft_test() { - if (support_smi_only_arrays) { - var a1 = [get(1), get(2), get(3)]; - assertKind(elements_kind.fast_smi_only, a1); - } + var a1 = [get(1), get(2), get(3)]; + assertKind(elements_kind.fast_smi_only, a1); + var a2 = new Array(get(1), get(2), get(3)); assertKind(elements_kind.fast_smi_only, a2); var b = [get(1), get(2), get("three")]; assertKind(elements_kind.fast, b); var c = [get(1), get(2), get(3.5)]; - if (support_smi_only_arrays) { - assertKind(elements_kind.fast_double, c); - } + assertKind(elements_kind.fast_double, c); } for (var i = 0; i < 3; i++) { crankshaft_test(); @@ -335,85 +309,76 @@ crankshaft_test(); // DOUBLE->OBJECT, and SMI->OBJECT. No matter in which order these three are // created, they must always end up with the same FAST map. -// This test is meaningless without FAST_SMI_ONLY_ELEMENTS. -if (support_smi_only_arrays) { - // Preparation: create one pair of identical objects for each case. - var a = [1, 2, 3]; - var b = [1, 2, 3]; - assertTrue(%HaveSameMap(a, b)); - assertKind(elements_kind.fast_smi_only, a); - var c = [1, 2, 3]; - c["case2"] = true; - var d = [1, 2, 3]; - d["case2"] = true; - assertTrue(%HaveSameMap(c, d)); - assertFalse(%HaveSameMap(a, c)); - assertKind(elements_kind.fast_smi_only, c); - var e = [1, 2, 3]; - e["case3"] = true; - var f = [1, 2, 3]; - f["case3"] = true; - assertTrue(%HaveSameMap(e, f)); - assertFalse(%HaveSameMap(a, e)); - assertFalse(%HaveSameMap(c, e)); - assertKind(elements_kind.fast_smi_only, e); - // Case 1: SMI->DOUBLE, DOUBLE->OBJECT, SMI->OBJECT. - a[0] = 1.5; - assertKind(elements_kind.fast_double, a); - a[0] = "foo"; - assertKind(elements_kind.fast, a); - b[0] = "bar"; - assertTrue(%HaveSameMap(a, b)); - // Case 2: SMI->DOUBLE, SMI->OBJECT, DOUBLE->OBJECT. - c[0] = 1.5; - assertKind(elements_kind.fast_double, c); - assertFalse(%HaveSameMap(c, d)); - d[0] = "foo"; - assertKind(elements_kind.fast, d); - assertFalse(%HaveSameMap(c, d)); - c[0] = "bar"; - assertTrue(%HaveSameMap(c, d)); - // Case 3: SMI->OBJECT, SMI->DOUBLE, DOUBLE->OBJECT. - e[0] = "foo"; - assertKind(elements_kind.fast, e); - assertFalse(%HaveSameMap(e, f)); - f[0] = 1.5; - assertKind(elements_kind.fast_double, f); - assertFalse(%HaveSameMap(e, f)); - f[0] = "bar"; - assertKind(elements_kind.fast, f); - assertTrue(%HaveSameMap(e, f)); -} +// Preparation: create one pair of identical objects for each case. +var a = [1, 2, 3]; +var b = [1, 2, 3]; +assertTrue(%HaveSameMap(a, b)); +assertKind(elements_kind.fast_smi_only, a); +var c = [1, 2, 3]; +c["case2"] = true; +var d = [1, 2, 3]; +d["case2"] = true; +assertTrue(%HaveSameMap(c, d)); +assertFalse(%HaveSameMap(a, c)); +assertKind(elements_kind.fast_smi_only, c); +var e = [1, 2, 3]; +e["case3"] = true; +var f = [1, 2, 3]; +f["case3"] = true; +assertTrue(%HaveSameMap(e, f)); +assertFalse(%HaveSameMap(a, e)); +assertFalse(%HaveSameMap(c, e)); +assertKind(elements_kind.fast_smi_only, e); +// Case 1: SMI->DOUBLE, DOUBLE->OBJECT, SMI->OBJECT. +a[0] = 1.5; +assertKind(elements_kind.fast_double, a); +a[0] = "foo"; +assertKind(elements_kind.fast, a); +b[0] = "bar"; +assertTrue(%HaveSameMap(a, b)); +// Case 2: SMI->DOUBLE, SMI->OBJECT, DOUBLE->OBJECT. +c[0] = 1.5; +assertKind(elements_kind.fast_double, c); +assertFalse(%HaveSameMap(c, d)); +d[0] = "foo"; +assertKind(elements_kind.fast, d); +assertFalse(%HaveSameMap(c, d)); +c[0] = "bar"; +assertTrue(%HaveSameMap(c, d)); +// Case 3: SMI->OBJECT, SMI->DOUBLE, DOUBLE->OBJECT. +e[0] = "foo"; +assertKind(elements_kind.fast, e); +assertFalse(%HaveSameMap(e, f)); +f[0] = 1.5; +assertKind(elements_kind.fast_double, f); +assertFalse(%HaveSameMap(e, f)); +f[0] = "bar"; +assertKind(elements_kind.fast, f); +assertTrue(%HaveSameMap(e, f)); // Test if Array.concat() works correctly with DOUBLE elements. -if (support_smi_only_arrays) { - var a = [1, 2]; - assertKind(elements_kind.fast_smi_only, a); - var b = [4.5, 5.5]; - assertKind(elements_kind.fast_double, b); - var c = a.concat(b); - assertEquals([1, 2, 4.5, 5.5], c); - assertKind(elements_kind.fast_double, c); -} +var a = [1, 2]; +assertKind(elements_kind.fast_smi_only, a); +var b = [4.5, 5.5]; +assertKind(elements_kind.fast_double, b); +var c = a.concat(b); +assertEquals([1, 2, 4.5, 5.5], c); +assertKind(elements_kind.fast_double, c); // Test that Array.push() correctly handles SMI elements. -if (support_smi_only_arrays) { - var a = [1, 2]; - assertKind(elements_kind.fast_smi_only, a); - a.push(3, 4, 5); - assertKind(elements_kind.fast_smi_only, a); - assertEquals([1, 2, 3, 4, 5], a); -} +var a = [1, 2]; +assertKind(elements_kind.fast_smi_only, a); +a.push(3, 4, 5); +assertKind(elements_kind.fast_smi_only, a); +assertEquals([1, 2, 3, 4, 5], a); // Test that Array.splice() and Array.slice() return correct ElementsKinds. -if (support_smi_only_arrays) { - var a = ["foo", "bar"]; - assertKind(elements_kind.fast, a); - var b = a.splice(0, 1); - assertKind(elements_kind.fast, b); - var c = a.slice(0, 1); - assertKind(elements_kind.fast, c); -} +var a = ["foo", "bar"]; +assertKind(elements_kind.fast, a); +var b = a.splice(0, 1); +assertKind(elements_kind.fast, b); +var c = a.slice(0, 1); +assertKind(elements_kind.fast, c); // Throw away type information in the ICs for next stress run. gc(); diff --git a/test/mjsunit/elements-transition-hoisting.js b/test/mjsunit/elements-transition-hoisting.js index 76027b9..9f229d2 100644 --- a/test/mjsunit/elements-transition-hoisting.js +++ b/test/mjsunit/elements-transition-hoisting.js @@ -25,21 +25,13 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --smi-only-arrays +// Flags: --allow-natives-syntax // Flags: --nostress-opt // Ensure that ElementsKind transitions in various situations are hoisted (or // not hoisted) correctly, don't change the semantics programs and don't trigger // deopt through hoisting in important situations. -support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6)); - -if (support_smi_only_arrays) { - print("Tests include smi-only arrays."); -} else { - print("Tests do NOT include smi-only arrays."); -} - function test_wrapper() { // Make sure that a simple elements array transitions inside a loop before // stores to an array gets hoisted in a way that doesn't generate a deopt in @@ -238,9 +230,7 @@ function test_wrapper() { %ClearFunctionTypeFeedback(testStraightLineDupeElinination); } -if (support_smi_only_arrays) { - // The test is called in a test wrapper that has type feedback cleared to - // prevent the influence of allocation-sites, which learn from transitions. - test_wrapper(); - %ClearFunctionTypeFeedback(test_wrapper); -} +// The test is called in a test wrapper that has type feedback cleared to +// prevent the influence of allocation-sites, which learn from transitions. +test_wrapper(); +%ClearFunctionTypeFeedback(test_wrapper); diff --git a/test/mjsunit/elements-transition.js b/test/mjsunit/elements-transition.js index 7298e68..f6a8188 100644 --- a/test/mjsunit/elements-transition.js +++ b/test/mjsunit/elements-transition.js @@ -25,107 +25,95 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --smi-only-arrays +// Flags: --allow-natives-syntax // Flags: --nostress-opt -support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8)); - -if (support_smi_only_arrays) { - print("Tests include smi-only arrays."); -} else { - print("Tests do NOT include smi-only arrays."); +// This code exists to eliminate the learning influence of AllocationSites +// on the following tests. +var __sequence = 0; +function make_array_string(length) { + this.__sequence = this.__sequence + 1; + return "/* " + this.__sequence + " */ new Array(" + length + ");"; +} +function make_array(length) { + return eval(make_array_string(length)); } -if (support_smi_only_arrays) { - // This code exists to eliminate the learning influence of AllocationSites - // on the following tests. - var __sequence = 0; - function make_array_string(length) { - this.__sequence = this.__sequence + 1; - return "/* " + this.__sequence + " */ new Array(" + length + ");"; - } - function make_array(length) { - return eval(make_array_string(length)); - } - - function test(test_double, test_object, set, length) { - // We apply the same operations to two identical arrays. The first array - // triggers an IC miss, upon which the conversion stub is generated, but the - // actual conversion is done in runtime. The second array, arriving at - // the previously patched IC, is then converted using the conversion stub. - var array_1 = make_array(length); - var array_2 = make_array(length); +function test(test_double, test_object, set, length) { + // We apply the same operations to two identical arrays. The first array + // triggers an IC miss, upon which the conversion stub is generated, but the + // actual conversion is done in runtime. The second array, arriving at + // the previously patched IC, is then converted using the conversion stub. + var array_1 = make_array(length); + var array_2 = make_array(length); - // false, true, nice setter function, 20 - assertTrue(%HasFastSmiElements(array_1)); - assertTrue(%HasFastSmiElements(array_2)); - for (var i = 0; i < length; i++) { - if (i == length - 5 && test_double) { - // Trigger conversion to fast double elements at length-5. - set(array_1, i, 0.5); - set(array_2, i, 0.5); - assertTrue(%HasFastDoubleElements(array_1)); - assertTrue(%HasFastDoubleElements(array_2)); - } else if (i == length - 3 && test_object) { - // Trigger conversion to fast object elements at length-3. - set(array_1, i, 'object'); - set(array_2, i, 'object'); - assertTrue(%HasFastObjectElements(array_1)); - assertTrue(%HasFastObjectElements(array_2)); - } else if (i != length - 7) { - // Set the element to an integer but leave a hole at length-7. - set(array_1, i, 2*i+1); - set(array_2, i, 2*i+1); - } + // false, true, nice setter function, 20 + assertTrue(%HasFastSmiElements(array_1)); + assertTrue(%HasFastSmiElements(array_2)); + for (var i = 0; i < length; i++) { + if (i == length - 5 && test_double) { + // Trigger conversion to fast double elements at length-5. + set(array_1, i, 0.5); + set(array_2, i, 0.5); + assertTrue(%HasFastDoubleElements(array_1)); + assertTrue(%HasFastDoubleElements(array_2)); + } else if (i == length - 3 && test_object) { + // Trigger conversion to fast object elements at length-3. + set(array_1, i, 'object'); + set(array_2, i, 'object'); + assertTrue(%HasFastObjectElements(array_1)); + assertTrue(%HasFastObjectElements(array_2)); + } else if (i != length - 7) { + // Set the element to an integer but leave a hole at length-7. + set(array_1, i, 2*i+1); + set(array_2, i, 2*i+1); } + } - for (var i = 0; i < length; i++) { - if (i == length - 5 && test_double) { - assertEquals(0.5, array_1[i]); - assertEquals(0.5, array_2[i]); - } else if (i == length - 3 && test_object) { - assertEquals('object', array_1[i]); - assertEquals('object', array_2[i]); - } else if (i != length - 7) { - assertEquals(2*i+1, array_1[i]); - assertEquals(2*i+1, array_2[i]); - } else { - assertEquals(undefined, array_1[i]); - assertEquals(undefined, array_2[i]); - } + for (var i = 0; i < length; i++) { + if (i == length - 5 && test_double) { + assertEquals(0.5, array_1[i]); + assertEquals(0.5, array_2[i]); + } else if (i == length - 3 && test_object) { + assertEquals('object', array_1[i]); + assertEquals('object', array_2[i]); + } else if (i != length - 7) { + assertEquals(2*i+1, array_1[i]); + assertEquals(2*i+1, array_2[i]); + } else { + assertEquals(undefined, array_1[i]); + assertEquals(undefined, array_2[i]); } - - assertEquals(length, array_1.length); - assertEquals(length, array_2.length); } - function run_test(test_double, test_object, set, length) { - test(test_double, test_object, set, length); + assertEquals(length, array_1.length); + assertEquals(length, array_2.length); +} + +function run_test(test_double, test_object, set, length) { + test(test_double, test_object, set, length); %ClearFunctionTypeFeedback(test); - } +} - run_test(false, false, function(a,i,v){ a[i] = v; }, 20); - run_test(true, false, function(a,i,v){ a[i] = v; }, 20); - run_test(false, true, function(a,i,v){ a[i] = v; }, 20); - run_test(true, true, function(a,i,v){ a[i] = v; }, 20); +run_test(false, false, function(a,i,v){ a[i] = v; }, 20); +run_test(true, false, function(a,i,v){ a[i] = v; }, 20); +run_test(false, true, function(a,i,v){ a[i] = v; }, 20); +run_test(true, true, function(a,i,v){ a[i] = v; }, 20); - run_test(false, false, function(a,i,v){ a[i] = v; }, 10000); - run_test(true, false, function(a,i,v){ a[i] = v; }, 10000); - run_test(false, true, function(a,i,v){ a[i] = v; }, 10000); - run_test(true, true, function(a,i,v){ a[i] = v; }, 10000); +run_test(false, false, function(a,i,v){ a[i] = v; }, 10000); +run_test(true, false, function(a,i,v){ a[i] = v; }, 10000); +run_test(false, true, function(a,i,v){ a[i] = v; }, 10000); +run_test(true, true, function(a,i,v){ a[i] = v; }, 10000); - // Check COW arrays - function get_cow() { return [1, 2, 3]; } +// Check COW arrays +function get_cow() { return [1, 2, 3]; } - function transition(x) { x[0] = 1.5; } +function transition(x) { x[0] = 1.5; } - var ignore = get_cow(); - transition(ignore); // Handled by runtime. - var a = get_cow(); - var b = get_cow(); - transition(a); // Handled by IC. - assertEquals(1.5, a[0]); - assertEquals(1, b[0]); -} else { - print("Test skipped because smi only arrays are not supported."); -} +var ignore = get_cow(); +transition(ignore); // Handled by runtime. +var a = get_cow(); +var b = get_cow(); +transition(a); // Handled by IC. +assertEquals(1.5, a[0]); +assertEquals(1, b[0]); diff --git a/test/mjsunit/opt-elements-kind.js b/test/mjsunit/opt-elements-kind.js index f26bb42..be7303b 100644 --- a/test/mjsunit/opt-elements-kind.js +++ b/test/mjsunit/opt-elements-kind.js @@ -25,28 +25,13 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --smi-only-arrays --expose-gc +// Flags: --allow-natives-syntax --expose-gc // Limit the number of stress runs to reduce polymorphism it defeats some of the // assumptions made about how elements transitions work because transition stubs // end up going generic. // Flags: --stress-runs=2 -// Test element kind of objects. -// Since --smi-only-arrays affects builtins, its default setting at compile -// time sticks if built with snapshot. If --smi-only-arrays is deactivated -// by default, only a no-snapshot build actually has smi-only arrays enabled -// in this test case. Depending on whether smi-only arrays are actually -// enabled, this test takes the appropriate code path to check smi-only arrays. - -support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8)); - -if (support_smi_only_arrays) { - print("Tests include smi-only arrays."); -} else { - print("Tests do NOT include smi-only arrays."); -} - var elements_kind = { fast_smi_only : 'fast smi only elements', fast : 'fast elements', @@ -100,10 +85,6 @@ function getKind(obj) { } function assertKind(expected, obj, name_opt) { - if (!support_smi_only_arrays && - expected == elements_kind.fast_smi_only) { - expected = elements_kind.fast; - } assertEquals(expected, getKind(obj), name_opt); } @@ -143,8 +124,6 @@ function convert_mixed(array, value, kind) { } function test1() { - if (!support_smi_only_arrays) return; - // Test transition chain SMI->DOUBLE->FAST (crankshafted function will // transition to FAST directly). var smis = construct_smis(); diff --git a/test/mjsunit/osr-elements-kind.js b/test/mjsunit/osr-elements-kind.js index 2ad3c43..518b984 100644 --- a/test/mjsunit/osr-elements-kind.js +++ b/test/mjsunit/osr-elements-kind.js @@ -25,28 +25,13 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --smi-only-arrays --expose-gc +// Flags: --allow-natives-syntax --expose-gc // Limit the number of stress runs to reduce polymorphism it defeats some of the // assumptions made about how elements transitions work because transition stubs // end up going generic. // Flags: --stress-runs=2 -// Test element kind of objects. -// Since --smi-only-arrays affects builtins, its default setting at compile -// time sticks if built with snapshot. If --smi-only-arrays is deactivated -// by default, only a no-snapshot build actually has smi-only arrays enabled -// in this test case. Depending on whether smi-only arrays are actually -// enabled, this test takes the appropriate code path to check smi-only arrays. - -support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8)); - -if (support_smi_only_arrays) { - print("Tests include smi-only arrays."); -} else { - print("Tests do NOT include smi-only arrays."); -} - var elements_kind = { fast_smi_only : 'fast smi only elements', fast : 'fast elements', @@ -100,10 +85,6 @@ function getKind(obj) { } function assertKind(expected, obj, name_opt) { - if (!support_smi_only_arrays && - expected == elements_kind.fast_smi_only) { - expected = elements_kind.fast; - } assertEquals(expected, getKind(obj), name_opt); } @@ -113,53 +94,51 @@ function assertKind(expected, obj, name_opt) { %NeverOptimizeFunction(convert_mixed); for (var i = 0; i < 1000000; i++) { } -if (support_smi_only_arrays) { - // This code exists to eliminate the learning influence of AllocationSites - // on the following tests. - var __sequence = 0; - function make_array_string() { - this.__sequence = this.__sequence + 1; - return "/* " + this.__sequence + " */ [0, 0, 0];" - } - function make_array() { - return eval(make_array_string()); - } +// This code exists to eliminate the learning influence of AllocationSites +// on the following tests. +var __sequence = 0; +function make_array_string() { + this.__sequence = this.__sequence + 1; + return "/* " + this.__sequence + " */ [0, 0, 0];" +} +function make_array() { + return eval(make_array_string()); +} - function construct_smis() { - var a = make_array(); - a[0] = 0; // Send the COW array map to the steak house. - assertKind(elements_kind.fast_smi_only, a); - return a; - } - function construct_doubles() { - var a = construct_smis(); - a[0] = 1.5; - assertKind(elements_kind.fast_double, a); - return a; - } +function construct_smis() { + var a = make_array(); + a[0] = 0; // Send the COW array map to the steak house. + assertKind(elements_kind.fast_smi_only, a); + return a; +} +function construct_doubles() { + var a = construct_smis(); + a[0] = 1.5; + assertKind(elements_kind.fast_double, a); + return a; +} - // Test transition chain SMI->DOUBLE->FAST (crankshafted function will - // transition to FAST directly). - function convert_mixed(array, value, kind) { - array[1] = value; - assertKind(kind, array); - assertEquals(value, array[1]); - } - smis = construct_smis(); - convert_mixed(smis, 1.5, elements_kind.fast_double); +// Test transition chain SMI->DOUBLE->FAST (crankshafted function will +// transition to FAST directly). +function convert_mixed(array, value, kind) { + array[1] = value; + assertKind(kind, array); + assertEquals(value, array[1]); +} +smis = construct_smis(); +convert_mixed(smis, 1.5, elements_kind.fast_double); - doubles = construct_doubles(); - convert_mixed(doubles, "three", elements_kind.fast); +doubles = construct_doubles(); +convert_mixed(doubles, "three", elements_kind.fast); - convert_mixed(construct_smis(), "three", elements_kind.fast); - convert_mixed(construct_doubles(), "three", elements_kind.fast); +convert_mixed(construct_smis(), "three", elements_kind.fast); +convert_mixed(construct_doubles(), "three", elements_kind.fast); - smis = construct_smis(); - doubles = construct_doubles(); - convert_mixed(smis, 1, elements_kind.fast); - convert_mixed(doubles, 1, elements_kind.fast); - assertTrue(%HaveSameMap(smis, doubles)); -} +smis = construct_smis(); +doubles = construct_doubles(); +convert_mixed(smis, 1, elements_kind.fast); +convert_mixed(doubles, 1, elements_kind.fast); +assertTrue(%HaveSameMap(smis, doubles)); // Throw away type information in the ICs for next stress run. gc(); diff --git a/test/mjsunit/packed-elements.js b/test/mjsunit/packed-elements.js index 4a87373..3ce92d1 100644 --- a/test/mjsunit/packed-elements.js +++ b/test/mjsunit/packed-elements.js @@ -25,9 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --smi-only-arrays --packed-arrays - -var has_packed_elements = !%HasFastHoleyElements(Array()); +// Flags: --allow-natives-syntax function test1() { var a = Array(8); @@ -101,11 +99,9 @@ function test_with_optimization(f) { for (i = 0; i < 25000; ++i) f(); // Make sure GC happens } -if (has_packed_elements) { - test_with_optimization(test1); - test_with_optimization(test2); - test_with_optimization(test3); - test_with_optimization(test4); - test_with_optimization(test5); - test_with_optimization(test6); -} +test_with_optimization(test1); +test_with_optimization(test2); +test_with_optimization(test3); +test_with_optimization(test4); +test_with_optimization(test5); +test_with_optimization(test6); diff --git a/test/mjsunit/regress/regress-320532.js b/test/mjsunit/regress/regress-320532.js index 6ec4b97..0c3198f 100644 --- a/test/mjsunit/regress/regress-320532.js +++ b/test/mjsunit/regress/regress-320532.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -// Flags: --allow-natives-syntax --smi-only-arrays --expose-gc +// Flags: --allow-natives-syntax --expose-gc // Flags: --noalways-opt // Flags: --stress-runs=8 --send-idle-notification --gc-global diff --git a/test/mjsunit/regress/regress-crbug-245480.js b/test/mjsunit/regress/regress-crbug-245480.js index ec88509..43fa6ba 100644 --- a/test/mjsunit/regress/regress-crbug-245480.js +++ b/test/mjsunit/regress/regress-crbug-245480.js @@ -25,25 +25,9 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --smi-only-arrays --expose-gc +// Flags: --allow-natives-syntax --expose-gc // Flags: --noalways-opt -// Test element kind of objects. -// Since --smi-only-arrays affects builtins, its default setting at compile -// time sticks if built with snapshot. If --smi-only-arrays is deactivated -// by default, only a no-snapshot build actually has smi-only arrays enabled -// in this test case. Depending on whether smi-only arrays are actually -// enabled, this test takes the appropriate code path to check smi-only arrays. - -// support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8)); -support_smi_only_arrays = true; - -if (support_smi_only_arrays) { - print("Tests include smi-only arrays."); -} else { - print("Tests do NOT include smi-only arrays."); -} - function isHoley(obj) { if (%HasFastHoleyElements(obj)) return true; return false; @@ -57,19 +41,17 @@ function assertNotHoley(obj, name_opt) { assertEquals(false, isHoley(obj), name_opt); } -if (support_smi_only_arrays) { - function create_array(arg) { - return new Array(arg); - } - - obj = create_array(0); - assertNotHoley(obj); - create_array(0); - %OptimizeFunctionOnNextCall(create_array); - obj = create_array(10); - assertHoley(obj); +function create_array(arg) { + return new Array(arg); } +obj = create_array(0); +assertNotHoley(obj); +create_array(0); +%OptimizeFunctionOnNextCall(create_array); +obj = create_array(10); +assertHoley(obj); + // The code below would assert in debug or crash in release function f(length) { return new Array(length) -- 2.7.4