| 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_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 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" | |
| 13 #include "vm/instructions.h" | 12 #include "vm/instructions.h" |
| 14 #include "vm/native_entry.h" | 13 #include "vm/native_entry.h" |
| 15 #include "vm/native_entry_test.h" | 14 #include "vm/native_entry_test.h" |
| 16 #include "vm/stub_code.h" | 15 #include "vm/stub_code.h" |
| 17 #include "vm/unit_test.h" | 16 #include "vm/unit_test.h" |
| 18 | 17 |
| 19 namespace dart { | 18 namespace dart { |
| 20 | 19 |
| 21 CODEGEN_TEST_GENERATE(NativePatchStaticCall, test) { | 20 CODEGEN_TEST_GENERATE(NativePatchStaticCall, test) { |
| 22 SequenceNode* node_seq = test->node_sequence(); | 21 SequenceNode* node_seq = test->node_sequence(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 40 node_seq->Add(new ReturnNode(Scanner::kDummyTokenIndex, | 39 node_seq->Add(new ReturnNode(Scanner::kDummyTokenIndex, |
| 41 new StaticCallNode(Scanner::kDummyTokenIndex, | 40 new StaticCallNode(Scanner::kDummyTokenIndex, |
| 42 function, arguments))); | 41 function, arguments))); |
| 43 } | 42 } |
| 44 | 43 |
| 45 CODEGEN_TEST2_RUN(PatchStaticCall, NativePatchStaticCall, Instance::null()); | 44 CODEGEN_TEST2_RUN(PatchStaticCall, NativePatchStaticCall, Instance::null()); |
| 46 | 45 |
| 47 #define __ assembler-> | 46 #define __ assembler-> |
| 48 | 47 |
| 49 ASSEMBLER_TEST_GENERATE(IcDataAccess, assembler) { | 48 ASSEMBLER_TEST_GENERATE(IcDataAccess, assembler) { |
| 50 const String& function_name = String::Handle(String::New("Vermicelles")); | 49 const String& function_name = |
| 51 ICData ic_data(function_name, 1); | 50 String::ZoneHandle(String::NewSymbol("callerFunction")); |
| 52 EXPECT(!Array::Handle(ic_data.data()).IsNull()); | 51 const Function& function = Function::ZoneHandle( |
| 53 __ LoadObject(RBX, Array::ZoneHandle(ic_data.data())); | 52 Function::New(function_name, RawFunction::kFunction, true, false, 0)); |
| 53 |
| 54 const String& target_name = String::Handle(String::New("targetFunction")); |
| 55 ICData& ic_data = ICData::ZoneHandle( |
| 56 ICData::New(function, target_name, 15, 1)); |
| 57 |
| 58 __ LoadObject(RBX, ic_data); |
| 54 __ LoadObject(R10, CodeGenerator::ArgumentsDescriptor(1, Array::Handle())); | 59 __ LoadObject(R10, CodeGenerator::ArgumentsDescriptor(1, Array::Handle())); |
| 55 ExternalLabel target_label( | 60 ExternalLabel target_label( |
| 56 "InlineCache", StubCode::OneArgCheckInlineCacheEntryPoint()); | 61 "InlineCache", StubCode::OneArgCheckInlineCacheEntryPoint()); |
| 57 __ call(&target_label); | 62 __ call(&target_label); |
| 58 __ ret(); | 63 __ ret(); |
| 59 } | 64 } |
| 60 | 65 |
| 61 | 66 |
| 62 ASSEMBLER_TEST_RUN(IcDataAccess, entry) { | 67 ASSEMBLER_TEST_RUN(IcDataAccess, entry) { |
| 63 uword return_address = entry + CodePatcher::InstanceCallSizeInBytes(); | 68 uword return_address = entry + CodePatcher::InstanceCallSizeInBytes(); |
| 64 const Array& array = Array::Handle( | 69 const ICData& ic_data = ICData::Handle( |
| 65 CodePatcher::GetInstanceCallIcDataAt(return_address)); | 70 CodePatcher::GetInstanceCallIcDataAt(return_address)); |
| 66 EXPECT(!array.IsNull()); | 71 EXPECT_STREQ("targetFunction", |
| 67 ICData ic_data(array); | 72 String::Handle(ic_data.target_name()).ToCString()); |
| 68 EXPECT_STREQ("Vermicelles", | 73 EXPECT_EQ(1, ic_data.num_args_tested()); |
| 69 String::Handle(ic_data.FunctionName()).ToCString()); | |
| 70 EXPECT_EQ(1, ic_data.NumberOfArgumentsChecked()); | |
| 71 EXPECT_EQ(0, ic_data.NumberOfChecks()); | 74 EXPECT_EQ(0, ic_data.NumberOfChecks()); |
| 72 const String& new_function_name = String::Handle(String::New("Rigi")); | |
| 73 ICData new_ic_data(new_function_name, 1); | |
| 74 EXPECT_STREQ("Rigi", String::Handle(new_ic_data.FunctionName()).ToCString()); | |
| 75 CodePatcher::SetInstanceCallIcDataAt(return_address, | |
| 76 Array::ZoneHandle(new_ic_data.data())); | |
| 77 const Array& new_array = Array::Handle( | |
| 78 CodePatcher::GetInstanceCallIcDataAt(return_address)); | |
| 79 ICData test_ic_data(new_array); | |
| 80 EXPECT_STREQ("Rigi", String::Handle(test_ic_data.FunctionName()).ToCString()); | |
| 81 } | 75 } |
| 82 | 76 |
| 83 } // namespace dart | 77 } // namespace dart |
| 84 | 78 |
| 85 #endif // TARGET_ARCH_X64 | 79 #endif // TARGET_ARCH_X64 |
| OLD | NEW |