~ubuntu-branches/ubuntu/trusty/libv8/trusty

« back to all changes in this revision

Viewing changes to .pc/0015_hash-collision-fix-v8-3.6.patch/test/mjsunit/debug-evaluate-locals-optimized-double.js

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2012-02-20 14:08:17 UTC
  • mfrom: (15.1.24 sid)
  • Revision ID: package-import@ubuntu.com-20120220140817-bsvmeoa4sxsj5hbz
Tags: 3.7.12.22-3
Fix mipsel build, allow test debug-step-3 to fail (non-crucial)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright 2008 the V8 project authors. All rights reserved.
2
 
// Redistribution and use in source and binary forms, with or without
3
 
// modification, are permitted provided that the following conditions are
4
 
// met:
5
 
//
6
 
//     * Redistributions of source code must retain the above copyright
7
 
//       notice, this list of conditions and the following disclaimer.
8
 
//     * Redistributions in binary form must reproduce the above
9
 
//       copyright notice, this list of conditions and the following
10
 
//       disclaimer in the documentation and/or other materials provided
11
 
//       with the distribution.
12
 
//     * Neither the name of Google Inc. nor the names of its
13
 
//       contributors may be used to endorse or promote products derived
14
 
//       from this software without specific prior written permission.
15
 
//
16
 
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
 
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
 
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
 
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
 
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
 
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
 
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
 
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
 
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 
 
28
 
// Flags: --expose-debug-as debug --allow-natives-syntax
29
 
// Get the Debug object exposed from the debug context global object.
30
 
Debug = debug.Debug
31
 
 
32
 
var listenerComplete = false;
33
 
var exception = false;
34
 
 
35
 
var testingConstructCall = false;
36
 
 
37
 
 
38
 
function listener(event, exec_state, event_data, data) {
39
 
  try {
40
 
    if (event == Debug.DebugEvent.Break)
41
 
    {
42
 
      assertEquals(6, exec_state.frameCount());
43
 
 
44
 
      for (var i = 0; i < exec_state.frameCount(); i++) {
45
 
        var frame = exec_state.frame(i);
46
 
        if (i < exec_state.frameCount() - 1) {
47
 
          var expected_a = i * 2 + 1 + (i * 2 + 1) / 100;
48
 
          var expected_b = i * 2 + 2 + (i * 2 + 2) / 100;
49
 
          var expected_x = (i + 1) * 2 + 1 + ((i + 1) * 2 + 1) / 100;
50
 
          var expected_y = (i + 1) * 2 + 2 + ((i + 1) * 2 + 2) / 100;
51
 
 
52
 
          // All frames except the bottom one has normal variables a and b.
53
 
          assertEquals('a', frame.localName(0));
54
 
          assertEquals('b', frame.localName(1));
55
 
          assertEquals(expected_a, frame.localValue(0).value());
56
 
          assertEquals(expected_b, frame.localValue(1).value());
57
 
 
58
 
          // All frames except the bottom one has arguments variables x and y.
59
 
          assertEquals('x', frame.argumentName(0));
60
 
          assertEquals('y', frame.argumentName(1));
61
 
          assertEquals(expected_x, frame.argumentValue(0).value());
62
 
          assertEquals(expected_y, frame.argumentValue(1).value());
63
 
 
64
 
          // All frames except the bottom one have two scopes.
65
 
          assertEquals(2, frame.scopeCount());
66
 
          assertEquals(debug.ScopeType.Local, frame.scope(0).scopeType());
67
 
          assertEquals(debug.ScopeType.Global, frame.scope(1).scopeType());
68
 
          assertEquals(expected_a, frame.scope(0).scopeObject().value()['a']);
69
 
          assertEquals(expected_b, frame.scope(0).scopeObject().value()['b']);
70
 
          assertEquals(expected_x, frame.scope(0).scopeObject().value()['x']);
71
 
          assertEquals(expected_y, frame.scope(0).scopeObject().value()['y']);
72
 
 
73
 
          // Evaluate in the inlined frame.
74
 
          assertEquals(expected_a, frame.evaluate('a').value());
75
 
          assertEquals(expected_x, frame.evaluate('x').value());
76
 
          assertEquals(expected_x, frame.evaluate('arguments[0]').value());
77
 
          assertEquals(expected_a + expected_b + expected_x + expected_y,
78
 
                       frame.evaluate('a + b + x + y').value());
79
 
          assertEquals(expected_x + expected_y,
80
 
                       frame.evaluate('arguments[0] + arguments[1]').value());
81
 
        } else {
82
 
          // The bottom frame only have the global scope.
83
 
          assertEquals(1, frame.scopeCount());
84
 
          assertEquals(debug.ScopeType.Global, frame.scope(0).scopeType());
85
 
        }
86
 
 
87
 
        // Check the frame function.
88
 
        switch (i) {
89
 
          case 0: assertEquals(h, frame.func().value()); break;
90
 
          case 1: assertEquals(g3, frame.func().value()); break;
91
 
          case 2: assertEquals(g2, frame.func().value()); break;
92
 
          case 3: assertEquals(g1, frame.func().value()); break;
93
 
          case 4: assertEquals(f, frame.func().value()); break;
94
 
          case 5: break;
95
 
          default: assertUnreachable();
96
 
        }
97
 
 
98
 
        // Check for construct call.
99
 
        assertEquals(testingConstructCall && i == 4, frame.isConstructCall());
100
 
 
101
 
        // When function f is optimized (1 means YES, see runtime.cc) we
102
 
        // expect an optimized frame for f with g1, g2 and g3 inlined.
103
 
        if (%GetOptimizationStatus(f) == 1) {
104
 
          if (i == 1 || i == 2 || i == 3) {
105
 
            assertTrue(frame.isOptimizedFrame());
106
 
            assertTrue(frame.isInlinedFrame());
107
 
            assertEquals(4 - i, frame.inlinedFrameIndex());
108
 
          } else if (i == 4) {
109
 
            assertTrue(frame.isOptimizedFrame());
110
 
            assertFalse(frame.isInlinedFrame());
111
 
          } else {
112
 
            assertFalse(frame.isOptimizedFrame());
113
 
            assertFalse(frame.isInlinedFrame());
114
 
          }
115
 
        }
116
 
      }
117
 
 
118
 
      // Indicate that all was processed.
119
 
      listenerComplete = true;
120
 
    }
121
 
  } catch (e) {
122
 
    exception = e
123
 
  };
124
 
};
125
 
 
126
 
