| 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/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/code_generator.h" | 9 #include "vm/code_generator.h" |
| 10 #include "vm/code_patcher.h" | 10 #include "vm/code_patcher.h" |
| 11 #include "vm/dart_entry.h" | 11 #include "vm/dart_entry.h" |
| 12 #include "vm/ic_data.h" | 12 #include "vm/ic_data.h" |
| 13 #include "vm/instructions.h" | 13 #include "vm/instructions.h" |
| 14 #include "vm/native_entry.h" | 14 #include "vm/native_entry.h" |
| 15 #include "vm/native_entry_test.h" | 15 #include "vm/native_entry_test.h" |
| 16 #include "vm/stub_code.h" | 16 #include "vm/stub_code.h" |
| 17 #include "vm/unit_test.h" | 17 #include "vm/unit_test.h" |
| 18 | 18 |
| 19 namespace dart { | 19 namespace dart { |
| 20 | 20 |
| 21 static const intptr_t kPos = 1; // Dummy token index in non-existing source. | |
| 22 | |
| 23 CODEGEN_TEST_GENERATE(NativePatchStaticCall, test) { | 21 CODEGEN_TEST_GENERATE(NativePatchStaticCall, test) { |
| 24 SequenceNode* node_seq = test->node_sequence(); | 22 SequenceNode* node_seq = test->node_sequence(); |
| 25 const int num_params = 0; | 23 const int num_params = 0; |
| 26 const bool has_opt_params = false; | 24 const bool has_opt_params = false; |
| 27 const String& native_name = | 25 const String& native_name = |
| 28 String::ZoneHandle(String::NewSymbol("TestStaticCallPatching")); | 26 String::ZoneHandle(String::NewSymbol("TestStaticCallPatching")); |
| 29 NativeFunction native_function = reinterpret_cast<NativeFunction>( | 27 NativeFunction native_function = reinterpret_cast<NativeFunction>( |
| 30 NATIVE_ENTRY_FUNCTION(TestStaticCallPatching)); | 28 NATIVE_ENTRY_FUNCTION(TestStaticCallPatching)); |
| 31 node_seq->Add(new ReturnNode(kPos, | 29 node_seq->Add(new ReturnNode(Scanner::kDummyTokenIndex, |
| 32 new NativeBodyNode(kPos, | 30 new NativeBodyNode(Scanner::kDummyTokenIndex, |
| 33 native_name, | 31 native_name, |
| 34 native_function, | 32 native_function, |
| 35 num_params, | 33 num_params, |
| 36 has_opt_params))); | 34 has_opt_params))); |
| 37 } | 35 } |
| 38 | 36 |
| 39 CODEGEN_TEST2_GENERATE(PatchStaticCall, function, test) { | 37 CODEGEN_TEST2_GENERATE(PatchStaticCall, function, test) { |
| 40 SequenceNode* node_seq = test->node_sequence(); | 38 SequenceNode* node_seq = test->node_sequence(); |
| 41 ArgumentListNode* arguments = new ArgumentListNode(kPos); | 39 ArgumentListNode* arguments = new ArgumentListNode(Scanner::kDummyTokenIndex); |
| 42 node_seq->Add(new ReturnNode(kPos, | 40 node_seq->Add(new ReturnNode(Scanner::kDummyTokenIndex, |
| 43 new StaticCallNode(kPos, function, arguments))); | 41 new StaticCallNode(Scanner::kDummyTokenIndex, |
| 42 function, arguments))); |
| 44 } | 43 } |
| 45 | 44 |
| 46 CODEGEN_TEST2_RUN(PatchStaticCall, NativePatchStaticCall, Instance::null()); | 45 CODEGEN_TEST2_RUN(PatchStaticCall, NativePatchStaticCall, Instance::null()); |
| 47 | 46 |
| 48 #define __ assembler-> | 47 #define __ assembler-> |
| 49 | 48 |
| 50 ASSEMBLER_TEST_GENERATE(IcDataAccess, assembler) { | 49 ASSEMBLER_TEST_GENERATE(IcDataAccess, assembler) { |
| 51 const String& function_name = String::Handle(String::New("Vermicelles")); | 50 const String& function_name = String::Handle(String::New("Vermicelles")); |
| 52 ICData ic_data(function_name, 1); | 51 ICData ic_data(function_name, 1); |
| 53 EXPECT(!Array::Handle(ic_data.data()).IsNull()); | 52 EXPECT(!Array::Handle(ic_data.data()).IsNull()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 77 Array::ZoneHandle(new_ic_data.data())); | 76 Array::ZoneHandle(new_ic_data.data())); |
| 78 const Array& new_array = Array::Handle( | 77 const Array& new_array = Array::Handle( |
| 79 CodePatcher::GetInstanceCallIcDataAt(return_address)); | 78 CodePatcher::GetInstanceCallIcDataAt(return_address)); |
| 80 ICData test_ic_data(new_array); | 79 ICData test_ic_data(new_array); |
| 81 EXPECT_STREQ("Rigi", String::Handle(test_ic_data.FunctionName()).ToCString()); | 80 EXPECT_STREQ("Rigi", String::Handle(test_ic_data.FunctionName()).ToCString()); |
| 82 } | 81 } |
| 83 | 82 |
| 84 } // namespace dart | 83 } // namespace dart |
| 85 | 84 |
| 86 #endif // TARGET_ARCH_IA32 | 85 #endif // TARGET_ARCH_IA32 |
| OLD | NEW |