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

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

Issue 868103002: VM: Use PC offset instead of absolute PC in exception handler info. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 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
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/globals.h" 5 #include "platform/globals.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 2715 matching lines...) Expand 10 before | Expand all | Expand 10 after
2726 #endif // ARCH_IS_64_BIT 2726 #endif // ARCH_IS_64_BIT
2727 2727
2728 2728
2729 TEST_CASE(ExceptionHandlers) { 2729 TEST_CASE(ExceptionHandlers) {
2730 const int kNumEntries = 4; 2730 const int kNumEntries = 4;
2731 // Add an exception handler table to the code. 2731 // Add an exception handler table to the code.
2732 ExceptionHandlers& exception_handlers = ExceptionHandlers::Handle(); 2732 ExceptionHandlers& exception_handlers = ExceptionHandlers::Handle();
2733 exception_handlers ^= ExceptionHandlers::New(kNumEntries); 2733 exception_handlers ^= ExceptionHandlers::New(kNumEntries);
2734 const bool kNeedsStacktrace = true; 2734 const bool kNeedsStacktrace = true;
2735 const bool kNoStacktrace = false; 2735 const bool kNoStacktrace = false;
2736 exception_handlers.SetHandlerInfo(0, -1, 20, kNeedsStacktrace, false); 2736 exception_handlers.SetHandlerInfo(0, -1, 20u, kNeedsStacktrace, false);
2737 exception_handlers.SetHandlerInfo(1, 0, 30, kNeedsStacktrace, false); 2737 exception_handlers.SetHandlerInfo(1, 0, 30u, kNeedsStacktrace, false);
2738 exception_handlers.SetHandlerInfo(2, -1, 40, kNoStacktrace, true); 2738 exception_handlers.SetHandlerInfo(2, -1, 40u, kNoStacktrace, true);
2739 exception_handlers.SetHandlerInfo(3, 1, 150, kNoStacktrace, true); 2739 exception_handlers.SetHandlerInfo(3, 1, 150u, kNoStacktrace, true);
2740 2740
2741 extern void GenerateIncrement(Assembler* assembler); 2741 extern void GenerateIncrement(Assembler* assembler);
2742 Assembler _assembler_; 2742 Assembler _assembler_;
2743 GenerateIncrement(&_assembler_); 2743 GenerateIncrement(&_assembler_);
2744 Code& code = Code::Handle(Code::FinalizeCode( 2744 Code& code = Code::Handle(Code::FinalizeCode(
2745 *CreateFunction("Test_Code"), &_assembler_)); 2745 *CreateFunction("Test_Code"), &_assembler_));
2746 code.set_exception_handlers(exception_handlers); 2746 code.set_exception_handlers(exception_handlers);
2747 2747
2748 // Verify the exception handler table entries by accessing them. 2748 // Verify the exception handler table entries by accessing them.
2749 const ExceptionHandlers& handlers = 2749 const ExceptionHandlers& handlers =
2750 ExceptionHandlers::Handle(code.exception_handlers()); 2750 ExceptionHandlers::Handle(code.exception_handlers());
2751 EXPECT_EQ(kNumEntries, handlers.num_entries()); 2751 EXPECT_EQ(kNumEntries, handlers.num_entries());
2752 RawExceptionHandlers::HandlerInfo info; 2752 RawExceptionHandlers::HandlerInfo info;
2753 handlers.GetHandlerInfo(0, &info); 2753 handlers.GetHandlerInfo(0, &info);
2754 EXPECT_EQ(-1, handlers.OuterTryIndex(0)); 2754 EXPECT_EQ(-1, handlers.OuterTryIndex(0));
2755 EXPECT_EQ(-1, info.outer_try_index); 2755 EXPECT_EQ(-1, info.outer_try_index);
2756 EXPECT_EQ(20, handlers.HandlerPC(0)); 2756 EXPECT_EQ(20u, handlers.HandlerPCOffset(0));
2757 EXPECT(handlers.NeedsStacktrace(0)); 2757 EXPECT(handlers.NeedsStacktrace(0));
2758 EXPECT(!handlers.HasCatchAll(0)); 2758 EXPECT(!handlers.HasCatchAll(0));
2759 EXPECT_EQ(20, info.handler_pc); 2759 EXPECT_EQ(20u, info.handler_pc_offset);
2760 EXPECT_EQ(1, handlers.OuterTryIndex(3)); 2760 EXPECT_EQ(1, handlers.OuterTryIndex(3));
2761 EXPECT_EQ(150, handlers.HandlerPC(3)); 2761 EXPECT_EQ(150u, handlers.HandlerPCOffset(3));
2762 EXPECT(!handlers.NeedsStacktrace(3)); 2762 EXPECT(!handlers.NeedsStacktrace(3));
2763 EXPECT(handlers.HasCatchAll(3)); 2763 EXPECT(handlers.HasCatchAll(3));
2764 } 2764 }
2765 2765
2766 2766
2767 TEST_CASE(PcDescriptors) { 2767 TEST_CASE(PcDescriptors) {
2768 const int kNumEntries = 6; 2768 const int kNumEntries = 6;
2769 // Add PcDescriptors to the code. 2769 // Add PcDescriptors to the code.
2770 PcDescriptors& descriptors = PcDescriptors::Handle(); 2770 PcDescriptors& descriptors = PcDescriptors::Handle();
2771 descriptors ^= PcDescriptors::New(kNumEntries, true); 2771 descriptors ^= PcDescriptors::New(kNumEntries, true);
(...skipping 1706 matching lines...) Expand 10 before | Expand all | Expand 10 after
4478 EXPECT_VALID(h_result); 4478 EXPECT_VALID(h_result);
4479 Integer& result = Integer::Handle(); 4479 Integer& result = Integer::Handle();
4480 result ^= Api::UnwrapHandle(h_result); 4480 result ^= Api::UnwrapHandle(h_result);
4481 String& foo = String::Handle(String::New("foo")); 4481 String& foo = String::Handle(String::New("foo"));
4482 Integer& expected = Integer::Handle(); 4482 Integer& expected = Integer::Handle();
4483 expected ^= foo.HashCode(); 4483 expected ^= foo.HashCode();
4484 EXPECT(result.IsIdenticalTo(expected)); 4484 EXPECT(result.IsIdenticalTo(expected));
4485 } 4485 }
4486 4486
4487 } // namespace dart 4487 } // namespace dart
OLDNEW
« runtime/vm/object.cc ('K') | « 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