~ubuntu-branches/ubuntu/saucy/libv8/saucy

« back to all changes in this revision

Viewing changes to test/mjsunit/regress/regress-1229.js

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2012-04-07 16:26:13 UTC
  • mfrom: (15.1.27 sid)
  • Revision ID: package-import@ubuntu.com-20120407162613-dqo1m6w9r3fh8tst
Tags: 3.8.9.16-3
* mipsel build fixes :
  + v8_use_mips_abi_hardfloat=false, this lowers EABI requirements.
  + v8_can_use_fpu_instructions=false, detect if FPU is present.
  + set -Wno-unused-but-set-variable only on mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright 2011 the V8 project authors. All rights reserved.
 
1
// Copyright 2012 the V8 project authors. All rights reserved.
2
2
// Redistribution and use in source and binary forms, with or without
3
3
// modification, are permitted provided that the following conditions are
4
4
// met:
29
29
 
30
30
// Check that %NewObjectFromBound works correctly when called from optimized
31
31
// frame.
32
 
function foo(x, y, z) {
33
 
  assertEquals(1, x);
34
 
  assertEquals(2, y);
35
 
  assertEquals(3, z);
36
 
}
37
 
 
38
 
var foob = foo.bind({}, 1);
39
 
 
40
 
function f(y, z) {
41
 
  return %NewObjectFromBound(foob);
 
32
function foo1(x, y, z) {
 
33
  assertEquals(1, x);
 
34
  assertEquals(2, y);
 
35
  assertEquals(3, z);
 
36
}
 
37
 
 
38
function foo2(x, y, z) {
 
39
  assertEquals(1, x);
 
40
  assertEquals(2, y);
 
41
  assertEquals(undefined, z);
 
42
}
 
43
 
 
44
function foo3(x, y, z) {
 
45
  assertEquals(1, x);
 
46
  assertEquals(2, y);
 
47
  assertEquals(3, z);
 
48
}
 
49
 
 
50
 
 
51
var foob1 = foo1.bind({}, 1);
 
52
var foob2 = foo2.bind({}, 1);
 
53
var foob3 = foo3.bind({}, 1);
 
54
 
 
55
 
 
56
function f1(y, z) {
 
57
  return %NewObjectFromBound(foob1);
 
58
}
 
59
 
 
60
function f2(y, z) {
 
61
  return %NewObjectFromBound(foob2);
 
62
}
 
63
 
 
64
function f3(y, z) {
 
65
  return %NewObjectFromBound(foob3);
42
66
}
43
67
 
44
68
// Check that %NewObjectFromBound looks at correct frame for inlined function.
45
 
function g(z, y) {
46
 
  return f(y, z); /* f should be inlined into g, note rotated arguments */
 
69
function g1(z, y) {
 
70
  return f1(y, z); /* f should be inlined into g, note rotated arguments */
 
71
}
 
72
 
 
73
function g2(z, y, x) {
 
74
  return f2(y); /* f should be inlined into g, note argument count mismatch */
 
75
}
 
76
 
 
77
function g3(z, y, x) {
 
78
  return f3(x, y, z); /* f should be inlined into g, note argument count mismatch */
47
79
}
48
80
 
49
81
// Check that %NewObjectFromBound looks at correct frame for inlined function.
50
82
function ff(x) { }
51
 
function h(z2, y2) {
52
 
  var local_z = z2 >> 1;
53
 
  ff(local_z);
54
 
  var local_y = y2 >> 1;
55
 
  ff(local_y);
56
 
  return f(local_y, local_z); /* f should be inlined into h */
57
 
}
58
 
 
59
 
for (var i = 0; i < 5; i++) f(2, 3);
60
 
%OptimizeFunctionOnNextCall(f);
61
 
f(2, 3);
62
 
 
63
 
for (var i = 0; i < 5; i++) g(3, 2);
64
 
%OptimizeFunctionOnNextCall(g);
65
 
g(3, 2);
66
 
 
67
 
for (var i = 0; i < 5; i++) h(6, 4);
68
 
%OptimizeFunctionOnNextCall(h);
69
 
h(6, 4);
 
83
function h1(z2, y2) {
 
84
  var local_z = z2 >> 1;
 
85
  ff(local_z);
 
86
  var local_y = y2 >> 1;
 
87
  ff(local_y);
 
88
  return f1(local_y, local_z); /* f should be inlined into h */
 
89
}
 
90
 
 
91
function h2(z2, y2, x2) {
 
92
  var local_z = z2 >> 1;
 
93
  ff(local_z);
 
94
  var local_y = y2 >> 1;
 
95
  ff(local_y);
 
96
  return f2(local_y); /* f should be inlined into h */
 
97
}
 
98
 
 
99
function h3(z2, y2, x2) {
 
100
  var local_z = z2 >> 1;
 
101
  ff(local_z);
 
102
  var local_y = y2 >> 1;
 
103
  ff(local_y);
 
104
  var local_x = x2 >> 1;
 
105
  ff(local_x);
 
106
  return f3(local_x, local_y, local_z); /* f should be inlined into h */
 
107
}
 
108
 
 
109
 
 
110
function invoke(f, args) {
 
111
  for (var i = 0; i < 5; i++) f.apply(this, args);
 
112
  %OptimizeFunctionOnNextCall(f);
 
113
  f.apply(this, args);
 
114
}
 
115
 
 
116
invoke(f1, [2, 3]);
 
117
invoke(f2, [2]);
 
118
invoke(f3, [2, 3, 4]);
 
119
invoke(g1, [3, 2]);
 
120
invoke(g2, [3, 2, 4]);
 
121
invoke(g3, [4, 3, 2]);
 
122
invoke(h1, [6, 4]);
 
123
invoke(h2, [6, 4, 8]);
 
124
invoke(h3, [8, 6, 4]);
70
125
 
71
126
// Check that %_IsConstructCall returns correct value when inlined
72
127
var NON_CONSTRUCT_MARKER = {};
73
128
var CONSTRUCT_MARKER = {};
74
 
function baz() {
 
129
function baz(x) {
75
130
  return (!%_IsConstructCall()) ? NON_CONSTRUCT_MARKER : CONSTRUCT_MARKER;
76
131
}
77
132
 
78
133
function bar(x, y, z) {
 
134
  var non_construct = baz(0); /* baz should be inlined */
 
135
  assertEquals(non_construct, NON_CONSTRUCT_MARKER);
79
136
  var non_construct = baz(); /* baz should be inlined */
80
137
  assertEquals(non_construct, NON_CONSTRUCT_MARKER);
81
 
  var construct = new baz();
 
138
  var non_construct = baz(0, 0); /* baz should be inlined */
 
139
  assertEquals(non_construct, NON_CONSTRUCT_MARKER);
 
140
  var construct = new baz(0);
82
141
  assertEquals(construct, CONSTRUCT_MARKER);
83
142
}
84
143
 
85
 
for (var i = 0; i < 5; i++) new bar(1, 2, 3);
86
 
%OptimizeFunctionOnNextCall(bar);
87
 
bar(1, 2, 3);
 
144
invoke(bar, [1, 2, 3]);