OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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/assert.h" | 5 #include "vm/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/isolate.h" | 8 #include "vm/isolate.h" |
9 #include "vm/object.h" | 9 #include "vm/object.h" |
10 #include "vm/object_store.h" | 10 #include "vm/object_store.h" |
(...skipping 2047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2058 EXPECT(!str3.IsOneByteString()); | 2058 EXPECT(!str3.IsOneByteString()); |
2059 str3 = String::New("Steep and Deep!"); | 2059 str3 = String::New("Steep and Deep!"); |
2060 EXPECT(str3.IsString()); | 2060 EXPECT(str3.IsString()); |
2061 EXPECT(str3.IsOneByteString()); | 2061 EXPECT(str3.IsOneByteString()); |
2062 str3 = OneByteString::null(); | 2062 str3 = OneByteString::null(); |
2063 EXPECT(str3.IsString()); | 2063 EXPECT(str3.IsString()); |
2064 EXPECT(!str3.IsOneByteString()); | 2064 EXPECT(!str3.IsOneByteString()); |
2065 } | 2065 } |
2066 | 2066 |
2067 | 2067 |
2068 #if defined(TARGET_ARCH_IA32) // only ia32 can run execution tests. | 2068 // only ia32 and x64 can run execution tests. |
| 2069 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
2069 // Test for Code and Instruction object creation. | 2070 // Test for Code and Instruction object creation. |
2070 TEST_CASE(Code) { | 2071 TEST_CASE(Code) { |
2071 extern void GenerateIncrement(Assembler* assembler); | 2072 extern void GenerateIncrement(Assembler* assembler); |
2072 Assembler _assembler_; | 2073 Assembler _assembler_; |
2073 GenerateIncrement(&_assembler_); | 2074 GenerateIncrement(&_assembler_); |
2074 Code& code = Code::Handle(Code::FinalizeCode("Test_Code", &_assembler_)); | 2075 Code& code = Code::Handle(Code::FinalizeCode("Test_Code", &_assembler_)); |
2075 Instructions& instructions = Instructions::Handle(code.instructions()); | 2076 Instructions& instructions = Instructions::Handle(code.instructions()); |
2076 typedef int (*IncrementCode)(); | 2077 typedef int (*IncrementCode)(); |
2077 EXPECT_EQ(2, reinterpret_cast<IncrementCode>(instructions.EntryPoint())()); | 2078 EXPECT_EQ(2, reinterpret_cast<IncrementCode>(instructions.EntryPoint())()); |
2078 uword entry_point = instructions.EntryPoint(); | 2079 uword entry_point = instructions.EntryPoint(); |
(...skipping 18 matching lines...) Expand all Loading... |
2097 string_object ^= reinterpret_cast<RawInstructions*>(retval); | 2098 string_object ^= reinterpret_cast<RawInstructions*>(retval); |
2098 EXPECT(string_object.Length() == expected_length); | 2099 EXPECT(string_object.Length() == expected_length); |
2099 for (int i = 0; i < expected_length; i ++) { | 2100 for (int i = 0; i < expected_length; i ++) { |
2100 EXPECT(string_object.CharAt(i) == kHello[i]); | 2101 EXPECT(string_object.CharAt(i) == kHello[i]); |
2101 } | 2102 } |
2102 } | 2103 } |
2103 | 2104 |
2104 | 2105 |
2105 // Test for Embedded Smi object in the instructions. | 2106 // Test for Embedded Smi object in the instructions. |
2106 TEST_CASE(EmbedSmiInCode) { | 2107 TEST_CASE(EmbedSmiInCode) { |
2107 extern void GenerateEmbedSmiInCode(Assembler* assembler, int value); | 2108 extern void GenerateEmbedSmiInCode(Assembler* assembler, intptr_t value); |
2108 const int kSmiTestValue = 5; | 2109 const intptr_t kSmiTestValue = 5; |
2109 Assembler _assembler_; | 2110 Assembler _assembler_; |
2110 GenerateEmbedSmiInCode(&_assembler_, kSmiTestValue); | 2111 GenerateEmbedSmiInCode(&_assembler_, kSmiTestValue); |
2111 Code& code = Code::Handle( | 2112 Code& code = Code::Handle( |
2112 Code::FinalizeCode("Test_EmbedSmiInCode", &_assembler_)); | 2113 Code::FinalizeCode("Test_EmbedSmiInCode", &_assembler_)); |
2113 Instructions& instructions = Instructions::Handle(code.instructions()); | 2114 Instructions& instructions = Instructions::Handle(code.instructions()); |
2114 typedef intptr_t (*EmbedSmiCode)(); | 2115 typedef intptr_t (*EmbedSmiCode)(); |
2115 intptr_t retval = | 2116 intptr_t retval = |
2116 reinterpret_cast<EmbedSmiCode>(instructions.EntryPoint())(); | 2117 reinterpret_cast<EmbedSmiCode>(instructions.EntryPoint())(); |
2117 EXPECT((retval >> kSmiTagShift) == kSmiTestValue); | 2118 EXPECT((retval >> kSmiTagShift) == kSmiTestValue); |
2118 } | 2119 } |
2119 | 2120 |
2120 | 2121 |
| 2122 #if defined(ARCH_IS_64_BIT) |
| 2123 // Test for Embedded Smi object in the instructions. |
| 2124 TEST_CASE(EmbedSmiIn64BitCode) { |
| 2125 extern void GenerateEmbedSmiInCode(Assembler* assembler, intptr_t value); |
| 2126 const intptr_t kSmiTestValue = 5L << 32; |
| 2127 Assembler _assembler_; |
| 2128 GenerateEmbedSmiInCode(&_assembler_, kSmiTestValue); |
| 2129 Code& code = Code::Handle( |
| 2130 Code::FinalizeCode("Test_EmbedSmiIn64BitCode", &_assembler_)); |
| 2131 Instructions& instructions = Instructions::Handle(code.instructions()); |
| 2132 typedef intptr_t (*EmbedSmiCode)(); |
| 2133 intptr_t retval = |
| 2134 reinterpret_cast<EmbedSmiCode>(instructions.EntryPoint())(); |
| 2135 EXPECT((retval >> kSmiTagShift) == kSmiTestValue); |
| 2136 } |
| 2137 #endif |
| 2138 |
| 2139 |
2121 TEST_CASE(ExceptionHandlers) { | 2140 TEST_CASE(ExceptionHandlers) { |
2122 const int kNumEntries = 6; | 2141 const int kNumEntries = 6; |
2123 // Add an exception handler table to the code. | 2142 // Add an exception handler table to the code. |
2124 ExceptionHandlers& exception_handlers = ExceptionHandlers::Handle(); | 2143 ExceptionHandlers& exception_handlers = ExceptionHandlers::Handle(); |
2125 exception_handlers ^= ExceptionHandlers::New(kNumEntries); | 2144 exception_handlers ^= ExceptionHandlers::New(kNumEntries); |
2126 exception_handlers.SetHandlerEntry(0, 10, 20); | 2145 exception_handlers.SetHandlerEntry(0, 10, 20); |
2127 exception_handlers.SetHandlerEntry(1, 20, 30); | 2146 exception_handlers.SetHandlerEntry(1, 20, 30); |
2128 exception_handlers.SetHandlerEntry(2, 30, 40); | 2147 exception_handlers.SetHandlerEntry(2, 30, 40); |
2129 exception_handlers.SetHandlerEntry(3, 10, 40); | 2148 exception_handlers.SetHandlerEntry(3, 10, 40); |
2130 exception_handlers.SetHandlerEntry(4, 10, 80); | 2149 exception_handlers.SetHandlerEntry(4, 10, 80); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2211 int count = 0; | 2230 int count = 0; |
2212 Class& cls = Class::Handle(); | 2231 Class& cls = Class::Handle(); |
2213 while (iterator.HasNext()) { | 2232 while (iterator.HasNext()) { |
2214 cls = iterator.GetNextClass(); | 2233 cls = iterator.GetNextClass(); |
2215 ASSERT((cls.raw() == ae66.raw()) || (cls.raw() == re44.raw())); | 2234 ASSERT((cls.raw() == ae66.raw()) || (cls.raw() == re44.raw())); |
2216 count++; | 2235 count++; |
2217 } | 2236 } |
2218 ASSERT(count == 2); | 2237 ASSERT(count == 2); |
2219 } | 2238 } |
2220 | 2239 |
2221 #endif // TARGET_ARCH_IA32. | 2240 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
2222 | 2241 |
2223 } // namespace dart | 2242 } // namespace dart |
OLD | NEW |