| 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/native_entry.h" | 9 #include "vm/native_entry.h" |
| 10 #include "vm/object.h" | 10 #include "vm/object.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 result += arg_value; | 51 result += arg_value; |
| 52 } | 52 } |
| 53 Dart_SetReturnValue(args, Dart_NewInteger(result)); | 53 Dart_SetReturnValue(args, Dart_NewInteger(result)); |
| 54 Dart_ExitScope(); | 54 Dart_ExitScope(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 | 57 |
| 58 // Test code patching. | 58 // Test code patching. |
| 59 void TestStaticCallPatching(Dart_NativeArguments args) { | 59 void TestStaticCallPatching(Dart_NativeArguments args) { |
| 60 Dart_EnterScope(); | 60 Dart_EnterScope(); |
| 61 uword target_address = 0; | |
| 62 Function& target_function = Function::Handle(); | 61 Function& target_function = Function::Handle(); |
| 63 DartFrameIterator iterator; | 62 DartFrameIterator iterator; |
| 64 iterator.NextFrame(); // Skip native call. | 63 iterator.NextFrame(); // Skip native call. |
| 65 StackFrame* static_caller_frame = iterator.NextFrame(); | 64 StackFrame* static_caller_frame = iterator.NextFrame(); |
| 65 uword target_address = 0; |
| 66 CodePatcher::GetStaticCallAt(static_caller_frame->pc(), | 66 CodePatcher::GetStaticCallAt(static_caller_frame->pc(), |
| 67 &target_function, | 67 &target_function, |
| 68 &target_address); | 68 &target_address); |
| 69 const Code& code = Code::Handle(static_caller_frame->LookupDartCode()); |
| 70 const Function& target_function_2 = |
| 71 Function::Handle(code.GetStaticCallTargetFunctionAt( |
| 72 static_caller_frame->pc())); |
| 73 EXPECT(!target_function_2.IsNull()); |
| 74 EXPECT_EQ(target_function_2.raw(), target_function.raw()); |
| 69 EXPECT(String::Handle(target_function.name()). | 75 EXPECT(String::Handle(target_function.name()). |
| 70 Equals(String::Handle(String::New("NativePatchStaticCall")))); | 76 Equals(String::Handle(String::New("NativePatchStaticCall")))); |
| 71 const uword function_entry_address = | 77 const uword function_entry_address = |
| 72 Code::Handle(target_function.CurrentCode()).EntryPoint(); | 78 Code::Handle(target_function.CurrentCode()).EntryPoint(); |
| 73 EXPECT_EQ(function_entry_address, target_address); | 79 EXPECT_EQ(function_entry_address, target_address); |
| 74 Dart_ExitScope(); | 80 Dart_ExitScope(); |
| 75 } | 81 } |
| 76 | 82 |
| 77 } // namespace dart | 83 } // namespace dart |
| OLD | NEW |