| 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/ic_data.h" | 5 #include "vm/ic_data.h" |
| 6 #include "vm/code_index_table.h" | 6 #include "vm/code_index_table.h" |
| 7 #include "vm/unit_test.h" | 7 #include "vm/unit_test.h" |
| 8 | 8 |
| 9 namespace dart { | 9 namespace dart { |
| 10 | 10 |
| 11 static RawFunction* GetDummyTarget(const char* name) { | 11 static RawFunction* GetDummyTarget(const char* name) { |
| 12 Assembler assembler; | 12 const String& function_name = String::Handle(String::NewSymbol(name)); |
| 13 assembler.ret(); | 13 const bool is_static = false; |
| 14 const Code& code = | 14 const bool is_const = false; |
| 15 Code::Handle(Code::FinalizeCode(name, &assembler)); | 15 return Function::New(function_name, |
| 16 const String& function_name = | 16 RawFunction::kFunction, |
| 17 String::ZoneHandle(String::NewSymbol(name)); | 17 is_static, |
| 18 const Function& function = Function::Handle(Function::New( | 18 is_const, |
| 19 function_name, RawFunction::kFunction, true, false, 0)); | 19 0); |
| 20 function.SetCode(code); | |
| 21 CodeIndexTable* code_index_table = Isolate::Current()->code_index_table(); | |
| 22 ASSERT(code_index_table != NULL); | |
| 23 code_index_table->AddFunction(function); | |
| 24 return function.raw(); | |
| 25 } | 20 } |
| 26 | 21 |
| 27 | 22 |
| 28 static bool SameClassArrays(const GrowableArray<const Class*>& a, | 23 static bool SameClassArrays(const GrowableArray<const Class*>& a, |
| 29 const GrowableArray<const Class*>& b) { | 24 const GrowableArray<const Class*>& b) { |
| 30 if (a.length() != b.length()) { | 25 if (a.length() != b.length()) { |
| 31 return false; | 26 return false; |
| 32 } | 27 } |
| 33 for (int i = 0; i < a.length(); i++) { | 28 for (int i = 0; i < a.length(); i++) { |
| 34 if (a[i]->raw() != b[i]->raw()) { | 29 if (a[i]->raw() != b[i]->raw()) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 const Function& new_target = | 61 const Function& new_target = |
| 67 Function::Handle(GetDummyTarget(name.ToCString())); | 62 Function::Handle(GetDummyTarget(name.ToCString())); |
| 68 ic_data.SetCheckAt(0, classes, new_target); | 63 ic_data.SetCheckAt(0, classes, new_target); |
| 69 ic_data.GetCheckAt(0, &test_classes, &test_target); | 64 ic_data.GetCheckAt(0, &test_classes, &test_target); |
| 70 | 65 |
| 71 EXPECT(SameClassArrays(classes, test_classes)); | 66 EXPECT(SameClassArrays(classes, test_classes)); |
| 72 EXPECT_EQ(new_target.raw(), test_target.raw()); | 67 EXPECT_EQ(new_target.raw(), test_target.raw()); |
| 73 } | 68 } |
| 74 | 69 |
| 75 } // namespace dart | 70 } // namespace dart |
| OLD | NEW |