OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // VMOptions=--error_on_bad_type --error_on_bad_override |
| 5 |
| 6 import 'dart:developer'; |
| 7 import 'package:observatory/service_io.dart'; |
| 8 import 'package:unittest/unittest.dart'; |
| 9 import 'service_test_common.dart'; |
| 10 import 'test_helper.dart'; |
| 11 |
| 12 const alwaysInline = "AlwaysInline"; |
| 13 const noInline = "NeverInline"; |
| 14 |
| 15 int LINE_A = 35; |
| 16 int LINE_B = 40; |
| 17 int LINE_C = 43; |
| 18 int LINE_D = 47; |
| 19 |
| 20 int global = 0; |
| 21 |
| 22 @noInline |
| 23 b3(x) { |
| 24 int sum = 0; |
| 25 try { |
| 26 for (int i = 0; i < x; i++) { |
| 27 sum += x; |
| 28 } |
| 29 } catch (e) { |
| 30 print("caught $e"); |
| 31 } |
| 32 if (global >= 100) { |
| 33 debugger(); |
| 34 } |
| 35 global = global + 1; // Line A |
| 36 return sum; |
| 37 } |
| 38 |
| 39 @alwaysInline |
| 40 b2(x) => b3(x); // Line B |
| 41 |
| 42 @alwaysInline |
| 43 b1(x) => b2(x); // Line C |
| 44 |
| 45 test() { |
| 46 while (true) { |
| 47 b1(10000); // Line D |
| 48 } |
| 49 } |
| 50 |
| 51 var tests = [ |
| 52 hasStoppedAtBreakpoint, |
| 53 stoppedAtLine(LINE_A), |
| 54 |
| 55 (Isolate isolate) async { |
| 56 // We are at our breakpoint with global=100. |
| 57 var result = await isolate.rootLibrary.evaluate('global'); |
| 58 print('global is $result'); |
| 59 expect(result.type, equals('Instance')); |
| 60 expect(result.valueAsString, equals('100')); |
| 61 |
| 62 // Rewind the top stack frame. |
| 63 bool caughtException; |
| 64 try { |
| 65 result = await isolate.rewind(1); |
| 66 expect(false, isTrue, reason:'Unreachable'); |
| 67 } on ServerRpcException catch(e) { |
| 68 caughtException = true; |
| 69 expect(e.code, equals(ServerRpcException.kCannotResume)); |
| 70 expect(e.message, |
| 71 'Cannot rewind to frame 1 due to conflicting compiler ' |
| 72 'optimizations. Run the vm with --no-prune-dead-locals to ' |
| 73 'disallow these optimizations. Next valid rewind frame is 4.'); |
| 74 } |
| 75 expect(caughtException, isTrue); |
| 76 }, |
| 77 ]; |
| 78 |
| 79 |
| 80 main(args) => runIsolateTests(args, tests, testeeConcurrent: test, |
| 81 extraArgs: |
| 82 ['--trace-rewind', |
| 83 '--prune-dead-locals', |
| 84 '--enable-inlining-annotations', |
| 85 '--no-background-compilation', |
| 86 '--optimization-counter-threshold=10']); |
OLD | NEW |