| 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/instructions.h" | 12 #include "vm/instructions.h" |
| 13 #include "vm/native_entry.h" | 13 #include "vm/native_entry.h" |
| 14 #include "vm/native_entry_test.h" | 14 #include "vm/native_entry_test.h" |
| 15 #include "vm/stub_code.h" | 15 #include "vm/stub_code.h" |
| 16 #include "vm/symbols.h" |
| 16 #include "vm/unit_test.h" | 17 #include "vm/unit_test.h" |
| 17 | 18 |
| 18 namespace dart { | 19 namespace dart { |
| 19 | 20 |
| 20 CODEGEN_TEST_GENERATE(NativePatchStaticCall, test) { | 21 CODEGEN_TEST_GENERATE(NativePatchStaticCall, test) { |
| 21 SequenceNode* node_seq = test->node_sequence(); | 22 SequenceNode* node_seq = test->node_sequence(); |
| 22 const int num_params = 0; | 23 const int num_params = 0; |
| 23 const bool has_opt_params = false; | 24 const bool has_opt_params = false; |
| 24 const String& native_name = | 25 const String& native_name = |
| 25 String::ZoneHandle(String::NewSymbol("TestStaticCallPatching")); | 26 String::ZoneHandle(Symbols::New("TestStaticCallPatching")); |
| 26 NativeFunction native_function = reinterpret_cast<NativeFunction>( | 27 NativeFunction native_function = reinterpret_cast<NativeFunction>( |
| 27 NATIVE_ENTRY_FUNCTION(TestStaticCallPatching)); | 28 NATIVE_ENTRY_FUNCTION(TestStaticCallPatching)); |
| 28 node_seq->Add(new ReturnNode(Scanner::kDummyTokenIndex, | 29 node_seq->Add(new ReturnNode(Scanner::kDummyTokenIndex, |
| 29 new NativeBodyNode(Scanner::kDummyTokenIndex, | 30 new NativeBodyNode(Scanner::kDummyTokenIndex, |
| 30 native_name, | 31 native_name, |
| 31 native_function, | 32 native_function, |
| 32 num_params, | 33 num_params, |
| 33 has_opt_params, | 34 has_opt_params, |
| 34 false))); | 35 false))); |
| 35 } | 36 } |
| 36 | 37 |
| 37 CODEGEN_TEST2_GENERATE(PatchStaticCall, function, test) { | 38 CODEGEN_TEST2_GENERATE(PatchStaticCall, function, test) { |
| 38 SequenceNode* node_seq = test->node_sequence(); | 39 SequenceNode* node_seq = test->node_sequence(); |
| 39 ArgumentListNode* arguments = new ArgumentListNode(Scanner::kDummyTokenIndex); | 40 ArgumentListNode* arguments = new ArgumentListNode(Scanner::kDummyTokenIndex); |
| 40 node_seq->Add(new ReturnNode(Scanner::kDummyTokenIndex, | 41 node_seq->Add(new ReturnNode(Scanner::kDummyTokenIndex, |
| 41 new StaticCallNode(Scanner::kDummyTokenIndex, | 42 new StaticCallNode(Scanner::kDummyTokenIndex, |
| 42 function, arguments))); | 43 function, arguments))); |
| 43 } | 44 } |
| 44 | 45 |
| 45 CODEGEN_TEST2_RUN(PatchStaticCall, NativePatchStaticCall, Instance::null()); | 46 CODEGEN_TEST2_RUN(PatchStaticCall, NativePatchStaticCall, Instance::null()); |
| 46 | 47 |
| 47 #define __ assembler-> | 48 #define __ assembler-> |
| 48 | 49 |
| 49 ASSEMBLER_TEST_GENERATE(IcDataAccess, assembler) { | 50 ASSEMBLER_TEST_GENERATE(IcDataAccess, assembler) { |
| 50 const String& function_name = | 51 const String& function_name = |
| 51 String::ZoneHandle(String::NewSymbol("callerFunction")); | 52 String::ZoneHandle(Symbols::New("callerFunction")); |
| 52 const Function& function = Function::ZoneHandle( | 53 const Function& function = Function::ZoneHandle( |
| 53 Function::New(function_name, RawFunction::kRegularFunction, | 54 Function::New(function_name, RawFunction::kRegularFunction, |
| 54 true, false, 0)); | 55 true, false, 0)); |
| 55 | 56 |
| 56 const String& target_name = String::Handle(String::New("targetFunction")); | 57 const String& target_name = String::Handle(String::New("targetFunction")); |
| 57 ICData& ic_data = ICData::ZoneHandle( | 58 ICData& ic_data = ICData::ZoneHandle( |
| 58 ICData::New(function, target_name, 15, 1)); | 59 ICData::New(function, target_name, 15, 1)); |
| 59 __ LoadObject(ECX, ic_data); | 60 __ LoadObject(ECX, ic_data); |
| 60 __ LoadObject(EDX, DartEntry::ArgumentsDescriptor(1, Array::Handle())); | 61 __ LoadObject(EDX, DartEntry::ArgumentsDescriptor(1, Array::Handle())); |
| 61 ExternalLabel target_label( | 62 ExternalLabel target_label( |
| 62 "InlineCache", StubCode::OneArgCheckInlineCacheEntryPoint()); | 63 "InlineCache", StubCode::OneArgCheckInlineCacheEntryPoint()); |
| 63 __ call(&target_label); | 64 __ call(&target_label); |
| 64 __ ret(); | 65 __ ret(); |
| 65 } | 66 } |
| 66 | 67 |
| 67 | 68 |
| 68 ASSEMBLER_TEST_RUN(IcDataAccess, entry) { | 69 ASSEMBLER_TEST_RUN(IcDataAccess, entry) { |
| 69 uword return_address = entry + CodePatcher::InstanceCallSizeInBytes(); | 70 uword return_address = entry + CodePatcher::InstanceCallSizeInBytes(); |
| 70 const ICData& ic_data = ICData::Handle( | 71 const ICData& ic_data = ICData::Handle( |
| 71 CodePatcher::GetInstanceCallIcDataAt(return_address)); | 72 CodePatcher::GetInstanceCallIcDataAt(return_address)); |
| 72 EXPECT_STREQ("targetFunction", | 73 EXPECT_STREQ("targetFunction", |
| 73 String::Handle(ic_data.target_name()).ToCString()); | 74 String::Handle(ic_data.target_name()).ToCString()); |
| 74 EXPECT_EQ(1, ic_data.num_args_tested()); | 75 EXPECT_EQ(1, ic_data.num_args_tested()); |
| 75 EXPECT_EQ(0, ic_data.NumberOfChecks()); | 76 EXPECT_EQ(0, ic_data.NumberOfChecks()); |
| 76 } | 77 } |
| 77 | 78 |
| 78 } // namespace dart | 79 } // namespace dart |
| 79 | 80 |
| 80 #endif // TARGET_ARCH_IA32 | 81 #endif // TARGET_ARCH_IA32 |
| OLD | NEW |