f();f();f();
127
 
%OptimizeFunctionOnNextCall(f);
128
 
f();
129
 
 
130
 
// Add the debug event listener.
131
 
Debug.setListener(listener);
132
 
 
133
 
function h(x, y) {
134
 
  var a = 1;
135
 
  var b = 2;
136
 
  a = a + a / 100;
137
 
  b = b + b / 100;
138
 
  debugger;  // Breakpoint.
139
 
};
140
 
 
141
 
function g3(x, y) {
142
 
  var a = 3;
143
 
  var b = 4;
144
 
  a = a + a / 100;
145
 
  b = b + b / 100;
146
 
  h(a, b);
147
 
  return a+b;
148
 
};
149
 
 
150
 
function g2(x, y) {
151
 
  var a = 5;
152
 
  var b = 6;
153
 
  a = a + a / 100;
154
 
  b = b + b / 100;
155
 
  g3(a, b);
156
 
};
157
 
 
158
 
function g1(x, y) {
159
 
  var a = 7;
160
 
  var b = 8;
161
 
  a = a + a / 100;
162
 
  b = b + b / 100;
163
 
  g2(a, b);
164
 
};
165
 
 
166
 
function f(x, y) {
167
 
  var a = 9;
168
 
  var b = 10;
169
 
  a = a + a / 100;
170
 
  b = b + b / 100;
171
 
  g1(a, b);
172
 
};
173
 
 
174
 
// Test calling f normally and as a constructor.
175
 
f(11.11, 12.12);
176
 
testingConstructCall = true;
177
 
new f(11.11, 12.12);
178
 
 
179
 
// Make sure that the debug event listener vas invoked.
180
 
assertFalse(exception, "exception in listener " + exception)
181
 
assertTrue(listenerComplete);
182
 
 
183
 
Debug.setListener(null);