| 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/debugger.h" | 10 #include "vm/debugger.h" |
| 11 #include "vm/isolate.h" | 11 #include "vm/isolate.h" |
| 12 #include "vm/object.h" | 12 #include "vm/object.h" |
| 13 #include "vm/object_store.h" | 13 #include "vm/object_store.h" |
| 14 #include "vm/simulator.h" | 14 #include "vm/simulator.h" |
| 15 #include "vm/symbols.h" | 15 #include "vm/symbols.h" |
| 16 #include "vm/unit_test.h" | 16 #include "vm/unit_test.h" |
| 17 | 17 |
| 18 namespace dart { | 18 namespace dart { |
| 19 | 19 |
| 20 DECLARE_FLAG(bool, write_protect_code); |
| 21 |
| 20 static RawLibrary* CreateDummyLibrary(const String& library_name) { | 22 static RawLibrary* CreateDummyLibrary(const String& library_name) { |
| 21 return Library::New(library_name); | 23 return Library::New(library_name); |
| 22 } | 24 } |
| 23 | 25 |
| 24 | 26 |
| 25 static RawClass* CreateDummyClass(const String& class_name, | 27 static RawClass* CreateDummyClass(const String& class_name, |
| 26 const Script& script) { | 28 const Script& script) { |
| 27 const Class& cls = Class::Handle( | 29 const Class& cls = Class::Handle( |
| 28 Class::New(class_name, script, Scanner::kNoSourcePos)); | 30 Class::New(class_name, script, Scanner::kNoSourcePos)); |
| 29 cls.set_is_synthesized_class(); // Dummy class for testing. | 31 cls.set_is_synthesized_class(); // Dummy class for testing. |
| (...skipping 2449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2479 intptr_t retval = 0; | 2481 intptr_t retval = 0; |
| 2480 #if defined(USING_SIMULATOR) | 2482 #if defined(USING_SIMULATOR) |
| 2481 retval = bit_copy<intptr_t, int64_t>(Simulator::Current()->Call( | 2483 retval = bit_copy<intptr_t, int64_t>(Simulator::Current()->Call( |
| 2482 static_cast<int32_t>(entry_point), 0, 0, 0, 0)); | 2484 static_cast<int32_t>(entry_point), 0, 0, 0, 0)); |
| 2483 #else | 2485 #else |
| 2484 typedef intptr_t (*IncrementCode)(); | 2486 typedef intptr_t (*IncrementCode)(); |
| 2485 retval = reinterpret_cast<IncrementCode>(entry_point)(); | 2487 retval = reinterpret_cast<IncrementCode>(entry_point)(); |
| 2486 #endif | 2488 #endif |
| 2487 EXPECT_EQ(3, retval); | 2489 EXPECT_EQ(3, retval); |
| 2488 EXPECT_EQ(instructions.raw(), Instructions::FromEntryPoint(entry_point)); | 2490 EXPECT_EQ(instructions.raw(), Instructions::FromEntryPoint(entry_point)); |
| 2491 if (!FLAG_write_protect_code) { |
| 2492 // Since this test is expected to crash, crash if write protection of code |
| 2493 // is switched off. |
| 2494 OS::DebugBreak(); |
| 2495 } |
| 2489 } | 2496 } |
| 2490 | 2497 |
| 2491 | 2498 |
| 2492 // Test for Embedded String object in the instructions. | 2499 // Test for Embedded String object in the instructions. |
| 2493 TEST_CASE(EmbedStringInCode) { | 2500 TEST_CASE(EmbedStringInCode) { |
| 2494 extern void GenerateEmbedStringInCode(Assembler* assembler, const char* str); | 2501 extern void GenerateEmbedStringInCode(Assembler* assembler, const char* str); |
| 2495 const char* kHello = "Hello World!"; | 2502 const char* kHello = "Hello World!"; |
| 2496 word expected_length = static_cast<word>(strlen(kHello)); | 2503 word expected_length = static_cast<word>(strlen(kHello)); |
| 2497 Assembler _assembler_; | 2504 Assembler _assembler_; |
| 2498 GenerateEmbedStringInCode(&_assembler_, kHello); | 2505 GenerateEmbedStringInCode(&_assembler_, kHello); |
| (...skipping 1508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4007 // Simple map. | 4014 // Simple map. |
| 4008 // | 4015 // |
| 4009 // TODO(turnidge): Consider showing something like: {1: 2, 2: 'otter'} | 4016 // TODO(turnidge): Consider showing something like: {1: 2, 2: 'otter'} |
| 4010 result = Dart_GetField(lib, NewString("simple_map")); | 4017 result = Dart_GetField(lib, NewString("simple_map")); |
| 4011 EXPECT_VALID(result); | 4018 EXPECT_VALID(result); |
| 4012 obj ^= Api::UnwrapHandle(result); | 4019 obj ^= Api::UnwrapHandle(result); |
| 4013 EXPECT_STREQ("Instance of '_LinkedHashMap'", obj.ToUserCString()); | 4020 EXPECT_STREQ("Instance of '_LinkedHashMap'", obj.ToUserCString()); |
| 4014 } | 4021 } |
| 4015 | 4022 |
| 4016 } // namespace dart | 4023 } // namespace dart |
| OLD | NEW |