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/assembler.h" | 6 #include "vm/assembler.h" |
7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
(...skipping 2342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2353 EXPECT_EQ(150, handlers.HandlerPC(3)); | 2353 EXPECT_EQ(150, handlers.HandlerPC(3)); |
2354 } | 2354 } |
2355 | 2355 |
2356 | 2356 |
2357 TEST_CASE(PcDescriptors) { | 2357 TEST_CASE(PcDescriptors) { |
2358 const int kNumEntries = 6; | 2358 const int kNumEntries = 6; |
2359 // Add PcDescriptors to the code. | 2359 // Add PcDescriptors to the code. |
2360 PcDescriptors& descriptors = PcDescriptors::Handle(); | 2360 PcDescriptors& descriptors = PcDescriptors::Handle(); |
2361 descriptors ^= PcDescriptors::New(kNumEntries); | 2361 descriptors ^= PcDescriptors::New(kNumEntries); |
2362 descriptors.AddDescriptor(0, 10, PcDescriptors::kOther, 1, 20, 1); | 2362 descriptors.AddDescriptor(0, 10, PcDescriptors::kOther, 1, 20, 1); |
2363 descriptors.AddDescriptor(1, 20, PcDescriptors::kDeoptBefore, 2, 30, 0); | 2363 descriptors.AddDescriptor(1, 20, PcDescriptors::kDeopt, 2, 30, 0); |
2364 descriptors.AddDescriptor(2, 30, PcDescriptors::kOther, 3, 40, 1); | 2364 descriptors.AddDescriptor(2, 30, PcDescriptors::kOther, 3, 40, 1); |
2365 descriptors.AddDescriptor(3, 10, PcDescriptors::kOther, 4, 40, 2); | 2365 descriptors.AddDescriptor(3, 10, PcDescriptors::kOther, 4, 40, 2); |
2366 descriptors.AddDescriptor(4, 10, PcDescriptors::kOther, 5, 80, 3); | 2366 descriptors.AddDescriptor(4, 10, PcDescriptors::kOther, 5, 80, 3); |
2367 descriptors.AddDescriptor(5, 80, PcDescriptors::kOther, 6, 150, 3); | 2367 descriptors.AddDescriptor(5, 80, PcDescriptors::kOther, 6, 150, 3); |
2368 | 2368 |
2369 extern void GenerateIncrement(Assembler* assembler); | 2369 extern void GenerateIncrement(Assembler* assembler); |
2370 Assembler _assembler_; | 2370 Assembler _assembler_; |
2371 GenerateIncrement(&_assembler_); | 2371 GenerateIncrement(&_assembler_); |
2372 Code& code = Code::Handle(Code::FinalizeCode( | 2372 Code& code = Code::Handle(Code::FinalizeCode( |
2373 *CreateFunction("Test_Code"), &_assembler_)); | 2373 *CreateFunction("Test_Code"), &_assembler_)); |
2374 code.set_pc_descriptors(descriptors); | 2374 code.set_pc_descriptors(descriptors); |
2375 | 2375 |
2376 // Verify the PcDescriptor entries by accessing them. | 2376 // Verify the PcDescriptor entries by accessing them. |
2377 const PcDescriptors& pc_descs = PcDescriptors::Handle(code.pc_descriptors()); | 2377 const PcDescriptors& pc_descs = PcDescriptors::Handle(code.pc_descriptors()); |
2378 EXPECT_EQ(kNumEntries, pc_descs.Length()); | 2378 EXPECT_EQ(kNumEntries, pc_descs.Length()); |
2379 EXPECT_EQ(1, pc_descs.TryIndex(0)); | 2379 EXPECT_EQ(1, pc_descs.TryIndex(0)); |
2380 EXPECT_EQ(static_cast<uword>(10), pc_descs.PC(0)); | 2380 EXPECT_EQ(static_cast<uword>(10), pc_descs.PC(0)); |
2381 EXPECT_EQ(1, pc_descs.DeoptId(0)); | 2381 EXPECT_EQ(1, pc_descs.DeoptId(0)); |
2382 EXPECT_EQ(20, pc_descs.TokenPos(0)); | 2382 EXPECT_EQ(20, pc_descs.TokenPos(0)); |
2383 EXPECT_EQ(3, pc_descs.TryIndex(5)); | 2383 EXPECT_EQ(3, pc_descs.TryIndex(5)); |
2384 EXPECT_EQ(static_cast<uword>(80), pc_descs.PC(5)); | 2384 EXPECT_EQ(static_cast<uword>(80), pc_descs.PC(5)); |
2385 EXPECT_EQ(150, pc_descs.TokenPos(5)); | 2385 EXPECT_EQ(150, pc_descs.TokenPos(5)); |
2386 EXPECT_EQ(PcDescriptors::kOther, pc_descs.DescriptorKind(0)); | 2386 EXPECT_EQ(PcDescriptors::kOther, pc_descs.DescriptorKind(0)); |
2387 EXPECT_EQ(PcDescriptors::kDeoptBefore, pc_descs.DescriptorKind(1)); | 2387 EXPECT_EQ(PcDescriptors::kDeopt, pc_descs.DescriptorKind(1)); |
2388 } | 2388 } |
2389 | 2389 |
2390 | 2390 |
2391 static RawClass* CreateTestClass(const char* name) { | 2391 static RawClass* CreateTestClass(const char* name) { |
2392 const String& class_name = String::Handle(Symbols::New(name)); | 2392 const String& class_name = String::Handle(Symbols::New(name)); |
2393 const Class& cls = Class::Handle( | 2393 const Class& cls = Class::Handle( |
2394 Class::New(class_name, Script::Handle(), Scanner::kDummyTokenIndex)); | 2394 Class::New(class_name, Script::Handle(), Scanner::kDummyTokenIndex)); |
2395 return cls.raw(); | 2395 return cls.raw(); |
2396 } | 2396 } |
2397 | 2397 |
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3178 EXPECT_NE(test1.SourceFingerprint(), test3.SourceFingerprint()); | 3178 EXPECT_NE(test1.SourceFingerprint(), test3.SourceFingerprint()); |
3179 EXPECT_NE(test3.SourceFingerprint(), test4.SourceFingerprint()); | 3179 EXPECT_NE(test3.SourceFingerprint(), test4.SourceFingerprint()); |
3180 EXPECT_NE(test4.SourceFingerprint(), test5.SourceFingerprint()); | 3180 EXPECT_NE(test4.SourceFingerprint(), test5.SourceFingerprint()); |
3181 EXPECT_NE(test5.SourceFingerprint(), test6.SourceFingerprint()); | 3181 EXPECT_NE(test5.SourceFingerprint(), test6.SourceFingerprint()); |
3182 EXPECT_EQ(test6.SourceFingerprint(), test7.SourceFingerprint()); | 3182 EXPECT_EQ(test6.SourceFingerprint(), test7.SourceFingerprint()); |
3183 } | 3183 } |
3184 | 3184 |
3185 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 3185 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
3186 | 3186 |
3187 } // namespace dart | 3187 } // namespace dart |
OLD | NEW |