| 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/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 11 matching lines...) Expand all Loading... |
| 22 // Class has no fields. | 22 // Class has no fields. |
| 23 const Array& no_fields = Array::Handle(Array::Empty()); | 23 const Array& no_fields = Array::Handle(Array::Empty()); |
| 24 cls.SetFields(no_fields); | 24 cls.SetFields(no_fields); |
| 25 | 25 |
| 26 // Create and populate the function arrays. | 26 // Create and populate the function arrays. |
| 27 const Array& functions = Array::Handle(Array::New(6)); | 27 const Array& functions = Array::Handle(Array::New(6)); |
| 28 Function& function = Function::Handle(); | 28 Function& function = Function::Handle(); |
| 29 String& function_name = String::Handle(); | 29 String& function_name = String::Handle(); |
| 30 function_name = String::NewSymbol("foo"); | 30 function_name = String::NewSymbol("foo"); |
| 31 function = Function::New( | 31 function = Function::New( |
| 32 function_name, RawFunction::kFunction, false, false, 0); | 32 function_name, RawFunction::kFunction, |
| 33 false, false, false, 0); |
| 33 functions.SetAt(0, function); | 34 functions.SetAt(0, function); |
| 34 function_name = String::NewSymbol("bar"); | 35 function_name = String::NewSymbol("bar"); |
| 35 function = Function::New( | 36 function = Function::New( |
| 36 function_name, RawFunction::kFunction, false, false, 0); | 37 function_name, RawFunction::kFunction, false, false, false, 0); |
| 37 | 38 |
| 38 const int kNumFixedParameters = 2; | 39 const int kNumFixedParameters = 2; |
| 39 const int kNumOptionalParameters = 3; | 40 const int kNumOptionalParameters = 3; |
| 40 function.set_num_fixed_parameters(kNumFixedParameters); | 41 function.set_num_fixed_parameters(kNumFixedParameters); |
| 41 function.set_num_optional_parameters(kNumOptionalParameters); | 42 function.set_num_optional_parameters(kNumOptionalParameters); |
| 42 functions.SetAt(1, function); | 43 functions.SetAt(1, function); |
| 43 | 44 |
| 44 function_name = String::NewSymbol("baz"); | 45 function_name = String::NewSymbol("baz"); |
| 45 function = Function::New( | 46 function = Function::New( |
| 46 function_name, RawFunction::kFunction, false, false, 0); | 47 function_name, RawFunction::kFunction, false, false, false, 0); |
| 47 functions.SetAt(2, function); | 48 functions.SetAt(2, function); |
| 48 | 49 |
| 49 function_name = String::NewSymbol("Foo"); | 50 function_name = String::NewSymbol("Foo"); |
| 50 function = Function::New( | 51 function = Function::New( |
| 51 function_name, RawFunction::kFunction, true, false, 0); | 52 function_name, RawFunction::kFunction, true, false, false, 0); |
| 52 functions.SetAt(3, function); | 53 functions.SetAt(3, function); |
| 53 function_name = String::NewSymbol("Bar"); | 54 function_name = String::NewSymbol("Bar"); |
| 54 function = Function::New( | 55 function = Function::New( |
| 55 function_name, RawFunction::kFunction, true, false, 0); | 56 function_name, RawFunction::kFunction, true, false, false, 0); |
| 56 functions.SetAt(4, function); | 57 functions.SetAt(4, function); |
| 57 function_name = String::NewSymbol("BaZ"); | 58 function_name = String::NewSymbol("BaZ"); |
| 58 function = Function::New( | 59 function = Function::New( |
| 59 function_name, RawFunction::kFunction, true, false, 0); | 60 function_name, RawFunction::kFunction, true, false, false, 0); |
| 60 functions.SetAt(5, function); | 61 functions.SetAt(5, function); |
| 61 | 62 |
| 62 // Setup the functions in the class. | 63 // Setup the functions in the class. |
| 63 cls.SetFunctions(functions); | 64 cls.SetFunctions(functions); |
| 64 | 65 |
| 65 function_name = String::New("Foo"); | 66 function_name = String::New("Foo"); |
| 66 function = cls.LookupDynamicFunction(function_name); | 67 function = cls.LookupDynamicFunction(function_name); |
| 67 EXPECT(function.IsNull()); | 68 EXPECT(function.IsNull()); |
| 68 function = cls.LookupStaticFunction(function_name); | 69 function = cls.LookupStaticFunction(function_name); |
| 69 EXPECT(!function.IsNull()); | 70 EXPECT(!function.IsNull()); |
| (...skipping 2246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2316 // Allocate the class first. | 2317 // Allocate the class first. |
| 2317 const String& class_name = String::Handle(String::NewSymbol("MyClass")); | 2318 const String& class_name = String::Handle(String::NewSymbol("MyClass")); |
| 2318 const Script& script = Script::Handle(); | 2319 const Script& script = Script::Handle(); |
| 2319 const Class& cls = | 2320 const Class& cls = |
| 2320 Class::Handle(Class::New(class_name, script, Scanner::kDummyTokenIndex)); | 2321 Class::Handle(Class::New(class_name, script, Scanner::kDummyTokenIndex)); |
| 2321 const Array& functions = Array::Handle(Array::New(1)); | 2322 const Array& functions = Array::Handle(Array::New(1)); |
| 2322 | 2323 |
| 2323 const Context& context = Context::Handle(Context::New(0)); | 2324 const Context& context = Context::Handle(Context::New(0)); |
| 2324 Function& parent = Function::Handle(); | 2325 Function& parent = Function::Handle(); |
| 2325 const String& parent_name = String::Handle(String::NewSymbol("foo_papa")); | 2326 const String& parent_name = String::Handle(String::NewSymbol("foo_papa")); |
| 2326 parent = Function::New(parent_name, RawFunction::kFunction, false, false, 0); | 2327 parent = Function::New(parent_name, RawFunction::kFunction, |
| 2328 false, false, false, 0); |
| 2327 functions.SetAt(0, parent); | 2329 functions.SetAt(0, parent); |
| 2328 cls.SetFunctions(functions); | 2330 cls.SetFunctions(functions); |
| 2329 | 2331 |
| 2330 Function& function = Function::Handle(); | 2332 Function& function = Function::Handle(); |
| 2331 const String& function_name = String::Handle(String::NewSymbol("foo")); | 2333 const String& function_name = String::Handle(String::NewSymbol("foo")); |
| 2332 function = Function::NewClosureFunction(function_name, parent, 0); | 2334 function = Function::NewClosureFunction(function_name, parent, 0); |
| 2333 const Class& signature_class = Class::Handle( | 2335 const Class& signature_class = Class::Handle( |
| 2334 Class::NewSignatureClass(function_name, function, script)); | 2336 Class::NewSignatureClass(function_name, function, script)); |
| 2335 const Closure& closure = Closure::Handle(Closure::New(function, context)); | 2337 const Closure& closure = Closure::Handle(Closure::New(function, context)); |
| 2336 const Class& closure_class = Class::Handle(closure.clazz()); | 2338 const Class& closure_class = Class::Handle(closure.clazz()); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2385 EXPECT(!str3.IsOneByteString()); | 2387 EXPECT(!str3.IsOneByteString()); |
| 2386 } | 2388 } |
| 2387 | 2389 |
| 2388 | 2390 |
| 2389 // only ia32 and x64 can run execution tests. | 2391 // only ia32 and x64 can run execution tests. |
| 2390 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) | 2392 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
| 2391 | 2393 |
| 2392 static Function* CreateFunction(const char* name) { | 2394 static Function* CreateFunction(const char* name) { |
| 2393 const String& function_name = String::ZoneHandle(String::NewSymbol(name)); | 2395 const String& function_name = String::ZoneHandle(String::NewSymbol(name)); |
| 2394 Function& function = Function::ZoneHandle( | 2396 Function& function = Function::ZoneHandle( |
| 2395 Function::New(function_name, RawFunction::kFunction, true, false, 0)); | 2397 Function::New(function_name, RawFunction::kFunction, |
| 2398 true, false, false, 0)); |
| 2396 return &function; | 2399 return &function; |
| 2397 } | 2400 } |
| 2398 | 2401 |
| 2399 // Test for Code and Instruction object creation. | 2402 // Test for Code and Instruction object creation. |
| 2400 TEST_CASE(Code) { | 2403 TEST_CASE(Code) { |
| 2401 extern void GenerateIncrement(Assembler* assembler); | 2404 extern void GenerateIncrement(Assembler* assembler); |
| 2402 Assembler _assembler_; | 2405 Assembler _assembler_; |
| 2403 GenerateIncrement(&_assembler_); | 2406 GenerateIncrement(&_assembler_); |
| 2404 Code& code = Code::Handle(Code::FinalizeCode( | 2407 Code& code = Code::Handle(Code::FinalizeCode( |
| 2405 *CreateFunction("Test_Code"), &_assembler_)); | 2408 *CreateFunction("Test_Code"), &_assembler_)); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2568 count++; | 2571 count++; |
| 2569 } | 2572 } |
| 2570 ASSERT(count == 2); | 2573 ASSERT(count == 2); |
| 2571 } | 2574 } |
| 2572 | 2575 |
| 2573 | 2576 |
| 2574 static RawFunction* GetDummyTarget(const char* name) { | 2577 static RawFunction* GetDummyTarget(const char* name) { |
| 2575 const String& function_name = String::Handle(String::NewSymbol(name)); | 2578 const String& function_name = String::Handle(String::NewSymbol(name)); |
| 2576 const bool is_static = false; | 2579 const bool is_static = false; |
| 2577 const bool is_const = false; | 2580 const bool is_const = false; |
| 2581 const bool is_abstract = false; |
| 2578 return Function::New(function_name, | 2582 return Function::New(function_name, |
| 2579 RawFunction::kFunction, | 2583 RawFunction::kFunction, |
| 2580 is_static, | 2584 is_static, |
| 2581 is_const, | 2585 is_const, |
| 2586 is_abstract, |
| 2582 0); | 2587 0); |
| 2583 } | 2588 } |
| 2584 | 2589 |
| 2585 | 2590 |
| 2586 TEST_CASE(ICData) { | 2591 TEST_CASE(ICData) { |
| 2587 Function& function = Function::Handle(GetDummyTarget("Bern")); | 2592 Function& function = Function::Handle(GetDummyTarget("Bern")); |
| 2588 const intptr_t id = 12; | 2593 const intptr_t id = 12; |
| 2589 const intptr_t num_args_tested = 1; | 2594 const intptr_t num_args_tested = 1; |
| 2590 const String& target_name = String::Handle(String::New("Thun")); | 2595 const String& target_name = String::Handle(String::New("Thun")); |
| 2591 ICData& o1 = ICData::Handle(); | 2596 ICData& o1 = ICData::Handle(); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2777 // Named double-private constructor mismatch. | 2782 // Named double-private constructor mismatch. |
| 2778 mangled_name = OneByteString::New("foo@12345.named@12345"); | 2783 mangled_name = OneByteString::New("foo@12345.named@12345"); |
| 2779 bare_name = OneByteString::New("foo.name"); | 2784 bare_name = OneByteString::New("foo.name"); |
| 2780 EXPECT(!mangled_name.EqualsIgnoringPrivateKey(bare_name)); | 2785 EXPECT(!mangled_name.EqualsIgnoringPrivateKey(bare_name)); |
| 2781 } | 2786 } |
| 2782 | 2787 |
| 2783 | 2788 |
| 2784 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 2789 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
| 2785 | 2790 |
| 2786 } // namespace dart | 2791 } // namespace dart |
| OLD | NEW |