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/globals.h" | 6 #include "vm/globals.h" |
7 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) | 7 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
8 | 8 |
9 #include "vm/ast.h" | 9 #include "vm/ast.h" |
10 #include "vm/assembler.h" | 10 #include "vm/assembler.h" |
11 #include "vm/code_descriptors.h" | 11 #include "vm/code_descriptors.h" |
12 #include "vm/compiler.h" | 12 #include "vm/compiler.h" |
13 #include "vm/dart_entry.h" | 13 #include "vm/dart_entry.h" |
14 #include "vm/native_entry.h" | 14 #include "vm/native_entry.h" |
15 #include "vm/parser.h" | 15 #include "vm/parser.h" |
| 16 #include "vm/symbols.h" |
16 #include "vm/unit_test.h" | 17 #include "vm/unit_test.h" |
17 | 18 |
18 namespace dart { | 19 namespace dart { |
19 | 20 |
20 static const intptr_t kPos = Scanner::kDummyTokenIndex; | 21 static const intptr_t kPos = Scanner::kDummyTokenIndex; |
21 | 22 |
22 | 23 |
23 CODEGEN_TEST_GENERATE(StackmapCodegen, test) { | 24 CODEGEN_TEST_GENERATE(StackmapCodegen, test) { |
24 Assembler assembler; | 25 Assembler assembler; |
25 const String& function_name = String::ZoneHandle(String::NewSymbol("test")); | 26 const String& function_name = String::ZoneHandle(Symbols::New("test")); |
26 const Function& function = Function::Handle( | 27 const Function& function = Function::Handle( |
27 Function::New(function_name, RawFunction::kFunction, true, false, 0)); | 28 Function::New(function_name, RawFunction::kFunction, true, false, 0)); |
28 function.set_result_type(Type::Handle(Type::DynamicType())); | 29 function.set_result_type(Type::Handle(Type::DynamicType())); |
29 Class& cls = Class::ZoneHandle(); | 30 Class& cls = Class::ZoneHandle(); |
30 const Script& script = Script::Handle(); | 31 const Script& script = Script::Handle(); |
31 cls = Class::New(function_name, script, Scanner::kDummyTokenIndex); | 32 cls = Class::New(function_name, script, Scanner::kDummyTokenIndex); |
32 const Array& functions = Array::Handle(Array::New(1)); | 33 const Array& functions = Array::Handle(Array::New(1)); |
33 functions.SetAt(0, function); | 34 functions.SetAt(0, function); |
34 cls.SetFunctions(functions); | 35 cls.SetFunctions(functions); |
35 Library& lib = Library::Handle(Library::CoreLibrary()); | 36 Library& lib = Library::Handle(Library::CoreLibrary()); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 " Expect.equals(30, i);" | 168 " Expect.equals(30, i);" |
168 " }\n" | 169 " }\n" |
169 "}\n"; | 170 "}\n"; |
170 // First setup the script and compile the script. | 171 // First setup the script and compile the script. |
171 TestCase::LoadTestScript(kScriptChars, native_resolver); | 172 TestCase::LoadTestScript(kScriptChars, native_resolver); |
172 EXPECT(ClassFinalizer::FinalizePendingClasses()); | 173 EXPECT(ClassFinalizer::FinalizePendingClasses()); |
173 const String& name = String::Handle(String::New(TestCase::url())); | 174 const String& name = String::Handle(String::New(TestCase::url())); |
174 const Library& lib = Library::Handle(Library::LookupLibrary(name)); | 175 const Library& lib = Library::Handle(Library::LookupLibrary(name)); |
175 EXPECT(!lib.IsNull()); | 176 EXPECT(!lib.IsNull()); |
176 Class& cls = Class::Handle( | 177 Class& cls = Class::Handle( |
177 lib.LookupClass(String::Handle(String::NewSymbol("A")))); | 178 lib.LookupClass(String::Handle(Symbols::New("A")))); |
178 EXPECT(!cls.IsNull()); | 179 EXPECT(!cls.IsNull()); |
179 | 180 |
180 // Now compile the two functions 'A.foo' and 'A.moo' | 181 // Now compile the two functions 'A.foo' and 'A.moo' |
181 String& function_moo_name = String::Handle(String::New("moo")); | 182 String& function_moo_name = String::Handle(String::New("moo")); |
182 Function& function_moo = | 183 Function& function_moo = |
183 Function::Handle(cls.LookupStaticFunction(function_moo_name)); | 184 Function::Handle(cls.LookupStaticFunction(function_moo_name)); |
184 EXPECT(CompilerTest::TestCompileFunction(function_moo)); | 185 EXPECT(CompilerTest::TestCompileFunction(function_moo)); |
185 EXPECT(function_moo.HasCode()); | 186 EXPECT(function_moo.HasCode()); |
186 | 187 |
187 String& function_foo_name = String::Handle(String::New("foo")); | 188 String& function_foo_name = String::Handle(String::New("foo")); |
(...skipping 22 matching lines...) Expand all Loading... |
210 GrowableArray<const Object*> arguments; | 211 GrowableArray<const Object*> arguments; |
211 const Array& kNoArgumentNames = Array::Handle(); | 212 const Array& kNoArgumentNames = Array::Handle(); |
212 Object& result = Object::Handle(); | 213 Object& result = Object::Handle(); |
213 result = DartEntry::InvokeStatic(function_foo, arguments, kNoArgumentNames); | 214 result = DartEntry::InvokeStatic(function_foo, arguments, kNoArgumentNames); |
214 EXPECT(!result.IsError()); | 215 EXPECT(!result.IsError()); |
215 } | 216 } |
216 | 217 |
217 } // namespace dart | 218 } // namespace dart |
218 | 219 |
219 #endif // defined TARGET_ARCH_IA32 || defined(TARGET_ARCH_X64) | 220 #endif // defined TARGET_ARCH_IA32 || defined(TARGET_ARCH_X64) |
OLD | NEW |