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

Side by Side Diff: vm/parser_test.cc

Issue 10783035: Create frequently used symbols in the vm isolate (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 5 months 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 | « vm/parser.cc ('k') | vm/raw_object_snapshot.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 5
6 #include "vm/ast_printer.h" 6 #include "vm/ast_printer.h"
7 #include "vm/class_finalizer.h" 7 #include "vm/class_finalizer.h"
8 #include "vm/longjump.h" 8 #include "vm/longjump.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/parser.h" 10 #include "vm/parser.h"
11 #include "vm/symbols.h"
11 #include "vm/unit_test.h" 12 #include "vm/unit_test.h"
12 13
13 namespace dart { 14 namespace dart {
14 15
15 16
16 void DumpFunction(const Library& lib, const char* cname, const char* fname) { 17 void DumpFunction(const Library& lib, const char* cname, const char* fname) {
17 const String& classname = String::Handle(String::NewSymbol(cname)); 18 const String& classname = String::Handle(Symbols::New(cname));
18 Class& cls = Class::Handle(lib.LookupClass(classname)); 19 Class& cls = Class::Handle(lib.LookupClass(classname));
19 EXPECT(!cls.IsNull()); 20 EXPECT(!cls.IsNull());
20 21
21 String& funcname = String::Handle(String::New(fname)); 22 String& funcname = String::Handle(String::New(fname));
22 Function& function = Function::Handle(cls.LookupStaticFunction(funcname)); 23 Function& function = Function::Handle(cls.LookupStaticFunction(funcname));
23 EXPECT(!function.IsNull()); 24 EXPECT(!function.IsNull());
24 25
25 bool retval; 26 bool retval;
26 Isolate* isolate = Isolate::Current(); 27 Isolate* isolate = Isolate::Current();
27 EXPECT(isolate != NULL); 28 EXPECT(isolate != NULL);
(...skipping 13 matching lines...) Expand all
41 EXPECT(retval); 42 EXPECT(retval);
42 isolate->set_long_jump_base(base); 43 isolate->set_long_jump_base(base);
43 } 44 }
44 45
45 46
46 void CheckField(const Library& lib, 47 void CheckField(const Library& lib,
47 const char* class_name, 48 const char* class_name,
48 const char* field_name, 49 const char* field_name,
49 bool expect_static, 50 bool expect_static,
50 bool is_final) { 51 bool is_final) {
51 const String& classname = String::Handle(String::NewSymbol(class_name)); 52 const String& classname = String::Handle(Symbols::New(class_name));
52 Class& cls = Class::Handle(lib.LookupClass(classname)); 53 Class& cls = Class::Handle(lib.LookupClass(classname));
53 EXPECT(!cls.IsNull()); 54 EXPECT(!cls.IsNull());
54 55
55 String& fieldname = String::Handle(String::New(field_name)); 56 String& fieldname = String::Handle(String::New(field_name));
56 String& functionname = String::Handle(); 57 String& functionname = String::Handle();
57 Function& function = Function::Handle(); 58 Function& function = Function::Handle();
58 Field& field = Field::Handle(); 59 Field& field = Field::Handle();
59 if (expect_static) { 60 if (expect_static) {
60 field ^= cls.LookupStaticField(fieldname); 61 field ^= cls.LookupStaticField(fieldname);
61 functionname ^= Field::GetterName(fieldname); 62 functionname ^= Field::GetterName(fieldname);
(...skipping 14 matching lines...) Expand all
76 EXPECT(!field.IsNull()); 77 EXPECT(!field.IsNull());
77 78
78 EXPECT_EQ(field.is_static(), expect_static); 79 EXPECT_EQ(field.is_static(), expect_static);
79 } 80 }
80 81
81 82
82 void CheckFunction(const Library& lib, 83 void CheckFunction(const Library& lib,
83 const char* class_name, 84 const char* class_name,
84 const char* function_name, 85 const char* function_name,
85 bool expect_static) { 86 bool expect_static) {
86 const String& classname = String::Handle(String::NewSymbol(class_name)); 87 const String& classname = String::Handle(Symbols::New(class_name));
87 Class& cls = Class::Handle(lib.LookupClass(classname)); 88 Class& cls = Class::Handle(lib.LookupClass(classname));
88 EXPECT(!cls.IsNull()); 89 EXPECT(!cls.IsNull());
89 90
90 String& functionname = String::Handle(String::New(function_name)); 91 String& functionname = String::Handle(String::New(function_name));
91 Function& function = Function::Handle(); 92 Function& function = Function::Handle();
92 if (expect_static) { 93 if (expect_static) {
93 function ^= cls.LookupStaticFunction(functionname); 94 function ^= cls.LookupStaticFunction(functionname);
94 } else { 95 } else {
95 function ^= cls.LookupDynamicFunction(functionname); 96 function ^= cls.LookupDynamicFunction(functionname);
96 } 97 }
(...skipping 27 matching lines...) Expand all
124 Parser::ParseCompilationUnit(lib, script); 125 Parser::ParseCompilationUnit(lib, script);
125 EXPECT(ClassFinalizer::FinalizePendingClasses()); 126 EXPECT(ClassFinalizer::FinalizePendingClasses());
126 CheckField(lib, "A", "f1", false, false); 127 CheckField(lib, "A", "f1", false, false);
127 CheckField(lib, "A", "f2", false, true); 128 CheckField(lib, "A", "f2", false, true);
128 CheckField(lib, "A", "f3", false, true); 129 CheckField(lib, "A", "f3", false, true);
129 CheckField(lib, "A", "f4", false, true); 130 CheckField(lib, "A", "f4", false, true);
130 CheckField(lib, "A", "s1", true, false); 131 CheckField(lib, "A", "s1", true, false);
131 CheckField(lib, "A", "s2", true, false); 132 CheckField(lib, "A", "s2", true, false);
132 // No field entries are added for static const fields. 133 // No field entries are added for static const fields.
133 String& fieldname = String::Handle(String::New("s3")); 134 String& fieldname = String::Handle(String::New("s3"));
134 const String& classname = String::Handle(String::NewSymbol("A")); 135 const String& classname = String::Handle(Symbols::New("A"));
135 const Class& cls = Class::Handle(lib.LookupClass(classname)); 136 const Class& cls = Class::Handle(lib.LookupClass(classname));
136 const Field& field = Field::Handle(cls.LookupStaticField(fieldname)); 137 const Field& field = Field::Handle(cls.LookupStaticField(fieldname));
137 EXPECT(!field.IsNull()); 138 EXPECT(!field.IsNull());
138 Object& val = Object::Handle(field.value()); 139 Object& val = Object::Handle(field.value());
139 // The static const field initializer is not evaluated and the field 140 // The static const field initializer is not evaluated and the field
140 // value is not initialized until the field is referenced by code that 141 // value is not initialized until the field is referenced by code that
141 // is compiled. 142 // is compiled.
142 EXPECT(val.raw() == Object::sentinel()); 143 EXPECT(val.raw() == Object::sentinel());
143 144
144 CheckFunction(lib, "A", "bar", true); 145 CheckFunction(lib, "A", "bar", true);
(...skipping 25 matching lines...) Expand all
170 Parser::ParseCompilationUnit(lib, script); 171 Parser::ParseCompilationUnit(lib, script);
171 EXPECT(ClassFinalizer::FinalizePendingClasses()); 172 EXPECT(ClassFinalizer::FinalizePendingClasses());
172 173
173 DumpFunction(lib, "A", "foo"); 174 DumpFunction(lib, "A", "foo");
174 DumpFunction(lib, "A", "bar"); 175 DumpFunction(lib, "A", "bar");
175 DumpFunction(lib, "A", "baz"); 176 DumpFunction(lib, "A", "baz");
176 DumpFunction(lib, "B", "bam"); 177 DumpFunction(lib, "B", "bam");
177 } 178 }
178 179
179 } // namespace dart 180 } // namespace dart
OLDNEW
« no previous file with comments | « vm/parser.cc ('k') | vm/raw_object_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698