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

Unified Diff: test/mjsunit/allocation-site-info.js

Issue 12114054: Supporting AllocationSiteInfo for Nested arrays (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Some updates Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/x64/code-stubs-x64.cc ('K') | « src/x64/lithium-codegen-x64.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/allocation-site-info.js
diff --git a/test/mjsunit/allocation-site-info.js b/test/mjsunit/allocation-site-info.js
index 3c8238710814be1beb7e55c3209fcd3840c898a5..e886dc8103a955cef2bb682c26c6311e5f740998 100644
--- a/test/mjsunit/allocation-site-info.js
+++ b/test/mjsunit/allocation-site-info.js
@@ -26,7 +26,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --smi-only-arrays --expose-gc
-// Flags: --track-allocation-sites
+// Flags: --track-allocation-sites --noalways-opt
// Test element kind of objects.
// Since --smi-only-arrays affects builtins, its default setting at compile
@@ -76,7 +76,6 @@ function assertKind(expected, obj, name_opt) {
if (support_smi_only_arrays) {
function fastliteralcase(literal, value) {
- // var literal = [1, 2, 3];
literal[0] = value;
return literal;
}
@@ -94,12 +93,17 @@ if (support_smi_only_arrays) {
obj = fastliteralcase(get_standard_literal(), 2);
assertKind(elements_kind.fast_double, obj);
- 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);
- obj = fastliteralcase([2, 6, 3], 2);
- assertKind(elements_kind.fast_smi_only, 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);
+ obj = fastliteralcase([2, 6, 3], 2);
+ assertKind(elements_kind.fast_smi_only, obj);
+ }
// Verify that we will not pretransition the double->fast path.
obj = fastliteralcase(get_standard_literal(), "elliot");
@@ -111,6 +115,12 @@ if (support_smi_only_arrays) {
// obj = fastliteralcase(3);
// assertKind(elements_kind.fast_double, obj);
+ // Make sure this works in crankshafted code too.
+ %OptimizeFunctionOnNextCall(get_standard_literal);
+ get_standard_literal();
+ obj = get_standard_literal();
+ assertKind(elements_kind.fast_double, obj);
+
function fastliteralcase_smifast(value) {
var literal = [1, 2, 3, 4];
literal[0] = value;
@@ -123,4 +133,89 @@ if (support_smi_only_arrays) {
assertKind(elements_kind.fast, obj);
obj = fastliteralcase_smifast(2);
assertKind(elements_kind.fast, obj);
+
+ // 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);
+ assertKind(elements_kind.fast_smi_only, obj[0]);
+ assertKind(elements_kind.fast_smi_only, obj[1]);
+ assertKind(elements_kind.fast_smi_only, obj[2]);
+ obj[0][0] = 3.5;
+ obj[2][0] = "hello";
+ assertKind(elements_kind.fast_double, obj[0]);
+ assertKind(elements_kind.fast_smi_only, obj[1]);
+ assertKind(elements_kind.fast, obj[2]);
+ obj = get_nested_literal();
+ assertKind(elements_kind.fast, obj);
+ 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[0]);
+ assertKind(elements_kind.fast, obj[1]);
+ assertKind(elements_kind.fast_smi_only, obj[1][0]);
+ assertKind(elements_kind.fast_smi_only, obj[3]);
+ obj[0][0] = 3.5;
+ obj[1][0][0] = "goodbye";
+
+ assertKind(elements_kind.fast_double, obj[0]);
+ assertKind(elements_kind.fast, obj[1]);
+ assertKind(elements_kind.fast, obj[1][0]);
+ assertKind(elements_kind.fast_smi_only, obj[3]);
+
+ obj = get_deep_nested_literal();
+
+ assertKind(elements_kind.fast_double, obj[0]);
+ assertKind(elements_kind.fast, obj[1]);
+ assertKind(elements_kind.fast, obj[1][0]);
+ assertKind(elements_kind.fast_smi_only, obj[3]);
+
+ // 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]);
+
+ %OptimizeFunctionOnNextCall(get_nested_object_literal);
+ get_nested_object_literal();
+ obj = get_nested_object_literal();
+ assertKind(elements_kind.fast_double, obj.array[1]);
}
« src/x64/code-stubs-x64.cc ('K') | « src/x64/lithium-codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698