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/isolate.h" | 6 #include "vm/isolate.h" |
7 #include "vm/lockers.h" | 7 #include "vm/lockers.h" |
8 #include "vm/unit_test.h" | 8 #include "vm/unit_test.h" |
9 #include "vm/profiler.h" | 9 #include "vm/profiler.h" |
10 #include "vm/thread_pool.h" | 10 #include "vm/thread_pool.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 public: | 110 public: |
111 TaskWithZoneAllocation(Isolate* isolate, | 111 TaskWithZoneAllocation(Isolate* isolate, |
112 const String& foo, | 112 const String& foo, |
113 Monitor* monitor, | 113 Monitor* monitor, |
114 bool* done, | 114 bool* done, |
115 intptr_t id) | 115 intptr_t id) |
116 : isolate_(isolate), foo_(foo), monitor_(monitor), done_(done), id_(id) {} | 116 : isolate_(isolate), foo_(foo), monitor_(monitor), done_(done), id_(id) {} |
117 virtual void Run() { | 117 virtual void Run() { |
118 Thread::EnterIsolateAsHelper(isolate_); | 118 Thread::EnterIsolateAsHelper(isolate_); |
119 { | 119 { |
| 120 Thread* thread = Thread::Current(); |
120 // Create a zone (which is also a stack resource) and exercise it a bit. | 121 // Create a zone (which is also a stack resource) and exercise it a bit. |
121 StackZone stack_zone(Thread::Current()); | 122 StackZone stack_zone(thread); |
122 Zone* zone = Thread::Current()->zone(); | 123 HANDLESCOPE(thread); |
| 124 Zone* zone = thread->zone(); |
123 EXPECT_EQ(zone, stack_zone.GetZone()); | 125 EXPECT_EQ(zone, stack_zone.GetZone()); |
124 ZoneGrowableArray<bool>* a0 = new(zone) ZoneGrowableArray<bool>(zone, 1); | 126 ZoneGrowableArray<bool>* a0 = new(zone) ZoneGrowableArray<bool>(zone, 1); |
125 GrowableArray<bool> a1(zone, 1); | 127 GrowableArray<bool> a1(zone, 1); |
126 for (intptr_t i = 0; i < 100000; ++i) { | 128 for (intptr_t i = 0; i < 100000; ++i) { |
127 a0->Add(true); | 129 a0->Add(true); |
128 a1.Add(true); | 130 a1.Add(true); |
129 } | 131 } |
130 // Check that we can create handles (but not yet allocate heap objects). | 132 // Check that we can create handles (but not yet allocate heap objects). |
131 String& str = String::Handle(zone, foo_.raw()); | 133 String& str = String::Handle(zone, foo_.raw()); |
132 EXPECT(str.Equals("foo")); | 134 EXPECT(str.Equals("foo")); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 Thread::ExitIsolate(); | 218 Thread::ExitIsolate(); |
217 Thread::EnterIsolate(orig); | 219 Thread::EnterIsolate(orig); |
218 // Original zone should be preserved. | 220 // Original zone should be preserved. |
219 EXPECT_EQ(orig_zone, Thread::Current()->zone()); | 221 EXPECT_EQ(orig_zone, Thread::Current()->zone()); |
220 EXPECT_STREQ("foo", orig_str); | 222 EXPECT_STREQ("foo", orig_str); |
221 delete isos[0]; | 223 delete isos[0]; |
222 delete isos[1]; | 224 delete isos[1]; |
223 } | 225 } |
224 | 226 |
225 } // namespace dart | 227 } // namespace dart |
OLD | NEW |