| 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 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) | 7 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
| 8 | 8 |
| 9 #include "vm/ast.h" | 9 #include "vm/ast.h" |
| 10 #include "vm/assembler.h" | 10 #include "vm/assembler.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 194 |
| 195 // Build and setup a stackmap for function 'A.foo' in order to test the | 195 // Build and setup a stackmap for function 'A.foo' in order to test the |
| 196 // traversal of stack maps when a GC happens. | 196 // traversal of stack maps when a GC happens. |
| 197 StackmapBuilder* builder = new StackmapBuilder(); | 197 StackmapBuilder* builder = new StackmapBuilder(); |
| 198 EXPECT(builder != NULL); | 198 EXPECT(builder != NULL); |
| 199 builder->SetSlotAsValue(0); // var i. | 199 builder->SetSlotAsValue(0); // var i. |
| 200 builder->SetSlotAsObject(1); // var s1. | 200 builder->SetSlotAsObject(1); // var s1. |
| 201 builder->SetSlotAsValue(2); // var k. | 201 builder->SetSlotAsValue(2); // var k. |
| 202 builder->SetSlotAsObject(3); // var s2. | 202 builder->SetSlotAsObject(3); // var s2. |
| 203 builder->SetSlotAsObject(4); // var s3. | 203 builder->SetSlotAsObject(4); // var s3. |
| 204 builder->AddEntry(0); // Add a stack map entry at pc offset 0. | |
| 205 const Code& code = Code::Handle(function_foo.unoptimized_code()); | 204 const Code& code = Code::Handle(function_foo.unoptimized_code()); |
| 205 // Search for the pc of the call to 'func'. |
| 206 const PcDescriptors& descriptors = |
| 207 PcDescriptors::Handle(code.pc_descriptors()); |
| 208 for (int i = 0; i < descriptors.Length(); ++i) { |
| 209 if (descriptors.DescriptorKind(i) == PcDescriptors::kFuncCall) { |
| 210 builder->AddEntry(descriptors.PC(i) - code.EntryPoint()); |
| 211 } |
| 212 } |
| 206 const Array& stack_maps = Array::Handle(builder->FinalizeStackmaps(code)); | 213 const Array& stack_maps = Array::Handle(builder->FinalizeStackmaps(code)); |
| 207 code.set_stackmaps(stack_maps); | 214 code.set_stackmaps(stack_maps); |
| 208 | 215 |
| 209 // Now invoke 'A.moo' and it will trigger a GC when the native function | 216 // Now invoke 'A.moo' and it will trigger a GC when the native function |
| 210 // is called, this should then cause the stack map of function 'A.foo' | 217 // is called, this should then cause the stack map of function 'A.foo' |
| 211 // to be traversed and the appropriate objects visited. | 218 // to be traversed and the appropriate objects visited. |
| 212 GrowableArray<const Object*> arguments; | 219 GrowableArray<const Object*> arguments; |
| 213 const Array& kNoArgumentNames = Array::Handle(); | 220 const Array& kNoArgumentNames = Array::Handle(); |
| 214 Object& result = Object::Handle(); | 221 Object& result = Object::Handle(); |
| 215 result = DartEntry::InvokeStatic(function_foo, arguments, kNoArgumentNames); | 222 result = DartEntry::InvokeStatic(function_foo, arguments, kNoArgumentNames); |
| 216 EXPECT(!result.IsError()); | 223 EXPECT(!result.IsError()); |
| 217 } | 224 } |
| 218 | 225 |
| 219 } // namespace dart | 226 } // namespace dart |
| 220 | 227 |
| 221 #endif // defined TARGET_ARCH_IA32 || defined(TARGET_ARCH_X64) | 228 #endif // defined TARGET_ARCH_IA32 || defined(TARGET_ARCH_X64) |
| OLD | NEW |