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

Side by Side Diff: test/mjsunit/call-counts.js

Issue 1217943004: Vector ICs: Introduce an InstanceType for the type feedback vector. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Improved printer. Created 5 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --allow-natives-syntax --noalways-opt 5 // Flags: --allow-natives-syntax --noalways-opt
6 6
7 // Locations in the type feedback vector where call counts are maintained for 7 // Locations in the type feedback vector where call counts are maintained for
8 // the two calls made from bar(); 8 // the two calls made from bar();
9 const kFooCallExtraIndex = 5; 9 const kFooCallExtraIndex = 5;
10 const kArrayCallExtraIndex = 9; 10 const kArrayCallExtraIndex = 9;
11 11
12 function GetCallCount(func, slot) { 12 function GetCallCount(func, slot) {
13 var vector = %GetTypeFeedbackVector(func); 13 var vector = %GetTypeFeedbackVector(func);
14 // Call counts are recorded doubled. 14 // Call counts are recorded doubled.
15 var value = %FixedArrayGet(vector, slot); 15 var value = %FeedbackVectorGet(vector, slot);
16 return Math.floor(value / 2); 16 return Math.floor(value / 2);
17 } 17 }
18 18
19 function foo(a) { return a[3] * 16; } 19 function foo(a) { return a[3] * 16; }
20 20
21 function bar(a) { 21 function bar(a) {
22 var result = 0; 22 var result = 0;
23 for (var i = 0; i < 10; i++) { 23 for (var i = 0; i < 10; i++) {
24 result = foo(a); 24 result = foo(a);
25 if (i % 2 === 0) { 25 if (i % 2 === 0) {
26 var r = Array(); 26 var r = Array();
27 r[0] = 1; 27 r[0] = 1;
28 result += r[0]; 28 result += r[0];
29 } 29 }
30 } 30 }
31 return result; 31 return result;
32 } 32 }
33 33
34 var a = [1, 2, 3]; 34 var a = [1, 2, 3];
35 bar(a); 35 bar(a);
36 assertEquals(10, GetCallCount(bar, kFooCallExtraIndex)); 36 assertEquals(10, GetCallCount(bar, kFooCallExtraIndex));
37 assertEquals(5, GetCallCount(bar, kArrayCallExtraIndex)); 37 assertEquals(5, GetCallCount(bar, kArrayCallExtraIndex));
38 38
39 %OptimizeFunctionOnNextCall(bar); 39 %OptimizeFunctionOnNextCall(bar);
40 bar(a); 40 bar(a);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698