Commit 1d2a4b83 authored by danno@chromium.org's avatar danno@chromium.org

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
parent c0849f8b
......@@ -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) {
......
......@@ -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);
......
......@@ -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,
......
......@@ -12647,15 +12647,11 @@ MaybeHandle<Object> 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);
......
......@@ -369,7 +369,6 @@ MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate(
Handle<FixedArrayBase> copied_elements_values;
if (IsFastDoubleElementsKind(constant_elements_kind)) {
ASSERT(FLAG_smi_only_arrays);
copied_elements_values = isolate->factory()->CopyFixedDoubleArray(
Handle<FixedDoubleArray>::cast(constant_elements_values));
} else {
......@@ -410,20 +409,6 @@ MaybeHandle<Object> 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
......
This diff is collapsed.
......@@ -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));
......@@ -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));
}
})();
}
}
})();
......@@ -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);
})();
......@@ -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);
})();
......@@ -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];
......
......@@ -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();
......@@ -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);
......
This diff is collapsed.
......@@ -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);
......@@ -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]);
......@@ -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();
......
......@@ -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();
......@@ -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);
......@@ -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
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment