| 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 stack_bitmap->Set(1, true); // var s1. | 252 stack_bitmap->Set(1, true); // var s1. |
| 253 stack_bitmap->Set(2, false); // var k. | 253 stack_bitmap->Set(2, false); // var k. |
| 254 stack_bitmap->Set(3, true); // var s2. | 254 stack_bitmap->Set(3, true); // var s2. |
| 255 stack_bitmap->Set(4, true); // var s3. | 255 stack_bitmap->Set(4, true); // var s3. |
| 256 const Code& code = Code::Handle(function_foo.unoptimized_code()); | 256 const Code& code = Code::Handle(function_foo.unoptimized_code()); |
| 257 // Search for the pc of the call to 'func'. | 257 // Search for the pc of the call to 'func'. |
| 258 const PcDescriptors& descriptors = | 258 const PcDescriptors& descriptors = |
| 259 PcDescriptors::Handle(code.pc_descriptors()); | 259 PcDescriptors::Handle(code.pc_descriptors()); |
| 260 int call_count = 0; | 260 int call_count = 0; |
| 261 for (int i = 0; i < descriptors.Length(); ++i) { | 261 for (int i = 0; i < descriptors.Length(); ++i) { |
| 262 if (descriptors.DescriptorKind(i) == PcDescriptors::kFuncCall) { | 262 if (descriptors.DescriptorKind(i) == PcDescriptors::kUnoptStaticCall) { |
| 263 stackmap_table_builder->AddEntry(descriptors.PC(i) - code.EntryPoint(), | 263 stackmap_table_builder->AddEntry(descriptors.PC(i) - code.EntryPoint(), |
| 264 stack_bitmap, | 264 stack_bitmap, |
| 265 0); | 265 0); |
| 266 ++call_count; | 266 ++call_count; |
| 267 } | 267 } |
| 268 } | 268 } |
| 269 // We can't easily check that we put the stackmap at the correct pc, but | 269 // We can't easily check that we put the stackmap at the correct pc, but |
| 270 // we did if there was exactly one call seen. | 270 // we did if there was exactly one call seen. |
| 271 EXPECT(call_count == 1); | 271 EXPECT(call_count == 1); |
| 272 const Array& stack_maps = | 272 const Array& stack_maps = |
| 273 Array::Handle(stackmap_table_builder->FinalizeStackmaps(code)); | 273 Array::Handle(stackmap_table_builder->FinalizeStackmaps(code)); |
| 274 code.set_stackmaps(stack_maps); | 274 code.set_stackmaps(stack_maps); |
| 275 | 275 |
| 276 // Now invoke 'A.moo' and it will trigger a GC when the native function | 276 // Now invoke 'A.moo' and it will trigger a GC when the native function |
| 277 // is called, this should then cause the stack map of function 'A.foo' | 277 // is called, this should then cause the stack map of function 'A.foo' |
| 278 // to be traversed and the appropriate objects visited. | 278 // to be traversed and the appropriate objects visited. |
| 279 const Object& result = Object::Handle( | 279 const Object& result = Object::Handle( |
| 280 DartEntry::InvokeFunction(function_foo, Object::empty_array())); | 280 DartEntry::InvokeFunction(function_foo, Object::empty_array())); |
| 281 EXPECT(!result.IsError()); | 281 EXPECT(!result.IsError()); |
| 282 } | 282 } |
| 283 | 283 |
| 284 } // namespace dart | 284 } // namespace dart |
| 285 | 285 |
| OLD | NEW |