| 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_patcher.h" | 10 #include "vm/code_patcher.h" |
| 10 #include "vm/dart_entry.h" | 11 #include "vm/dart_entry.h" |
| 12 #include "vm/ic_data.h" |
| 11 #include "vm/instructions.h" | 13 #include "vm/instructions.h" |
| 12 #include "vm/native_entry.h" | 14 #include "vm/native_entry.h" |
| 13 #include "vm/native_entry_test.h" | 15 #include "vm/native_entry_test.h" |
| 14 #include "vm/stub_code.h" | 16 #include "vm/stub_code.h" |
| 15 #include "vm/unit_test.h" | 17 #include "vm/unit_test.h" |
| 16 | 18 |
| 17 namespace dart { | 19 namespace dart { |
| 18 | 20 |
| 19 static const intptr_t kPos = 1; // Dummy token index in non-existing source. | 21 static const intptr_t kPos = 1; // Dummy token index in non-existing source. |
| 20 | 22 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 } | 74 } |
| 73 | 75 |
| 74 | 76 |
| 75 ASSEMBLER_TEST_RUN(InsertJump, entry) { | 77 ASSEMBLER_TEST_RUN(InsertJump, entry) { |
| 76 CodePatcher::InsertJump(entry, &StubCode::MegamorphicLookupLabel()); | 78 CodePatcher::InsertJump(entry, &StubCode::MegamorphicLookupLabel()); |
| 77 Jump jump(entry); | 79 Jump jump(entry); |
| 78 EXPECT_EQ(StubCode::MegamorphicLookupLabel().address(), jump.TargetAddress()); | 80 EXPECT_EQ(StubCode::MegamorphicLookupLabel().address(), jump.TargetAddress()); |
| 79 } | 81 } |
| 80 | 82 |
| 81 | 83 |
| 84 ASSEMBLER_TEST_GENERATE(IcDataAccess, assembler) { |
| 85 const String& function_name = String::Handle(String::New("Vermicelles")); |
| 86 ICData ic_data(function_name, 1); |
| 87 EXPECT(!Array::Handle(ic_data.data()).IsNull()); |
| 88 __ LoadObject(ECX, Array::ZoneHandle(ic_data.data())); |
| 89 __ LoadObject(EDX, CodeGenerator::ArgumentsDescriptor(1, Array::Handle())); |
| 90 __ call(&StubCode::CallInstanceFunctionLabel()); |
| 91 __ ret(); |
| 92 } |
| 93 |
| 94 |
| 95 ASSEMBLER_TEST_RUN(IcDataAccess, entry) { |
| 96 uword return_address = entry + CodePatcher::InstanceCallSizeInBytes(); |
| 97 const Array& array = Array::Handle( |
| 98 CodePatcher::GetInstanceCallIcDataAt(return_address)); |
| 99 EXPECT(!array.IsNull()); |
| 100 ICData ic_data(array); |
| 101 EXPECT_STREQ("Vermicelles", |
| 102 String::Handle(ic_data.FunctionName()).ToCString()); |
| 103 EXPECT_EQ(1, ic_data.NumberOfArgumentsChecked()); |
| 104 EXPECT_EQ(0, ic_data.NumberOfChecks()); |
| 105 const String& new_function_name = String::Handle(String::New("Rigi")); |
| 106 ICData new_ic_data(new_function_name, 1); |
| 107 EXPECT_STREQ("Rigi", String::Handle(new_ic_data.FunctionName()).ToCString()); |
| 108 CodePatcher::SetInstanceCallIcDataAt(return_address, |
| 109 Array::ZoneHandle(new_ic_data.data())); |
| 110 const Array& new_array = Array::Handle( |
| 111 CodePatcher::GetInstanceCallIcDataAt(return_address)); |
| 112 ICData test_ic_data(new_array); |
| 113 EXPECT_STREQ("Rigi", String::Handle(test_ic_data.FunctionName()).ToCString()); |
| 114 } |
| 115 |
| 82 } // namespace dart | 116 } // namespace dart |
| 83 | 117 |
| 84 #endif // TARGET_ARCH_IA32 | 118 #endif // TARGET_ARCH_IA32 |
| OLD | NEW |