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

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

Issue 9395016: First part of new ICData infrastructure: use a wrapper object instead of an array. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 months 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/code_patcher_ia32.cc ('k') | runtime/vm/code_patcher_x64.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/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_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
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(ECX, 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 __ LoadObject(ECX, ic_data);
54 __ LoadObject(EDX, CodeGenerator::ArgumentsDescriptor(1, Array::Handle())); 58 __ LoadObject(EDX, CodeGenerator::ArgumentsDescriptor(1, Array::Handle()));
55 ExternalLabel target_label( 59 ExternalLabel target_label(
56 "InlineCache", StubCode::OneArgCheckInlineCacheEntryPoint()); 60 "InlineCache", StubCode::OneArgCheckInlineCacheEntryPoint());
57 __ call(&target_label); 61 __ call(&target_label);
58 __ ret(); 62 __ ret();
59 } 63 }
60 64
61 65
62 ASSEMBLER_TEST_RUN(IcDataAccess, entry) { 66 ASSEMBLER_TEST_RUN(IcDataAccess, entry) {
63 uword return_address = entry + CodePatcher::InstanceCallSizeInBytes(); 67 uword return_address = entry + CodePatcher::InstanceCallSizeInBytes();
64 const Array& array = Array::Handle( 68 const ICData& ic_data = ICData::Handle(
65 CodePatcher::GetInstanceCallIcDataAt(return_address)); 69 CodePatcher::GetInstanceCallIcDataAt(return_address));
66 EXPECT(!array.IsNull()); 70 EXPECT_STREQ("targetFunction",
67 ICData ic_data(array); 71 String::Handle(ic_data.target_name()).ToCString());
68 EXPECT_STREQ("Vermicelles", 72 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()); 73 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 } 74 }
82 75
83 } // namespace dart 76 } // namespace dart
84 77
85 #endif // TARGET_ARCH_IA32 78 #endif // TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/code_patcher_ia32.cc ('k') | runtime/vm/code_patcher_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698