| 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/native_entry_test.h" | 5 #include "vm/native_entry_test.h" |
| 6 | 6 |
| 7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
| 8 #include "vm/code_patcher.h" | 8 #include "vm/code_patcher.h" |
| 9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 10 #include "vm/native_entry.h" | 10 #include "vm/native_entry.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 Dart_ExitScope(); | 87 Dart_ExitScope(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 | 90 |
| 91 // Test code patching. | 91 // Test code patching. |
| 92 void TestStaticCallPatching(Dart_NativeArguments args) { | 92 void TestStaticCallPatching(Dart_NativeArguments args) { |
| 93 Dart_EnterScope(); | 93 Dart_EnterScope(); |
| 94 DartFrameIterator iterator; | 94 DartFrameIterator iterator; |
| 95 iterator.NextFrame(); // Skip native call. | 95 iterator.NextFrame(); // Skip native call. |
| 96 StackFrame* static_caller_frame = iterator.NextFrame(); | 96 StackFrame* static_caller_frame = iterator.NextFrame(); |
| 97 const Code& code = Code::Handle(static_caller_frame->LookupDartCode()); |
| 97 uword target_address = | 98 uword target_address = |
| 98 CodePatcher::GetStaticCallTargetAt(static_caller_frame->pc()); | 99 CodePatcher::GetStaticCallTargetAt(static_caller_frame->pc(), code); |
| 99 const Code& code = Code::Handle(static_caller_frame->LookupDartCode()); | |
| 100 const Function& target_function = | 100 const Function& target_function = |
| 101 Function::Handle(code.GetStaticCallTargetFunctionAt( | 101 Function::Handle(code.GetStaticCallTargetFunctionAt( |
| 102 static_caller_frame->pc())); | 102 static_caller_frame->pc())); |
| 103 EXPECT(String::Handle(target_function.name()). | 103 EXPECT(String::Handle(target_function.name()). |
| 104 Equals(String::Handle(String::New("NativePatchStaticCall")))); | 104 Equals(String::Handle(String::New("NativePatchStaticCall")))); |
| 105 const uword function_entry_address = | 105 const uword function_entry_address = |
| 106 Code::Handle(target_function.CurrentCode()).EntryPoint(); | 106 Code::Handle(target_function.CurrentCode()).EntryPoint(); |
| 107 EXPECT_EQ(function_entry_address, target_address); | 107 EXPECT_EQ(function_entry_address, target_address); |
| 108 Dart_ExitScope(); | 108 Dart_ExitScope(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 } // namespace dart | 111 } // namespace dart |
| OLD | NEW |