Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: runtime/vm/object_test.cc

Issue 99373002: Mark native functions when they are created. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "vm/assembler.h" 5 #include "vm/assembler.h"
6 #include "vm/bigint_operations.h" 6 #include "vm/bigint_operations.h"
7 #include "vm/class_finalizer.h" 7 #include "vm/class_finalizer.h"
8 #include "vm/dart_api_impl.h" 8 #include "vm/dart_api_impl.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/debugger.h" 10 #include "vm/debugger.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // parsed. 57 // parsed.
58 ClassFinalizer::FinalizeTypesInClass(cls); 58 ClassFinalizer::FinalizeTypesInClass(cls);
59 59
60 // Create and populate the function arrays. 60 // Create and populate the function arrays.
61 const Array& functions = Array::Handle(Array::New(6)); 61 const Array& functions = Array::Handle(Array::New(6));
62 Function& function = Function::Handle(); 62 Function& function = Function::Handle();
63 String& function_name = String::Handle(); 63 String& function_name = String::Handle();
64 function_name = Symbols::New("foo"); 64 function_name = Symbols::New("foo");
65 function = Function::New( 65 function = Function::New(
66 function_name, RawFunction::kRegularFunction, 66 function_name, RawFunction::kRegularFunction,
67 false, false, false, false, cls, 0); 67 false, false, false, false, false, cls, 0);
68 functions.SetAt(0, function); 68 functions.SetAt(0, function);
69 function_name = Symbols::New("bar"); 69 function_name = Symbols::New("bar");
70 function = Function::New( 70 function = Function::New(
71 function_name, RawFunction::kRegularFunction, 71 function_name, RawFunction::kRegularFunction,
72 false, false, false, false, cls, 0); 72 false, false, false, false, false, cls, 0);
73 73
74 const int kNumFixedParameters = 2; 74 const int kNumFixedParameters = 2;
75 const int kNumOptionalParameters = 3; 75 const int kNumOptionalParameters = 3;
76 const bool kAreOptionalPositional = true; 76 const bool kAreOptionalPositional = true;
77 function.set_num_fixed_parameters(kNumFixedParameters); 77 function.set_num_fixed_parameters(kNumFixedParameters);
78 function.SetNumOptionalParameters(kNumOptionalParameters, 78 function.SetNumOptionalParameters(kNumOptionalParameters,
79 kAreOptionalPositional); 79 kAreOptionalPositional);
80 functions.SetAt(1, function); 80 functions.SetAt(1, function);
81 81
82 function_name = Symbols::New("baz"); 82 function_name = Symbols::New("baz");
83 function = Function::New( 83 function = Function::New(
84 function_name, RawFunction::kRegularFunction, 84 function_name, RawFunction::kRegularFunction,
85 false, false, false, false, cls, 0); 85 false, false, false, false, false, cls, 0);
86 functions.SetAt(2, function); 86 functions.SetAt(2, function);
87 87
88 function_name = Symbols::New("Foo"); 88 function_name = Symbols::New("Foo");
89 function = Function::New( 89 function = Function::New(
90 function_name, RawFunction::kRegularFunction, 90 function_name, RawFunction::kRegularFunction,
91 true, false, false, false, cls, 0); 91 true, false, false, false, false, cls, 0);
92 92
93 functions.SetAt(3, function); 93 functions.SetAt(3, function);
94 function_name = Symbols::New("Bar"); 94 function_name = Symbols::New("Bar");
95 function = Function::New( 95 function = Function::New(
96 function_name, RawFunction::kRegularFunction, 96 function_name, RawFunction::kRegularFunction,
97 true, false, false, false, cls, 0); 97 true, false, false, false, false, cls, 0);
98 functions.SetAt(4, function); 98 functions.SetAt(4, function);
99 function_name = Symbols::New("BaZ"); 99 function_name = Symbols::New("BaZ");
100 function = Function::New( 100 function = Function::New(
101 function_name, RawFunction::kRegularFunction, 101 function_name, RawFunction::kRegularFunction,
102 true, false, false, false, cls, 0); 102 true, false, false, false, false, cls, 0);
103 functions.SetAt(5, function); 103 functions.SetAt(5, function);
104 104
105 // Setup the functions in the class. 105 // Setup the functions in the class.
106 cls.SetFunctions(functions); 106 cls.SetFunctions(functions);
107 107
108 // The class can now be finalized. 108 // The class can now be finalized.
109 cls.Finalize(); 109 cls.Finalize();
110 110
111 function_name = String::New("Foo"); 111 function_name = String::New("Foo");
112 function = cls.LookupDynamicFunction(function_name); 112 function = cls.LookupDynamicFunction(function_name);
(...skipping 2216 matching lines...) Expand 10 before | Expand all | Expand 10 after
2329 // Allocate the class first. 2329 // Allocate the class first.
2330 const String& class_name = String::Handle(Symbols::New("MyClass")); 2330 const String& class_name = String::Handle(Symbols::New("MyClass"));
2331 const Script& script = Script::Handle(); 2331 const Script& script = Script::Handle();
2332 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); 2332 const Class& cls = Class::Handle(CreateDummyClass(class_name, script));
2333 const Array& functions = Array::Handle(Array::New(1)); 2333 const Array& functions = Array::Handle(Array::New(1));
2334 2334
2335 const Context& context = Context::Handle(Context::New(0)); 2335 const Context& context = Context::Handle(Context::New(0));
2336 Function& parent = Function::Handle(); 2336 Function& parent = Function::Handle();
2337 const String& parent_name = String::Handle(Symbols::New("foo_papa")); 2337 const String& parent_name = String::Handle(Symbols::New("foo_papa"));
2338 parent = Function::New(parent_name, RawFunction::kRegularFunction, 2338 parent = Function::New(parent_name, RawFunction::kRegularFunction,
2339 false, false, false, false, cls, 0); 2339 false, false, false, false, false, cls, 0);
2340 functions.SetAt(0, parent); 2340 functions.SetAt(0, parent);
2341 cls.SetFunctions(functions); 2341 cls.SetFunctions(functions);
2342 2342
2343 Function& function = Function::Handle(); 2343 Function& function = Function::Handle();
2344 const String& function_name = String::Handle(Symbols::New("foo")); 2344 const String& function_name = String::Handle(Symbols::New("foo"));
2345 function = Function::NewClosureFunction(function_name, parent, 0); 2345 function = Function::NewClosureFunction(function_name, parent, 0);
2346 const Class& signature_class = Class::Handle( 2346 const Class& signature_class = Class::Handle(
2347 Class::NewSignatureClass(function_name, function, script, 0)); 2347 Class::NewSignatureClass(function_name, function, script, 0));
2348 const Instance& closure = Instance::Handle(Closure::New(function, context)); 2348 const Instance& closure = Instance::Handle(Closure::New(function, context));
2349 const Class& closure_class = Class::Handle(closure.clazz()); 2349 const Class& closure_class = Class::Handle(closure.clazz());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2404 const String& lib_name = String::Handle(Symbols::New("ownerLibrary")); 2404 const String& lib_name = String::Handle(Symbols::New("ownerLibrary"));
2405 const Script& script = Script::Handle(); 2405 const Script& script = Script::Handle();
2406 const Class& owner_class = 2406 const Class& owner_class =
2407 Class::Handle(CreateDummyClass(class_name, script)); 2407 Class::Handle(CreateDummyClass(class_name, script));
2408 const Library& owner_library = 2408 const Library& owner_library =
2409 Library::Handle(CreateDummyLibrary(lib_name)); 2409 Library::Handle(CreateDummyLibrary(lib_name));
2410 owner_class.set_library(owner_library); 2410 owner_class.set_library(owner_library);
2411 const String& function_name = String::ZoneHandle(Symbols::New(name)); 2411 const String& function_name = String::ZoneHandle(Symbols::New(name));
2412 Function& function = Function::ZoneHandle( 2412 Function& function = Function::ZoneHandle(
2413 Function::New(function_name, RawFunction::kRegularFunction, 2413 Function::New(function_name, RawFunction::kRegularFunction,
2414 true, false, false, false, owner_class, 0)); 2414 true, false, false, false, false, owner_class, 0));
2415 return &function; 2415 return &function;
2416 } 2416 }
2417 2417
2418 2418
2419 // Test for Code and Instruction object creation. 2419 // Test for Code and Instruction object creation.
2420 TEST_CASE(Code) { 2420 TEST_CASE(Code) {
2421 extern void GenerateIncrement(Assembler* assembler); 2421 extern void GenerateIncrement(Assembler* assembler);
2422 Assembler _assembler_; 2422 Assembler _assembler_;
2423 GenerateIncrement(&_assembler_); 2423 GenerateIncrement(&_assembler_);
2424 Code& code = Code::Handle(Code::FinalizeCode( 2424 Code& code = Code::Handle(Code::FinalizeCode(
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
2623 2623
2624 2624
2625 static RawFunction* GetDummyTarget(const char* name) { 2625 static RawFunction* GetDummyTarget(const char* name) {
2626 const String& function_name = String::Handle(Symbols::New(name)); 2626 const String& function_name = String::Handle(Symbols::New(name));
2627 const Class& cls = Class::Handle( 2627 const Class& cls = Class::Handle(
2628 CreateDummyClass(function_name, Script::Handle())); 2628 CreateDummyClass(function_name, Script::Handle()));
2629 const bool is_static = false; 2629 const bool is_static = false;
2630 const bool is_const = false; 2630 const bool is_const = false;
2631 const bool is_abstract = false; 2631 const bool is_abstract = false;
2632 const bool is_external = false; 2632 const bool is_external = false;
2633 const bool is_native = false;
2633 return Function::New(function_name, 2634 return Function::New(function_name,
2634 RawFunction::kRegularFunction, 2635 RawFunction::kRegularFunction,
2635 is_static, 2636 is_static,
2636 is_const, 2637 is_const,
2637 is_abstract, 2638 is_abstract,
2638 is_external, 2639 is_external,
2640 is_native,
2639 cls, 2641 cls,
2640 0); 2642 0);
2641 } 2643 }
2642 2644
2643 2645
2644 TEST_CASE(ICData) { 2646 TEST_CASE(ICData) {
2645 Function& function = Function::Handle(GetDummyTarget("Bern")); 2647 Function& function = Function::Handle(GetDummyTarget("Bern"));
2646 const intptr_t id = 12; 2648 const intptr_t id = 12;
2647 const intptr_t num_args_tested = 1; 2649 const intptr_t num_args_tested = 1;
2648 const String& target_name = String::Handle(String::New("Thun")); 2650 const String& target_name = String::Handle(String::New("Thun"));
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after
3619 cls = Object::dynamic_class(); 3621 cls = Object::dynamic_class();
3620 array = cls.fields(); 3622 array = cls.fields();
3621 EXPECT(!array.IsNull()); 3623 EXPECT(!array.IsNull());
3622 EXPECT(array.IsArray()); 3624 EXPECT(array.IsArray());
3623 array = cls.functions(); 3625 array = cls.functions();
3624 EXPECT(!array.IsNull()); 3626 EXPECT(!array.IsNull());
3625 EXPECT(array.IsArray()); 3627 EXPECT(array.IsArray());
3626 } 3628 }
3627 3629
3628 } // namespace dart 3630 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698