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" |
11 #include "vm/compiler.h" | 11 #include "vm/compiler.h" |
12 #include "vm/dart_entry.h" | 12 #include "vm/dart_entry.h" |
13 #include "vm/native_entry.h" | 13 #include "vm/native_entry.h" |
14 #include "vm/parser.h" | 14 #include "vm/parser.h" |
15 #include "vm/symbols.h" | 15 #include "vm/symbols.h" |
16 #include "vm/thread.h" | 16 #include "vm/thread.h" |
17 #include "vm/unit_test.h" | 17 #include "vm/unit_test.h" |
18 | 18 |
19 namespace dart { | 19 namespace dart { |
20 | 20 |
21 static const intptr_t kPos = Scanner::kNoSourcePos; | 21 static const intptr_t kPos = Token::kNoSourcePos; |
22 | 22 |
23 | 23 |
24 CODEGEN_TEST_GENERATE(StackmapCodegen, test) { | 24 CODEGEN_TEST_GENERATE(StackmapCodegen, test) { |
25 ParsedFunction* parsed_function = | 25 ParsedFunction* parsed_function = |
26 new ParsedFunction(Thread::Current(), test->function()); | 26 new ParsedFunction(Thread::Current(), test->function()); |
27 LiteralNode* l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(1))); | 27 LiteralNode* l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(1))); |
28 test->node_sequence()->Add(new ReturnNode(kPos, l)); | 28 test->node_sequence()->Add(new ReturnNode(kPos, l)); |
29 l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(2))); | 29 l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(2))); |
30 test->node_sequence()->Add(new ReturnNode(kPos, l)); | 30 test->node_sequence()->Add(new ReturnNode(kPos, l)); |
31 l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(3))); | 31 l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(3))); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 code.set_stackmaps(stack_maps); | 261 code.set_stackmaps(stack_maps); |
262 | 262 |
263 // Now invoke 'A.moo' and it will trigger a GC when the native function | 263 // Now invoke 'A.moo' and it will trigger a GC when the native function |
264 // is called, this should then cause the stack map of function 'A.foo' | 264 // is called, this should then cause the stack map of function 'A.foo' |
265 // to be traversed and the appropriate objects visited. | 265 // to be traversed and the appropriate objects visited. |
266 const Object& result = Object::Handle( | 266 const Object& result = Object::Handle( |
267 DartEntry::InvokeFunction(function_foo, Object::empty_array())); | 267 DartEntry::InvokeFunction(function_foo, Object::empty_array())); |
268 EXPECT(!result.IsError()); | 268 EXPECT(!result.IsError()); |
269 } | 269 } |
270 | 270 |
| 271 |
| 272 TEST_CASE(DescriptorList_TokenPositions) { |
| 273 DescriptorList* descriptors = new DescriptorList(64); |
| 274 ASSERT(descriptors != NULL); |
| 275 const intptr_t token_positions[] = { |
| 276 kMinInt32, |
| 277 5, |
| 278 13, |
| 279 13, |
| 280 13, |
| 281 13, |
| 282 31, |
| 283 23, |
| 284 23, |
| 285 23, |
| 286 33, |
| 287 33, |
| 288 5, |
| 289 5, |
| 290 Token::kMinSourcePos, |
| 291 Token::kMaxSourcePos, |
| 292 }; |
| 293 const intptr_t num_token_positions = |
| 294 sizeof(token_positions) / sizeof(token_positions[0]); |
| 295 |
| 296 for (intptr_t i = 0; i < num_token_positions; i++) { |
| 297 descriptors->AddDescriptor(RawPcDescriptors::kRuntimeCall, 0, 0, |
| 298 token_positions[i], 0); |
| 299 } |
| 300 |
| 301 const PcDescriptors& finalized_descriptors = |
| 302 PcDescriptors::Handle(descriptors->FinalizePcDescriptors(0)); |
| 303 |
| 304 ASSERT(!finalized_descriptors.IsNull()); |
| 305 PcDescriptors::Iterator it(finalized_descriptors, |
| 306 RawPcDescriptors::kRuntimeCall); |
| 307 |
| 308 intptr_t i = 0; |
| 309 while (it.MoveNext()) { |
| 310 if (token_positions[i] != it.TokenPos()) { |
| 311 OS::Print("[%" Pd "]: Expected: %" Pd " != %" Pd "\n", |
| 312 i, token_positions[i], it.TokenPos()); |
| 313 } |
| 314 EXPECT(token_positions[i] == it.TokenPos()); |
| 315 i++; |
| 316 } |
| 317 } |
| 318 |
271 } // namespace dart | 319 } // namespace dart |
OLD | NEW |