| 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/compiler.h" | 7 #include "vm/compiler.h" |
| 8 #include "vm/object.h" | 8 #include "vm/object.h" |
| 9 #include "vm/pages.h" | 9 #include "vm/pages.h" |
| 10 #include "vm/stack_frame.h" | 10 #include "vm/stack_frame.h" |
| 11 #include "vm/symbols.h" | 11 #include "vm/symbols.h" |
| 12 #include "vm/unit_test.h" | 12 #include "vm/unit_test.h" |
| 13 | 13 |
| 14 namespace dart { | 14 namespace dart { |
| 15 | 15 |
| 16 // Compiler only implemented on IA32, X64, and ARM. | |
| 17 #if defined(TARGET_ARCH_IA32) || \ | |
| 18 defined(TARGET_ARCH_X64) || \ | |
| 19 defined(TARGET_ARCH_ARM) | |
| 20 | |
| 21 TEST_CASE(FindCodeObject) { | 16 TEST_CASE(FindCodeObject) { |
| 22 #if defined(TARGET_ARCH_IA32) | 17 #if defined(TARGET_ARCH_IA32) |
| 23 const int kLoopCount = 50000; | 18 const int kLoopCount = 50000; |
| 24 #elif defined(TARGET_ARCH_X64) | 19 #elif defined(TARGET_ARCH_X64) |
| 25 const int kLoopCount = 25000; | 20 const int kLoopCount = 25000; |
| 21 #elif defined(TARGET_ARCH_MIPS) |
| 22 // TODO(zra): Increase after we implement far branches on MIPS. |
| 23 const int kLoopCount = 1818; |
| 26 #else | 24 #else |
| 27 const int kLoopCount = 20000; | 25 const int kLoopCount = 20000; |
| 28 #endif | 26 #endif |
| 29 const int kScriptSize = 512 * KB; | 27 const int kScriptSize = 512 * KB; |
| 30 const int kNumFunctions = 1024; | 28 const int kNumFunctions = 1024; |
| 31 char scriptChars[kScriptSize]; | 29 char scriptChars[kScriptSize]; |
| 32 String& url = String::Handle(String::New("dart-test:FindCodeObject")); | 30 String& url = String::Handle(String::New("dart-test:FindCodeObject")); |
| 33 String& source = String::Handle(); | 31 String& source = String::Handle(); |
| 34 Script& script = Script::Handle(); | 32 Script& script = Script::Handle(); |
| 35 Library& lib = Library::Handle(); | 33 Library& lib = Library::Handle(); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 EXPECT(Code::LookupCode(pc) == code.raw()); | 140 EXPECT(Code::LookupCode(pc) == code.raw()); |
| 143 | 141 |
| 144 // Lookup the large function | 142 // Lookup the large function |
| 145 OS::SNPrint(buffer, 256, "moo%d", 0); | 143 OS::SNPrint(buffer, 256, "moo%d", 0); |
| 146 function_name = String::New(buffer); | 144 function_name = String::New(buffer); |
| 147 function = clsB.LookupStaticFunction(function_name); | 145 function = clsB.LookupStaticFunction(function_name); |
| 148 EXPECT(!function.IsNull()); | 146 EXPECT(!function.IsNull()); |
| 149 code = function.CurrentCode(); | 147 code = function.CurrentCode(); |
| 150 EXPECT(code.Size() > 16); | 148 EXPECT(code.Size() > 16); |
| 151 pc = code.EntryPoint() + 16; | 149 pc = code.EntryPoint() + 16; |
| 150 #if defined(TARGET_ARCH_MIPS) |
| 151 // MIPS can only Branch +/- 128KB |
| 152 EXPECT(code.Size() > (PageSpace::kPageSize / 2)); |
| 153 EXPECT(Code::LookupCode(pc) == code.raw()); |
| 154 pc = code.EntryPoint() + (PageSpace::kPageSize / 4); |
| 155 EXPECT(Code::LookupCode(pc) == code.raw()); |
| 156 #else |
| 152 EXPECT(code.Size() > PageSpace::kPageSize); | 157 EXPECT(code.Size() > PageSpace::kPageSize); |
| 153 EXPECT(Code::LookupCode(pc) == code.raw()); | 158 EXPECT(Code::LookupCode(pc) == code.raw()); |
| 154 EXPECT(code.Size() > (1 * MB)); | 159 EXPECT(code.Size() > (1 * MB)); |
| 155 pc = code.EntryPoint() + (1 * MB); | 160 pc = code.EntryPoint() + (1 * MB); |
| 156 EXPECT(Code::LookupCode(pc) == code.raw()); | 161 EXPECT(Code::LookupCode(pc) == code.raw()); |
| 162 #endif // defined(TARGET_ARCH_MIPS) |
| 157 } | 163 } |
| 158 | 164 |
| 159 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64 || TARGET_ARCH_ARM | |
| 160 | |
| 161 } // namespace dart | 165 } // namespace dart |
| OLD | NEW |