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/globals.h" | 6 #include "vm/globals.h" |
7 | 7 |
8 #include "vm/ast.h" | 8 #include "vm/ast.h" |
9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
10 #include "vm/code_descriptors.h" | 10 #include "vm/code_descriptors.h" |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
250 stack_bitmap->Set(0, false); // var i. | 250 stack_bitmap->Set(0, false); // var i. |
251 stack_bitmap->Set(1, true); // var s1. | 251 stack_bitmap->Set(1, true); // var s1. |
252 stack_bitmap->Set(2, false); // var k. | 252 stack_bitmap->Set(2, false); // var k. |
253 stack_bitmap->Set(3, true); // var s2. | 253 stack_bitmap->Set(3, true); // var s2. |
254 stack_bitmap->Set(4, true); // var s3. | 254 stack_bitmap->Set(4, true); // var s3. |
255 const Code& code = Code::Handle(function_foo.unoptimized_code()); | 255 const Code& code = Code::Handle(function_foo.unoptimized_code()); |
256 // Search for the pc of the call to 'func'. | 256 // Search for the pc of the call to 'func'. |
257 const PcDescriptors& descriptors = | 257 const PcDescriptors& descriptors = |
258 PcDescriptors::Handle(code.pc_descriptors()); | 258 PcDescriptors::Handle(code.pc_descriptors()); |
259 int call_count = 0; | 259 int call_count = 0; |
260 for (int i = 0; i < descriptors.Length(); ++i) { | 260 PcDescriptors::Iterator iter(descriptors); |
siva
2014/07/01 18:37:11
Not for this CL but it might make things easier to
srdjan
2014/07/07 18:01:25
I am planning either that, or specifying the kind
| |
261 if (descriptors.DescriptorKind(i) == PcDescriptors::kUnoptStaticCall) { | 261 while (iter.HasNext()) { |
262 stackmap_table_builder->AddEntry(descriptors.PC(i) - code.EntryPoint(), | 262 const RawPcDescriptors::PcDescriptorRec& rec = iter.Next(); |
263 if (rec.kind() == RawPcDescriptors::kUnoptStaticCall) { | |
264 stackmap_table_builder->AddEntry(rec.pc - code.EntryPoint(), | |
263 stack_bitmap, | 265 stack_bitmap, |
264 0); | 266 0); |
265 ++call_count; | 267 ++call_count; |
266 } | 268 } |
267 } | 269 } |
268 // We can't easily check that we put the stackmap at the correct pc, but | 270 // We can't easily check that we put the stackmap at the correct pc, but |
269 // we did if there was exactly one call seen. | 271 // we did if there was exactly one call seen. |
270 EXPECT(call_count == 1); | 272 EXPECT(call_count == 1); |
271 const Array& stack_maps = | 273 const Array& stack_maps = |
272 Array::Handle(stackmap_table_builder->FinalizeStackmaps(code)); | 274 Array::Handle(stackmap_table_builder->FinalizeStackmaps(code)); |
273 code.set_stackmaps(stack_maps); | 275 code.set_stackmaps(stack_maps); |
274 | 276 |
275 // Now invoke 'A.moo' and it will trigger a GC when the native function | 277 // Now invoke 'A.moo' and it will trigger a GC when the native function |
276 // is called, this should then cause the stack map of function 'A.foo' | 278 // is called, this should then cause the stack map of function 'A.foo' |
277 // to be traversed and the appropriate objects visited. | 279 // to be traversed and the appropriate objects visited. |
278 const Object& result = Object::Handle( | 280 const Object& result = Object::Handle( |
279 DartEntry::InvokeFunction(function_foo, Object::empty_array())); | 281 DartEntry::InvokeFunction(function_foo, Object::empty_array())); |
280 EXPECT(!result.IsError()); | 282 EXPECT(!result.IsError()); |
281 } | 283 } |
282 | 284 |
283 } // namespace dart | 285 } // namespace dart |
OLD | NEW |