| OLD | NEW |
| 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/class_finalizer.h" | 6 #include "vm/class_finalizer.h" |
| 7 #include "vm/code_index_table.h" | 7 #include "vm/code_index_table.h" |
| 8 #include "vm/compiler.h" | 8 #include "vm/compiler.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/pages.h" | 10 #include "vm/pages.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 EXPECT(function.HasCode()); | 116 EXPECT(function.HasCode()); |
| 117 } | 117 } |
| 118 | 118 |
| 119 // Now try and access these functions using the code index table. | 119 // Now try and access these functions using the code index table. |
| 120 Code& code = Code::Handle(); | 120 Code& code = Code::Handle(); |
| 121 uword pc; | 121 uword pc; |
| 122 OS::SNPrint(buffer, 256, "foo%d", 123); | 122 OS::SNPrint(buffer, 256, "foo%d", 123); |
| 123 function_name = String::New(buffer); | 123 function_name = String::New(buffer); |
| 124 function = clsA.LookupStaticFunction(function_name); | 124 function = clsA.LookupStaticFunction(function_name); |
| 125 EXPECT(!function.IsNull()); | 125 EXPECT(!function.IsNull()); |
| 126 code = function.code(); | 126 code = function.CurrentCode(); |
| 127 EXPECT(code.Size() > 16); | 127 EXPECT(code.Size() > 16); |
| 128 pc = code.EntryPoint() + 16; | 128 pc = code.EntryPoint() + 16; |
| 129 EXPECT(code_index_table->LookupFunction(pc) == function.raw()); | |
| 130 EXPECT(code_index_table->LookupCode(pc) == code.raw()); | 129 EXPECT(code_index_table->LookupCode(pc) == code.raw()); |
| 131 | 130 |
| 132 OS::SNPrint(buffer, 256, "moo%d", 54); | 131 OS::SNPrint(buffer, 256, "moo%d", 54); |
| 133 function_name = String::New(buffer); | 132 function_name = String::New(buffer); |
| 134 function = clsB.LookupStaticFunction(function_name); | 133 function = clsB.LookupStaticFunction(function_name); |
| 135 EXPECT(!function.IsNull()); | 134 EXPECT(!function.IsNull()); |
| 136 code = function.code(); | 135 code = function.CurrentCode(); |
| 137 EXPECT(code.Size() > 16); | 136 EXPECT(code.Size() > 16); |
| 138 pc = code.EntryPoint() + 16; | 137 pc = code.EntryPoint() + 16; |
| 139 EXPECT(code_index_table->LookupFunction(pc) == function.raw()); | |
| 140 EXPECT(code_index_table->LookupCode(pc) == code.raw()); | 138 EXPECT(code_index_table->LookupCode(pc) == code.raw()); |
| 141 | 139 |
| 142 // Lookup the large function | 140 // Lookup the large function |
| 143 OS::SNPrint(buffer, 256, "moo%d", 0); | 141 OS::SNPrint(buffer, 256, "moo%d", 0); |
| 144 function_name = String::New(buffer); | 142 function_name = String::New(buffer); |
| 145 function = clsB.LookupStaticFunction(function_name); | 143 function = clsB.LookupStaticFunction(function_name); |
| 146 EXPECT(!function.IsNull()); | 144 EXPECT(!function.IsNull()); |
| 147 code = function.code(); | 145 code = function.CurrentCode(); |
| 148 EXPECT(code.Size() > 16); | 146 EXPECT(code.Size() > 16); |
| 149 pc = code.EntryPoint() + 16; | 147 pc = code.EntryPoint() + 16; |
| 150 EXPECT(code.Size() > PageSpace::kPageSize); | 148 EXPECT(code.Size() > PageSpace::kPageSize); |
| 151 EXPECT(code_index_table->LookupFunction(pc) == function.raw()); | |
| 152 EXPECT(code_index_table->LookupCode(pc) == code.raw()); | 149 EXPECT(code_index_table->LookupCode(pc) == code.raw()); |
| 153 EXPECT(code.Size() > (1 * MB)); | 150 EXPECT(code.Size() > (1 * MB)); |
| 154 pc = code.EntryPoint() + (1 * MB); | 151 pc = code.EntryPoint() + (1 * MB); |
| 155 EXPECT(code_index_table->LookupFunction(pc) == function.raw()); | |
| 156 EXPECT(code_index_table->LookupCode(pc) == code.raw()); | 152 EXPECT(code_index_table->LookupCode(pc) == code.raw()); |
| 157 } | 153 } |
| 158 | 154 |
| 159 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64 | 155 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64 |
| 160 | 156 |
| 161 } // namespace dart | 157 } // namespace dart |
| OLD | NEW |