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

Unified Diff: test/mjsunit/regress/regress-trap-allocation-memento.js

Issue 2487943005: [stubs] Fix CodeStubAssembler::TrapAllocationMemento (Closed)
Patch Set: use a bigger hammer Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/code-stub-assembler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/regress/regress-trap-allocation-memento.js
diff --git a/test/mjsunit/regress/regress-trap-allocation-memento.js b/test/mjsunit/regress/regress-trap-allocation-memento.js
new file mode 100644
index 0000000000000000000000000000000000000000..12baca091838b7546c7333beba390c7ae0bc439b
--- /dev/null
+++ b/test/mjsunit/regress/regress-trap-allocation-memento.js
@@ -0,0 +1,50 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --allow-natives-syntax --noalways-opt
+
+var elements_kind = {
+ fast_smi_only : 'fast smi only elements',
+ fast : 'fast elements',
+ fast_double : 'fast double elements',
+ dictionary : 'dictionary elements',
+}
+
+function getKind(obj) {
+ if (%HasFastSmiElements(obj)) return elements_kind.fast_smi_only;
+ if (%HasFastObjectElements(obj)) return elements_kind.fast;
+ if (%HasFastDoubleElements(obj)) return elements_kind.fast_double;
+ if (%HasDictionaryElements(obj)) return elements_kind.dictionary;
+}
+
+function assertKind(expected, obj, name_opt) {
+ assertEquals(expected, getKind(obj), name_opt);
+}
+
+(function() {
+ function make1() { return new Array(); }
+ function make2() { return new Array(); }
+ function make3() { return new Array(); }
+ function foo(a, i) { a[0] = i; }
+
+ function run_test(maker_function) {
+ var one = maker_function();
+ assertKind(elements_kind.fast_smi_only, one);
+ // Use memento to pre-transition allocation site to DOUBLE elements.
+ foo(one, 1.5);
+ // Newly created arrays should now have DOUBLE elements right away.
+ var two = maker_function();
+ assertKind(elements_kind.fast_double, two);
+ }
+
+ // Initialize the KeyedStoreIC in foo; the actual operation will be done
+ // in the runtime.
+ run_test(make1);
+ // Run again; the IC optimistically assumed to only see the transitioned
+ // (double-elements) map again, so this will make it polymorphic.
+ // The actual operation will again be done in the runtime.
+ run_test(make2);
+ // Finally, check if the initialized IC honors the allocation memento.
+ run_test(make3);
+})();
« no previous file with comments | « src/code-stub-assembler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698