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

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

Issue 8357034: Transitioning to new IC structure: change IC data to include function name; pass IC data instead ... (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 2 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/ic_stubs_ia32.cc ('k') | runtime/vm/stub_code_ia32.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_index_table.h" 9 #include "vm/code_index_table.h"
10 #include "vm/ic_stubs.h" 10 #include "vm/ic_stubs.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 EXPECT_EQ(function2.raw(), new_targets[i]->raw()); 193 EXPECT_EQ(function2.raw(), new_targets[i]->raw());
194 } else if (new_classes[i]->raw() == 194 } else if (new_classes[i]->raw() ==
195 Isolate::Current()->object_store()->bool_class()) { 195 Isolate::Current()->object_store()->bool_class()) {
196 EXPECT_EQ(function2.raw(), new_targets[i]->raw()); 196 EXPECT_EQ(function2.raw(), new_targets[i]->raw());
197 } else { 197 } else {
198 UNREACHABLE(); 198 UNREACHABLE();
199 } 199 }
200 } 200 }
201 } 201 }
202 202
203
204 static bool SameClassArrays(const GrowableArray<const Class*>& a,
205 const GrowableArray<const Class*>& b) {
206 if (a.length() != b.length()) {
207 return false;
208 }
209 for (int i = 0; i < a.length(); i++) {
210 if (a[i]->raw() != b[i]->raw()) {
211 return false;
212 }
213 }
214 return true;
215 }
216
217
218 // Testing the platform independent ICData class here because ICStubs::GetICStub
219 // is implemented only in ia32.
220 TEST_CASE(ICDataTest) {
221 GrowableArray<const Class*> classes;
222 GrowableArray<const Function*> targets;
223 const Code& ic_stub = Code::Handle(ICStubs::GetICStub(classes, targets));
224 if (ic_stub.IsNull()) {
225 // ICStubs not implemented for the platform.
226 return;
227 }
228 ICData ic_data(ic_stub);
229 intptr_t num_classes = 2;
230 intptr_t num_checks = 3;
231 ic_data.SetICDataArray(num_classes, num_checks);
232 EXPECT_EQ(num_classes, ic_data.NumberOfClasses());
233 EXPECT_EQ(num_checks, ic_data.NumberOfChecks());
234 ObjectStore* object_store = Isolate::Current()->object_store();
235 const Class& double_class = Class::ZoneHandle(object_store->double_class());
236 const Class& smi_class = Class::ZoneHandle(object_store->smi_class());
237 GrowableArray<const Class*> check0;
238 check0.Add(&smi_class);
239 check0.Add(&smi_class);
240 GrowableArray<const Class*> check1;
241 check1.Add(&smi_class);
242 check1.Add(&double_class);
243 GrowableArray<const Class*> check2;
244 check2.Add(&double_class);
245 check2.Add(&smi_class);
246 const Function& function0 = Function::ZoneHandle(GetDummyTarget("SmiSmi"));
247 const Function& function1 = Function::ZoneHandle(GetDummyTarget("SmiDouble"));
248 const Function& function2 = Function::ZoneHandle(GetDummyTarget("DoubleSmi"));
249 const Function& function3 =
250 Function::ZoneHandle(GetDummyTarget("DoubleDouble"));
251 ic_data.SetCheckAt(0, check0, function0);
252 ic_data.SetCheckAt(1, check1, function1);
253 ic_data.SetCheckAt(2, check2, function2);
254
255 Function& test_function = Function::Handle();
256 GrowableArray<const Class*> test_classes;
257
258 ic_data.GetCheckAt(0, &test_classes, &test_function);
259 EXPECT_EQ(function0.raw(), test_function.raw());
260 EXPECT_EQ(true, SameClassArrays(test_classes, check0));
261
262 ic_data.GetCheckAt(1, &test_classes, &test_function);
263 EXPECT_EQ(function1.raw(), test_function.raw());
264 EXPECT_EQ(true, SameClassArrays(test_classes, check1));
265
266 ic_data.GetCheckAt(1, &test_classes, &test_function);
267 EXPECT_EQ(function1.raw(), test_function.raw());
268 EXPECT_EQ(true, SameClassArrays(test_classes, check1));
269
270 ic_data.GetCheckAt(2, &test_classes, &test_function);
271 EXPECT_EQ(function2.raw(), test_function.raw());
272 EXPECT_EQ(true, SameClassArrays(test_classes, check2));
273
274 // Test AddCheck, test new and old data.
275 GrowableArray<const Class*> double_double_classes;
276 double_double_classes.Add(&double_class);
277 double_double_classes.Add(&double_class);
278 ic_data.AddCheck(double_double_classes, function3);
279 EXPECT_EQ(4, ic_data.NumberOfChecks());
280 ic_data.GetCheckAt(3, &test_classes, &test_function);
281 EXPECT_EQ(function3.raw(), test_function.raw());
282 EXPECT_EQ(true, SameClassArrays(test_classes, double_double_classes));
283
284 ic_data.GetCheckAt(1, &test_classes, &test_function);
285 EXPECT_EQ(function1.raw(), test_function.raw());
286 EXPECT_EQ(true, SameClassArrays(test_classes, check1));
287 }
288
289
290 } // namespace dart 203 } // namespace dart
291 204
292 #endif // defined TARGET_ARCH_IA32 205 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/ic_stubs_ia32.cc ('k') | runtime/vm/stub_code_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698