| 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 "vm/assembler.h" | 5 #include "vm/assembler.h" |
| 6 #include "vm/bigint_operations.h" | 6 #include "vm/bigint_operations.h" |
| 7 #include "vm/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
| 8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
| (...skipping 2367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2378 EXPECT((retval >> kSmiTagShift) == kSmiTestValue); | 2378 EXPECT((retval >> kSmiTagShift) == kSmiTestValue); |
| 2379 } | 2379 } |
| 2380 #endif // ARCH_IS_64_BIT | 2380 #endif // ARCH_IS_64_BIT |
| 2381 | 2381 |
| 2382 | 2382 |
| 2383 TEST_CASE(ExceptionHandlers) { | 2383 TEST_CASE(ExceptionHandlers) { |
| 2384 const int kNumEntries = 4; | 2384 const int kNumEntries = 4; |
| 2385 // Add an exception handler table to the code. | 2385 // Add an exception handler table to the code. |
| 2386 ExceptionHandlers& exception_handlers = ExceptionHandlers::Handle(); | 2386 ExceptionHandlers& exception_handlers = ExceptionHandlers::Handle(); |
| 2387 exception_handlers ^= ExceptionHandlers::New(kNumEntries); | 2387 exception_handlers ^= ExceptionHandlers::New(kNumEntries); |
| 2388 exception_handlers.SetHandlerInfo(0, -1, 20); | 2388 const bool kNeedsStacktrace = true; |
| 2389 exception_handlers.SetHandlerInfo(1, 0, 30); | 2389 const bool kNoStacktrace = false; |
| 2390 exception_handlers.SetHandlerInfo(2, -1, 40); | 2390 exception_handlers.SetHandlerInfo(0, -1, 20, kNeedsStacktrace); |
| 2391 exception_handlers.SetHandlerInfo(3, 1, 150); | 2391 exception_handlers.SetHandlerInfo(1, 0, 30, kNeedsStacktrace); |
| 2392 exception_handlers.SetHandlerInfo(2, -1, 40, kNoStacktrace); |
| 2393 exception_handlers.SetHandlerInfo(3, 1, 150, kNoStacktrace); |
| 2392 | 2394 |
| 2393 extern void GenerateIncrement(Assembler* assembler); | 2395 extern void GenerateIncrement(Assembler* assembler); |
| 2394 Assembler _assembler_; | 2396 Assembler _assembler_; |
| 2395 GenerateIncrement(&_assembler_); | 2397 GenerateIncrement(&_assembler_); |
| 2396 Code& code = Code::Handle(Code::FinalizeCode( | 2398 Code& code = Code::Handle(Code::FinalizeCode( |
| 2397 *CreateFunction("Test_Code"), &_assembler_)); | 2399 *CreateFunction("Test_Code"), &_assembler_)); |
| 2398 code.set_exception_handlers(exception_handlers); | 2400 code.set_exception_handlers(exception_handlers); |
| 2399 | 2401 |
| 2400 // Verify the exception handler table entries by accessing them. | 2402 // Verify the exception handler table entries by accessing them. |
| 2401 const ExceptionHandlers& handlers = | 2403 const ExceptionHandlers& handlers = |
| 2402 ExceptionHandlers::Handle(code.exception_handlers()); | 2404 ExceptionHandlers::Handle(code.exception_handlers()); |
| 2403 EXPECT_EQ(kNumEntries, handlers.Length()); | 2405 EXPECT_EQ(kNumEntries, handlers.Length()); |
| 2404 RawExceptionHandlers::HandlerInfo info; | 2406 RawExceptionHandlers::HandlerInfo info; |
| 2405 handlers.GetHandlerInfo(0, &info); | 2407 handlers.GetHandlerInfo(0, &info); |
| 2406 EXPECT_EQ(-1, handlers.OuterTryIndex(0)); | 2408 EXPECT_EQ(-1, handlers.OuterTryIndex(0)); |
| 2407 EXPECT_EQ(-1, info.outer_try_index); | 2409 EXPECT_EQ(-1, info.outer_try_index); |
| 2408 EXPECT_EQ(20, handlers.HandlerPC(0)); | 2410 EXPECT_EQ(20, handlers.HandlerPC(0)); |
| 2411 EXPECT(handlers.NeedsStacktrace(0)); |
| 2409 EXPECT_EQ(20, info.handler_pc); | 2412 EXPECT_EQ(20, info.handler_pc); |
| 2410 EXPECT_EQ(1, handlers.OuterTryIndex(3)); | 2413 EXPECT_EQ(1, handlers.OuterTryIndex(3)); |
| 2411 EXPECT_EQ(150, handlers.HandlerPC(3)); | 2414 EXPECT_EQ(150, handlers.HandlerPC(3)); |
| 2415 EXPECT(!handlers.NeedsStacktrace(3)); |
| 2412 } | 2416 } |
| 2413 | 2417 |
| 2414 | 2418 |
| 2415 TEST_CASE(PcDescriptors) { | 2419 TEST_CASE(PcDescriptors) { |
| 2416 const int kNumEntries = 6; | 2420 const int kNumEntries = 6; |
| 2417 // Add PcDescriptors to the code. | 2421 // Add PcDescriptors to the code. |
| 2418 PcDescriptors& descriptors = PcDescriptors::Handle(); | 2422 PcDescriptors& descriptors = PcDescriptors::Handle(); |
| 2419 descriptors ^= PcDescriptors::New(kNumEntries); | 2423 descriptors ^= PcDescriptors::New(kNumEntries); |
| 2420 descriptors.AddDescriptor(0, 10, PcDescriptors::kOther, 1, 20, 1); | 2424 descriptors.AddDescriptor(0, 10, PcDescriptors::kOther, 1, 20, 1); |
| 2421 descriptors.AddDescriptor(1, 20, PcDescriptors::kDeopt, 2, 30, 0); | 2425 descriptors.AddDescriptor(1, 20, PcDescriptors::kDeopt, 2, 30, 0); |
| (...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3446 cls = Object::dynamic_class(); | 3450 cls = Object::dynamic_class(); |
| 3447 array = cls.fields(); | 3451 array = cls.fields(); |
| 3448 EXPECT(!array.IsNull()); | 3452 EXPECT(!array.IsNull()); |
| 3449 EXPECT(array.IsArray()); | 3453 EXPECT(array.IsArray()); |
| 3450 array = cls.functions(); | 3454 array = cls.functions(); |
| 3451 EXPECT(!array.IsNull()); | 3455 EXPECT(!array.IsNull()); |
| 3452 EXPECT(array.IsArray()); | 3456 EXPECT(array.IsArray()); |
| 3453 } | 3457 } |
| 3454 | 3458 |
| 3455 } // namespace dart | 3459 } // namespace dart |
| OLD | NEW |