OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "platform/assert.h" | 5 #include "platform/assert.h" |
6 #include "vm/allocation.h" | 6 #include "vm/allocation.h" |
7 #include "vm/longjump.h" | 7 #include "vm/longjump.h" |
8 #include "vm/unit_test.h" | 8 #include "vm/unit_test.h" |
9 | 9 |
10 namespace dart { | 10 namespace dart { |
(...skipping 14 matching lines...) Expand all Loading... |
25 virtual int GetId() const { return 3; } | 25 virtual int GetId() const { return 3; } |
26 | 26 |
27 private: | 27 private: |
28 int* ptr_; | 28 int* ptr_; |
29 }; | 29 }; |
30 | 30 |
31 | 31 |
32 class TestStackResource : public StackResource { | 32 class TestStackResource : public StackResource { |
33 public: | 33 public: |
34 explicit TestStackResource(int* ptr) | 34 explicit TestStackResource(int* ptr) |
35 : StackResource(Isolate::Current()), ptr_(ptr) { | 35 : StackResource(Thread::Current()), ptr_(ptr) { |
36 EXPECT_EQ(1, *ptr_); | 36 EXPECT_EQ(1, *ptr_); |
37 *ptr_ = 2; | 37 *ptr_ = 2; |
38 } | 38 } |
39 | 39 |
40 ~TestStackResource() { | 40 ~TestStackResource() { |
41 EXPECT_EQ(6, *ptr_); | 41 EXPECT_EQ(6, *ptr_); |
42 *ptr_ = 7; | 42 *ptr_ = 7; |
43 } | 43 } |
44 | 44 |
45 int value() const { return *ptr_; } | 45 int value() const { return *ptr_; } |
46 virtual int GetId() const { return 3; } | 46 virtual int GetId() const { return 3; } |
47 | 47 |
48 private: | 48 private: |
49 int* ptr_; | 49 int* ptr_; |
50 }; | 50 }; |
51 | 51 |
52 | 52 |
53 class TestStackedStackResource : public StackResource { | 53 class TestStackedStackResource : public StackResource { |
54 public: | 54 public: |
55 explicit TestStackedStackResource(int* ptr) | 55 explicit TestStackedStackResource(int* ptr) |
56 : StackResource(Isolate::Current()), ptr_(ptr) { | 56 : StackResource(Thread::Current()), ptr_(ptr) { |
57 EXPECT_EQ(3, *ptr_); | 57 EXPECT_EQ(3, *ptr_); |
58 *ptr_ = 4; | 58 *ptr_ = 4; |
59 } | 59 } |
60 | 60 |
61 ~TestStackedStackResource() { | 61 ~TestStackedStackResource() { |
62 EXPECT_EQ(5, *ptr_); | 62 EXPECT_EQ(5, *ptr_); |
63 *ptr_ = 6; | 63 *ptr_ = 6; |
64 } | 64 } |
65 | 65 |
66 int value() const { return *ptr_; } | 66 int value() const { return *ptr_; } |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 if (setjmp(*jump.Set()) == 0) { | 160 if (setjmp(*jump.Set()) == 0) { |
161 StackResourceLongJumpHelper(&data, &jump); | 161 StackResourceLongJumpHelper(&data, &jump); |
162 UNREACHABLE(); | 162 UNREACHABLE(); |
163 } | 163 } |
164 EXPECT_EQ(7, data); | 164 EXPECT_EQ(7, data); |
165 } | 165 } |
166 ASSERT(base == Thread::Current()->long_jump_base()); | 166 ASSERT(base == Thread::Current()->long_jump_base()); |
167 } | 167 } |
168 | 168 |
169 } // namespace dart | 169 } // namespace dart |
OLD | NEW |