Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1468)

Side by Side Diff: runtime/vm/object_test.cc

Issue 11970024: Simplify exception handler table (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2713 matching lines...) Expand 10 before | Expand all | Expand 10 after
2724 Instructions& instructions = Instructions::Handle(code.instructions()); 2724 Instructions& instructions = Instructions::Handle(code.instructions());
2725 typedef intptr_t (*EmbedSmiCode)(); 2725 typedef intptr_t (*EmbedSmiCode)();
2726 intptr_t retval = 2726 intptr_t retval =
2727 reinterpret_cast<EmbedSmiCode>(instructions.EntryPoint())(); 2727 reinterpret_cast<EmbedSmiCode>(instructions.EntryPoint())();
2728 EXPECT((retval >> kSmiTagShift) == kSmiTestValue); 2728 EXPECT((retval >> kSmiTagShift) == kSmiTestValue);
2729 } 2729 }
2730 #endif 2730 #endif
2731 2731
2732 2732
2733 TEST_CASE(ExceptionHandlers) { 2733 TEST_CASE(ExceptionHandlers) {
2734 const int kNumEntries = 6; 2734 const int kNumEntries = 4;
2735 // Add an exception handler table to the code. 2735 // Add an exception handler table to the code.
2736 ExceptionHandlers& exception_handlers = ExceptionHandlers::Handle(); 2736 ExceptionHandlers& exception_handlers = ExceptionHandlers::Handle();
2737 exception_handlers ^= ExceptionHandlers::New(kNumEntries); 2737 exception_handlers ^= ExceptionHandlers::New(kNumEntries);
2738 exception_handlers.SetHandlerInfo(0, 10, -1, 20); 2738 exception_handlers.SetHandlerInfo(0, -1, 20);
2739 exception_handlers.SetHandlerInfo(1, 20, 25, 30); 2739 exception_handlers.SetHandlerInfo(1, 0, 30);
2740 exception_handlers.SetHandlerInfo(2, 30, 35, 40); 2740 exception_handlers.SetHandlerInfo(2, -1, 40);
2741 exception_handlers.SetHandlerInfo(3, 10, 15, 40); 2741 exception_handlers.SetHandlerInfo(3, 1, 150);
2742 exception_handlers.SetHandlerInfo(4, 10, 15, 80);
2743 exception_handlers.SetHandlerInfo(5, 80, 1, 150);
2744 2742
2745 extern void GenerateIncrement(Assembler* assembler); 2743 extern void GenerateIncrement(Assembler* assembler);
2746 Assembler _assembler_; 2744 Assembler _assembler_;
2747 GenerateIncrement(&_assembler_); 2745 GenerateIncrement(&_assembler_);
2748 Code& code = Code::Handle(Code::FinalizeCode( 2746 Code& code = Code::Handle(Code::FinalizeCode(
2749 *CreateFunction("Test_Code"), &_assembler_)); 2747 *CreateFunction("Test_Code"), &_assembler_));
2750 code.set_exception_handlers(exception_handlers); 2748 code.set_exception_handlers(exception_handlers);
2751 2749
2752 // Verify the exception handler table entries by accessing them. 2750 // Verify the exception handler table entries by accessing them.
2753 const ExceptionHandlers& handlers = 2751 const ExceptionHandlers& handlers =
2754 ExceptionHandlers::Handle(code.exception_handlers()); 2752 ExceptionHandlers::Handle(code.exception_handlers());
2755 EXPECT_EQ(kNumEntries, handlers.Length()); 2753 EXPECT_EQ(kNumEntries, handlers.Length());
2756 RawExceptionHandlers::HandlerInfo info; 2754 RawExceptionHandlers::HandlerInfo info;
2757 handlers.GetHandlerInfo(0, &info); 2755 handlers.GetHandlerInfo(0, &info);
2758 EXPECT_EQ(10, handlers.TryIndex(0)); 2756 EXPECT_EQ(-1, handlers.OuterTryIndex(0));
2759 EXPECT_EQ(10, info.try_index);
2760 EXPECT_EQ(-1, info.outer_try_index); 2757 EXPECT_EQ(-1, info.outer_try_index);
2761 EXPECT_EQ(20, handlers.HandlerPC(0)); 2758 EXPECT_EQ(20, handlers.HandlerPC(0));
2762 EXPECT_EQ(20, info.handler_pc); 2759 EXPECT_EQ(20, info.handler_pc);
2763 EXPECT_EQ(80, handlers.TryIndex(5)); 2760 EXPECT_EQ(1, handlers.OuterTryIndex(3));
2764 EXPECT_EQ(150, handlers.HandlerPC(5)); 2761 EXPECT_EQ(150, handlers.HandlerPC(3));
2765 } 2762 }
2766 2763
2767 2764
2768 TEST_CASE(PcDescriptors) { 2765 TEST_CASE(PcDescriptors) {
2769 const int kNumEntries = 6; 2766 const int kNumEntries = 6;
2770 // Add PcDescriptors to the code. 2767 // Add PcDescriptors to the code.
2771 PcDescriptors& descriptors = PcDescriptors::Handle(); 2768 PcDescriptors& descriptors = PcDescriptors::Handle();
2772 descriptors ^= PcDescriptors::New(kNumEntries); 2769 descriptors ^= PcDescriptors::New(kNumEntries);
2773 descriptors.AddDescriptor(0, 10, PcDescriptors::kOther, 1, 20, 1); 2770 descriptors.AddDescriptor(0, 10, PcDescriptors::kOther, 1, 20, 1);
2774 descriptors.AddDescriptor(1, 20, PcDescriptors::kDeoptBefore, 2, 30, 0); 2771 descriptors.AddDescriptor(1, 20, PcDescriptors::kDeoptBefore, 2, 30, 0);
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
3556 EXPECT_NE(test1.SourceFingerprint(), test3.SourceFingerprint()); 3553 EXPECT_NE(test1.SourceFingerprint(), test3.SourceFingerprint());
3557 EXPECT_NE(test3.SourceFingerprint(), test4.SourceFingerprint()); 3554 EXPECT_NE(test3.SourceFingerprint(), test4.SourceFingerprint());
3558 EXPECT_NE(test4.SourceFingerprint(), test5.SourceFingerprint()); 3555 EXPECT_NE(test4.SourceFingerprint(), test5.SourceFingerprint());
3559 EXPECT_NE(test5.SourceFingerprint(), test6.SourceFingerprint()); 3556 EXPECT_NE(test5.SourceFingerprint(), test6.SourceFingerprint());
3560 EXPECT_EQ(test6.SourceFingerprint(), test7.SourceFingerprint()); 3557 EXPECT_EQ(test6.SourceFingerprint(), test7.SourceFingerprint());
3561 } 3558 }
3562 3559
3563 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 3560 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
3564 3561
3565 } // namespace dart 3562 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698