Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: runtime/vm/native_entry_test.cc

Issue 11411072: Simplify CodePatcher::GetStaticCallAt. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/debugger.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 Function& target_function = Function::Handle();
62 DartFrameIterator iterator; 61 DartFrameIterator iterator;
63 iterator.NextFrame(); // Skip native call. 62 iterator.NextFrame(); // Skip native call.
64 StackFrame* static_caller_frame = iterator.NextFrame(); 63 StackFrame* static_caller_frame = iterator.NextFrame();
65 uword target_address = 0; 64 uword target_address =
66 CodePatcher::GetStaticCallAt(static_caller_frame->pc(), 65 CodePatcher::GetStaticCallTargetAt(static_caller_frame->pc());
67 &target_function,
68 &target_address);
69 const Code& code = Code::Handle(static_caller_frame->LookupDartCode()); 66 const Code& code = Code::Handle(static_caller_frame->LookupDartCode());
70 const Function& target_function_2 = 67 const Function& target_function =
71 Function::Handle(code.GetStaticCallTargetFunctionAt( 68 Function::Handle(code.GetStaticCallTargetFunctionAt(
72 static_caller_frame->pc())); 69 static_caller_frame->pc()));
73 EXPECT(!target_function_2.IsNull());
74 EXPECT_EQ(target_function_2.raw(), target_function.raw());
75 EXPECT(String::Handle(target_function.name()). 70 EXPECT(String::Handle(target_function.name()).
76 Equals(String::Handle(String::New("NativePatchStaticCall")))); 71 Equals(String::Handle(String::New("NativePatchStaticCall"))));
77 const uword function_entry_address = 72 const uword function_entry_address =
78 Code::Handle(target_function.CurrentCode()).EntryPoint(); 73 Code::Handle(target_function.CurrentCode()).EntryPoint();
79 EXPECT_EQ(function_entry_address, target_address); 74 EXPECT_EQ(function_entry_address, target_address);
80 Dart_ExitScope(); 75 Dart_ExitScope();
81 } 76 }
82 77
83 } // namespace dart 78 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/debugger.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698