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

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

Issue 10352012: Using SubtypeTestCache object instead of an array, that way we do not need to patch and can communi… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 "platform/assert.h" 5 #include "platform/assert.h"
6 #include "vm/assembler.h" 6 #include "vm/assembler.h"
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/object_store.h" 10 #include "vm/object_store.h"
(...skipping 2785 matching lines...) Expand 10 before | Expand all | Expand 10 after
2796 o2.AddCheck(classes, target1); 2796 o2.AddCheck(classes, target1);
2797 EXPECT_EQ(1, o2.NumberOfChecks()); 2797 EXPECT_EQ(1, o2.NumberOfChecks());
2798 o2.GetCheckAt(0, &test_classes, &test_target); 2798 o2.GetCheckAt(0, &test_classes, &test_target);
2799 EXPECT_EQ(2, test_classes.length()); 2799 EXPECT_EQ(2, test_classes.length());
2800 EXPECT_EQ(smi_class.raw(), test_classes[0]->raw()); 2800 EXPECT_EQ(smi_class.raw(), test_classes[0]->raw());
2801 EXPECT_EQ(smi_class.raw(), test_classes[1]->raw()); 2801 EXPECT_EQ(smi_class.raw(), test_classes[1]->raw());
2802 EXPECT_EQ(target1.raw(), test_target.raw()); 2802 EXPECT_EQ(target1.raw(), test_target.raw());
2803 } 2803 }
2804 2804
2805 2805
2806 TEST_CASE(SubtypeTestCache) {
2807 String& class_name = String::Handle(String::NewSymbol("EmptyClass"));
2808 Script& script = Script::Handle();
2809 const Class& empty_class =
2810 Class::Handle(Class::New(class_name, script, Scanner::kDummyTokenIndex));
2811 SubtypeTestCache& cache = SubtypeTestCache::Handle(SubtypeTestCache::New());
2812 ASSERT(!cache.IsNull());
2813 EXPECT_EQ(0, cache.NumberOfChecks());
2814 const TypeArguments& targ_0 = TypeArguments::Handle(TypeArguments::New(2));
2815 const TypeArguments& targ_1 = TypeArguments::Handle(TypeArguments::New(3));
2816 cache.AddCheck(empty_class, targ_0, targ_1, Bool::Handle(Bool::True()));
2817 EXPECT_EQ(1, cache.NumberOfChecks());
2818 Class& test_class = Class::Handle();
2819 AbstractTypeArguments& test_targ_0 = AbstractTypeArguments::Handle();
2820 AbstractTypeArguments& test_targ_1 = AbstractTypeArguments::Handle();
2821 Bool& test_result = Bool::Handle();
2822 cache.GetCheck(0, &test_class, &test_targ_0, &test_targ_1, &test_result);
2823 EXPECT_EQ(empty_class.raw(), test_class.raw());
2824 EXPECT_EQ(targ_0.raw(), test_targ_0.raw());
2825 EXPECT_EQ(targ_1.raw(), test_targ_1.raw());
2826 EXPECT_EQ(Bool::True(), test_result.raw());
2827 }
2828
2806 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 2829 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
2807 2830
2808 } // namespace dart 2831 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698