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

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

Issue 1870343002: - Refactor Symbol allocation to expect a thread parameter. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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
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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 // 208 //
209 // List. -> List 209 // List. -> List
210 // 210 //
211 // And so forth: 211 // And so forth:
212 // 212 //
213 // get:foo@6328321 -> foo 213 // get:foo@6328321 -> foo
214 // _MyClass@6328321. -> _MyClass 214 // _MyClass@6328321. -> _MyClass
215 // _MyClass@6328321.named -> _MyClass.named 215 // _MyClass@6328321.named -> _MyClass.named
216 // 216 //
217 RawString* String::ScrubName(const String& name) { 217 RawString* String::ScrubName(const String& name) {
218 Zone* zone = Thread::Current()->zone(); 218 Thread* thread = Thread::Current();
219 Zone* zone = thread->zone();
219 220
220 NOT_IN_PRODUCT( 221 NOT_IN_PRODUCT(
221 if (name.Equals(Symbols::TopLevel())) { 222 if (name.Equals(Symbols::TopLevel())) {
222 // Name of invisible top-level class. 223 // Name of invisible top-level class.
223 return Symbols::Empty().raw(); 224 return Symbols::Empty().raw();
224 } 225 }
225 ) 226 )
226 227
227 const char* cname = name.ToCString(); 228 const char* cname = name.ToCString();
228 ASSERT(strlen(cname) == static_cast<size_t>(name.Length())); 229 ASSERT(strlen(cname) == static_cast<size_t>(name.Length()));
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 dot_pos = -1; 293 dot_pos = -1;
293 break; 294 break;
294 } 295 }
295 ASSERT(dot_pos == -1); // Only one dot is supported. 296 ASSERT(dot_pos == -1); // Only one dot is supported.
296 dot_pos = i; 297 dot_pos = i;
297 } 298 }
298 } 299 }
299 300
300 if ((start == 0) && (dot_pos == -1)) { 301 if ((start == 0) && (dot_pos == -1)) {
301 // This unmangled_name is fine as it is. 302 // This unmangled_name is fine as it is.
302 return Symbols::New(unmangled_name, sum_segment_len); 303 return Symbols::New(thread, unmangled_name, sum_segment_len);
303 } 304 }
304 305
305 // Drop the trailing dot if needed. 306 // Drop the trailing dot if needed.
306 intptr_t end = ((dot_pos + 1) == len) ? dot_pos : len; 307 intptr_t end = ((dot_pos + 1) == len) ? dot_pos : len;
307 308
308 unmangled_segments.Clear(); 309 unmangled_segments.Clear();
309 intptr_t final_len = end - start; 310 intptr_t final_len = end - start;
310 AppendSubString(zone, &unmangled_segments, unmangled_name, start, final_len); 311 AppendSubString(zone, &unmangled_segments, unmangled_name, start, final_len);
311 if (is_setter) { 312 if (is_setter) {
312 const char* equals = Symbols::Equals().ToCString(); 313 const char* equals = Symbols::Equals().ToCString();
313 const intptr_t equals_len = strlen(equals); 314 const intptr_t equals_len = strlen(equals);
314 AppendSubString(zone, &unmangled_segments, equals, 0, equals_len); 315 AppendSubString(zone, &unmangled_segments, equals, 0, equals_len);
315 final_len += equals_len; 316 final_len += equals_len;
316 } 317 }
317 318
318 unmangled_name = MergeSubStrings(zone, unmangled_segments, final_len); 319 unmangled_name = MergeSubStrings(zone, unmangled_segments, final_len);
319 ) 320 )
320 321
321 return Symbols::New(unmangled_name); 322 return Symbols::New(thread, unmangled_name);
322 } 323 }
323 324
324 325
325 RawString* String::ScrubNameRetainPrivate(const String& name) { 326 RawString* String::ScrubNameRetainPrivate(const String& name) {
326 NOT_IN_PRODUCT( 327 NOT_IN_PRODUCT(
327 intptr_t len = name.Length(); 328 intptr_t len = name.Length();
328 intptr_t start = 0; 329 intptr_t start = 0;
329 intptr_t at_pos = -1; // Position of '@' in the name, if any. 330 intptr_t at_pos = -1; // Position of '@' in the name, if any.
330 bool is_setter = false; 331 bool is_setter = false;
331 332
(...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1514 1515
1515 cls = Class::New<Instance>(kIllegalCid); 1516 cls = Class::New<Instance>(kIllegalCid);
1516 RegisterClass(cls, Symbols::Double(), core_lib); 1517 RegisterClass(cls, Symbols::Double(), core_lib);
1517 cls.set_num_type_arguments(0); 1518 cls.set_num_type_arguments(0);
1518 cls.set_num_own_type_arguments(0); 1519 cls.set_num_own_type_arguments(0);
1519 cls.set_is_prefinalized(); 1520 cls.set_is_prefinalized();
1520 pending_classes.Add(cls); 1521 pending_classes.Add(cls);
1521 type = Type::NewNonParameterizedType(cls); 1522 type = Type::NewNonParameterizedType(cls);
1522 object_store->set_double_type(type); 1523 object_store->set_double_type(type);
1523 1524
1524 name = Symbols::New("String"); 1525 name = Symbols::_String().raw();
1525 cls = Class::New<Instance>(kIllegalCid); 1526 cls = Class::New<Instance>(kIllegalCid);
1526 RegisterClass(cls, name, core_lib); 1527 RegisterClass(cls, name, core_lib);
1527 cls.set_num_type_arguments(0); 1528 cls.set_num_type_arguments(0);
1528 cls.set_num_own_type_arguments(0); 1529 cls.set_num_own_type_arguments(0);
1529 cls.set_is_prefinalized(); 1530 cls.set_is_prefinalized();
1530 pending_classes.Add(cls); 1531 pending_classes.Add(cls);
1531 type = Type::NewNonParameterizedType(cls); 1532 type = Type::NewNonParameterizedType(cls);
1532 object_store->set_string_type(type); 1533 object_store->set_string_type(type);
1533 1534
1534 cls = object_store->bool_class(); 1535 cls = object_store->bool_class();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1579 ASSERT(!cls.IsNull()); 1580 ASSERT(!cls.IsNull());
1580 Field& field = Field::Handle(zone); 1581 Field& field = Field::Handle(zone);
1581 Smi& value = Smi::Handle(zone); 1582 Smi& value = Smi::Handle(zone);
1582 String& field_name = String::Handle(zone); 1583 String& field_name = String::Handle(zone);
1583 1584
1584 #define CLASS_LIST_WITH_NULL(V) \ 1585 #define CLASS_LIST_WITH_NULL(V) \
1585 V(Null) \ 1586 V(Null) \
1586 CLASS_LIST_NO_OBJECT(V) 1587 CLASS_LIST_NO_OBJECT(V)
1587 1588
1588 #define ADD_SET_FIELD(clazz) \ 1589 #define ADD_SET_FIELD(clazz) \
1589 field_name = Symbols::New("cid"#clazz); \ 1590 field_name = Symbols::New(thread, "cid"#clazz); \
1590 field = Field::New(field_name, true, false, true, false, cls, \ 1591 field = Field::New(field_name, true, false, true, false, cls, \
1591 Type::Handle(Type::IntType()), TokenPosition::kMinSource); \ 1592 Type::Handle(Type::IntType()), TokenPosition::kMinSource); \
1592 value = Smi::New(k##clazz##Cid); \ 1593 value = Smi::New(k##clazz##Cid); \
1593 field.SetStaticValue(value, true); \ 1594 field.SetStaticValue(value, true); \
1594 cls.AddField(field); \ 1595 cls.AddField(field); \
1595 1596
1596 CLASS_LIST_WITH_NULL(ADD_SET_FIELD) 1597 CLASS_LIST_WITH_NULL(ADD_SET_FIELD)
1597 #undef ADD_SET_FIELD 1598 #undef ADD_SET_FIELD
1598 1599
1599 isolate->object_store()->InitKnownObjects(); 1600 isolate->object_store()->InitKnownObjects();
1600 1601
1601 return Error::null(); 1602 return Error::null();
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
2563 cache.SetAt(i + kArgsDescIndex, args_desc); 2564 cache.SetAt(i + kArgsDescIndex, args_desc);
2564 cache.SetAt(i + kFunctionIndex, dispatcher); 2565 cache.SetAt(i + kFunctionIndex, dispatcher);
2565 } 2566 }
2566 return dispatcher.raw(); 2567 return dispatcher.raw();
2567 } 2568 }
2568 2569
2569 2570
2570 RawFunction* Class::CreateInvocationDispatcher(const String& target_name, 2571 RawFunction* Class::CreateInvocationDispatcher(const String& target_name,
2571 const Array& args_desc, 2572 const Array& args_desc,
2572 RawFunction::Kind kind) const { 2573 RawFunction::Kind kind) const {
2573 Function& invocation = Function::Handle( 2574 Thread* thread = Thread::Current();
2574 Function::New(String::Handle(Symbols::New(target_name)), 2575 Zone* zone = thread->zone();
2576 Function& invocation = Function::Handle(zone,
2577 Function::New(String::Handle(zone, Symbols::New(thread, target_name)),
2575 kind, 2578 kind,
2576 false, // Not static. 2579 false, // Not static.
2577 false, // Not const. 2580 false, // Not const.
2578 false, // Not abstract. 2581 false, // Not abstract.
2579 false, // Not external. 2582 false, // Not external.
2580 false, // Not native. 2583 false, // Not native.
2581 *this, 2584 *this,
2582 TokenPosition::kMinSource)); 2585 TokenPosition::kMinSource));
2583 ArgumentsDescriptor desc(args_desc); 2586 ArgumentsDescriptor desc(args_desc);
2584 invocation.set_num_fixed_parameters(desc.PositionalCount()); 2587 invocation.set_num_fixed_parameters(desc.PositionalCount());
2585 invocation.SetNumOptionalParameters(desc.NamedCount(), 2588 invocation.SetNumOptionalParameters(desc.NamedCount(),
2586 false); // Not positional. 2589 false); // Not positional.
2587 invocation.set_parameter_types(Array::Handle(Array::New(desc.Count(), 2590 invocation.set_parameter_types(Array::Handle(zone, Array::New(desc.Count(),
2588 Heap::kOld))); 2591 Heap::kOld)));
2589 invocation.set_parameter_names(Array::Handle(Array::New(desc.Count(), 2592 invocation.set_parameter_names(Array::Handle(zone, Array::New(desc.Count(),
2590 Heap::kOld))); 2593 Heap::kOld)));
2591 // Receiver. 2594 // Receiver.
2592 invocation.SetParameterTypeAt(0, Object::dynamic_type()); 2595 invocation.SetParameterTypeAt(0, Object::dynamic_type());
2593 invocation.SetParameterNameAt(0, Symbols::This()); 2596 invocation.SetParameterNameAt(0, Symbols::This());
2594 // Remaining positional parameters. 2597 // Remaining positional parameters.
2595 intptr_t i = 1; 2598 intptr_t i = 1;
2596 for (; i < desc.PositionalCount(); i++) { 2599 for (; i < desc.PositionalCount(); i++) {
2597 invocation.SetParameterTypeAt(i, Object::dynamic_type()); 2600 invocation.SetParameterTypeAt(i, Object::dynamic_type());
2598 char name[64]; 2601 char name[64];
2599 OS::SNPrint(name, 64, ":p%" Pd, i); 2602 OS::SNPrint(name, 64, ":p%" Pd, i);
2600 invocation.SetParameterNameAt(i, String::Handle(Symbols::New(name))); 2603 invocation.SetParameterNameAt(i, String::Handle(zone,
2604 Symbols::New(thread, name)));
2601 } 2605 }
2602 2606
2603 // Named parameters. 2607 // Named parameters.
2604 for (; i < desc.Count(); i++) { 2608 for (; i < desc.Count(); i++) {
2605 invocation.SetParameterTypeAt(i, Object::dynamic_type()); 2609 invocation.SetParameterTypeAt(i, Object::dynamic_type());
2606 intptr_t index = i - desc.PositionalCount(); 2610 intptr_t index = i - desc.PositionalCount();
2607 invocation.SetParameterNameAt(i, String::Handle(desc.NameAt(index))); 2611 invocation.SetParameterNameAt(i, String::Handle(zone, desc.NameAt(index)));
2608 } 2612 }
2609 invocation.set_result_type(Object::dynamic_type()); 2613 invocation.set_result_type(Object::dynamic_type());
2610 invocation.set_is_debuggable(false); 2614 invocation.set_is_debuggable(false);
2611 invocation.set_is_visible(false); 2615 invocation.set_is_visible(false);
2612 invocation.set_is_reflectable(false); 2616 invocation.set_is_reflectable(false);
2613 invocation.set_saved_args_desc(args_desc); 2617 invocation.set_saved_args_desc(args_desc);
2614 2618
2615 return invocation.raw(); 2619 return invocation.raw();
2616 } 2620 }
2617 2621
2618 2622
2619 // Method extractors are used to create implicit closures from methods. 2623 // Method extractors are used to create implicit closures from methods.
2620 // When an expression obj.M is evaluated for the first time and receiver obj 2624 // When an expression obj.M is evaluated for the first time and receiver obj
2621 // does not have a getter called M but has a method called M then an extractor 2625 // does not have a getter called M but has a method called M then an extractor
2622 // is created and injected as a getter (under the name get:M) into the class 2626 // is created and injected as a getter (under the name get:M) into the class
2623 // owning method M. 2627 // owning method M.
2624 RawFunction* Function::CreateMethodExtractor(const String& getter_name) const { 2628 RawFunction* Function::CreateMethodExtractor(const String& getter_name) const {
2629 Thread* thread = Thread::Current();
2630 Zone* zone = thread->zone();
2625 ASSERT(Field::IsGetterName(getter_name)); 2631 ASSERT(Field::IsGetterName(getter_name));
2626 const Function& closure_function = 2632 const Function& closure_function =
2627 Function::Handle(ImplicitClosureFunction()); 2633 Function::Handle(zone, ImplicitClosureFunction());
2628 2634
2629 const Class& owner = Class::Handle(closure_function.Owner()); 2635 const Class& owner = Class::Handle(zone, closure_function.Owner());
2630 Function& extractor = Function::Handle( 2636 Function& extractor = Function::Handle(zone,
2631 Function::New(String::Handle(Symbols::New(getter_name)), 2637 Function::New(String::Handle(zone, Symbols::New(thread, getter_name)),
2632 RawFunction::kMethodExtractor, 2638 RawFunction::kMethodExtractor,
2633 false, // Not static. 2639 false, // Not static.
2634 false, // Not const. 2640 false, // Not const.
2635 false, // Not abstract. 2641 false, // Not abstract.
2636 false, // Not external. 2642 false, // Not external.
2637 false, // Not native. 2643 false, // Not native.
2638 owner, 2644 owner,
2639 TokenPosition::kMethodExtractor)); 2645 TokenPosition::kMethodExtractor));
2640 2646
2641 // Initialize signature: receiver is a single fixed parameter. 2647 // Initialize signature: receiver is a single fixed parameter.
(...skipping 1858 matching lines...) Expand 10 before | Expand all | Expand 10 after
4500 4506
4501 4507
4502 void UnresolvedClass::set_library_prefix( 4508 void UnresolvedClass::set_library_prefix(
4503 const LibraryPrefix& library_prefix) const { 4509 const LibraryPrefix& library_prefix) const {
4504 StorePointer(&raw_ptr()->library_prefix_, library_prefix.raw()); 4510 StorePointer(&raw_ptr()->library_prefix_, library_prefix.raw());
4505 } 4511 }
4506 4512
4507 4513
4508 RawString* UnresolvedClass::Name() const { 4514 RawString* UnresolvedClass::Name() const {
4509 if (library_prefix() != LibraryPrefix::null()) { 4515 if (library_prefix() != LibraryPrefix::null()) {
4510 const LibraryPrefix& lib_prefix = LibraryPrefix::Handle(library_prefix()); 4516 Thread* thread = Thread::Current();
4511 String& name = String::Handle(); 4517 Zone* zone = thread->zone();
4512 name = lib_prefix.name(); // Qualifier. 4518 const LibraryPrefix& lib_prefix = LibraryPrefix::Handle(zone,
4513 Zone* zone = Thread::Current()->zone(); 4519 library_prefix());
4520 const String& name = String::Handle(zone, lib_prefix.name()); // Qualifier.
4514 GrowableHandlePtrArray<const String> strs(zone, 3); 4521 GrowableHandlePtrArray<const String> strs(zone, 3);
4515 strs.Add(name); 4522 strs.Add(name);
4516 strs.Add(Symbols::Dot()); 4523 strs.Add(Symbols::Dot());
4517 strs.Add(String::Handle(zone, ident())); 4524 strs.Add(String::Handle(zone, ident()));
4518 return Symbols::FromConcatAll(strs); 4525 return Symbols::FromConcatAll(thread, strs);
4519 } else { 4526 } else {
4520 return ident(); 4527 return ident();
4521 } 4528 }
4522 } 4529 }
4523 4530
4524 4531
4525 const char* UnresolvedClass::ToCString() const { 4532 const char* UnresolvedClass::ToCString() const {
4526 const char* cname = String::Handle(Name()).ToCString(); 4533 const char* cname = String::Handle(Name()).ToCString();
4527 return OS::SCreate(Thread::Current()->zone(), 4534 return OS::SCreate(Thread::Current()->zone(),
4528 "unresolved class '%s'", cname); 4535 "unresolved class '%s'", cname);
(...skipping 28 matching lines...) Expand all
4557 // purposes only) while a type argument is still temporarily null. 4564 // purposes only) while a type argument is still temporarily null.
4558 result = CombineHashes(result, type.IsNull() ? 0 : type.Hash()); 4565 result = CombineHashes(result, type.IsNull() ? 0 : type.Hash());
4559 } 4566 }
4560 return FinalizeHash(result); 4567 return FinalizeHash(result);
4561 } 4568 }
4562 4569
4563 4570
4564 RawString* TypeArguments::SubvectorName(intptr_t from_index, 4571 RawString* TypeArguments::SubvectorName(intptr_t from_index,
4565 intptr_t len, 4572 intptr_t len,
4566 NameVisibility name_visibility) const { 4573 NameVisibility name_visibility) const {
4567 Zone* zone = Thread::Current()->zone(); 4574 Thread* thread = Thread::Current();
4575 Zone* zone = thread->zone();
4568 ASSERT(from_index + len <= Length()); 4576 ASSERT(from_index + len <= Length());
4569 String& name = String::Handle(zone); 4577 String& name = String::Handle(zone);
4570 const intptr_t num_strings = (len == 0) ? 2 : 2*len + 1; // "<""T"", ""T"">". 4578 const intptr_t num_strings = (len == 0) ? 2 : 2*len + 1; // "<""T"", ""T"">".
4571 GrowableHandlePtrArray<const String> pieces(zone, num_strings); 4579 GrowableHandlePtrArray<const String> pieces(zone, num_strings);
4572 pieces.Add(Symbols::LAngleBracket()); 4580 pieces.Add(Symbols::LAngleBracket());
4573 AbstractType& type = AbstractType::Handle(); 4581 AbstractType& type = AbstractType::Handle(zone);
4574 for (intptr_t i = 0; i < len; i++) { 4582 for (intptr_t i = 0; i < len; i++) {
4575 type = TypeAt(from_index + i); 4583 type = TypeAt(from_index + i);
4576 name = type.BuildName(name_visibility); 4584 name = type.BuildName(name_visibility);
4577 pieces.Add(name); 4585 pieces.Add(name);
4578 if (i < len - 1) { 4586 if (i < len - 1) {
4579 pieces.Add(Symbols::CommaSpace()); 4587 pieces.Add(Symbols::CommaSpace());
4580 } 4588 }
4581 } 4589 }
4582 pieces.Add(Symbols::RAngleBracket()); 4590 pieces.Add(Symbols::RAngleBracket());
4583 ASSERT(pieces.length() == num_strings); 4591 ASSERT(pieces.length() == num_strings);
4584 return Symbols::FromConcatAll(pieces); 4592 return Symbols::FromConcatAll(thread, pieces);
4585 } 4593 }
4586 4594
4587 4595
4588 bool TypeArguments::IsSubvectorEquivalent(const TypeArguments& other, 4596 bool TypeArguments::IsSubvectorEquivalent(const TypeArguments& other,
4589 intptr_t from_index, 4597 intptr_t from_index,
4590 intptr_t len, 4598 intptr_t len,
4591 TrailPtr trail) const { 4599 TrailPtr trail) const {
4592 if (this->raw() == other.raw()) { 4600 if (this->raw() == other.raw()) {
4593 return true; 4601 return true;
4594 } 4602 }
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
5232 ASSERT(result.IsTypeArguments()); 5240 ASSERT(result.IsTypeArguments());
5233 ASSERT(result.IsCanonical()); 5241 ASSERT(result.IsCanonical());
5234 return result.raw(); 5242 return result.raw();
5235 } 5243 }
5236 5244
5237 5245
5238 RawString* TypeArguments::EnumerateURIs() const { 5246 RawString* TypeArguments::EnumerateURIs() const {
5239 if (IsNull()) { 5247 if (IsNull()) {
5240 return Symbols::Empty().raw(); 5248 return Symbols::Empty().raw();
5241 } 5249 }
5242 Zone* zone = Thread::Current()->zone(); 5250 Thread* thread = Thread::Current();
5251 Zone* zone = thread->zone();
5243 AbstractType& type = AbstractType::Handle(zone); 5252 AbstractType& type = AbstractType::Handle(zone);
5244 const intptr_t num_types = Length(); 5253 const intptr_t num_types = Length();
5245 GrowableHandlePtrArray<const String> pieces(zone, num_types); 5254 const Array& pieces = Array::Handle(zone, Array::New(num_types));
5246 for (intptr_t i = 0; i < num_types; i++) { 5255 for (intptr_t i = 0; i < num_types; i++) {
5247 type = TypeAt(i); 5256 type = TypeAt(i);
5248 pieces.Add(String::Handle(zone, type.EnumerateURIs())); 5257 pieces.SetAt(i, String::Handle(zone, type.EnumerateURIs()));
5249 } 5258 }
5250 return Symbols::FromConcatAll(pieces); 5259 return String::ConcatAll(pieces);
5251 } 5260 }
5252 5261
5253 5262
5254 const char* TypeArguments::ToCString() const { 5263 const char* TypeArguments::ToCString() const {
5255 if (IsNull()) { 5264 if (IsNull()) {
5256 return "NULL TypeArguments"; 5265 return "NULL TypeArguments";
5257 } 5266 }
5258 const char* prev_cstr = "TypeArguments:"; 5267 const char* prev_cstr = "TypeArguments:";
5259 for (int i = 0; i < Length(); i++) { 5268 for (int i = 0; i < Length(); i++) {
5260 const AbstractType& type_at = AbstractType::Handle(TypeAt(i)); 5269 const AbstractType& type_at = AbstractType::Handle(TypeAt(i));
(...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after
6651 result.set_is_reflectable(false); 6660 result.set_is_reflectable(false);
6652 result.set_is_visible(false); 6661 result.set_is_visible(false);
6653 result.set_is_debuggable(false); 6662 result.set_is_debuggable(false);
6654 return result.raw(); 6663 return result.raw();
6655 } 6664 }
6656 6665
6657 6666
6658 RawFunction* Function::NewEvalFunction(const Class& owner, 6667 RawFunction* Function::NewEvalFunction(const Class& owner,
6659 const Script& script, 6668 const Script& script,
6660 bool is_static) { 6669 bool is_static) {
6661 const Function& result = Function::Handle( 6670 Thread* thread = Thread::Current();
6662 Function::New(String::Handle(Symbols::New(":Eval")), 6671 Zone* zone = thread->zone();
6672 const Function& result = Function::Handle(zone,
6673 Function::New(String::Handle(Symbols::New(thread, ":Eval")),
6663 RawFunction::kRegularFunction, 6674 RawFunction::kRegularFunction,
6664 is_static, 6675 is_static,
6665 /* is_const = */ false, 6676 /* is_const = */ false,
6666 /* is_abstract = */ false, 6677 /* is_abstract = */ false,
6667 /* is_external = */ false, 6678 /* is_external = */ false,
6668 /* is_native = */ false, 6679 /* is_native = */ false,
6669 owner, 6680 owner,
6670 TokenPosition::kMinSource)); 6681 TokenPosition::kMinSource));
6671 ASSERT(!script.IsNull()); 6682 ASSERT(!script.IsNull());
6672 result.set_is_debuggable(false); 6683 result.set_is_debuggable(false);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
6748 if (implicit_closure_function() != Function::null()) { 6759 if (implicit_closure_function() != Function::null()) {
6749 const Function& func = Function::Handle(implicit_closure_function()); 6760 const Function& func = Function::Handle(implicit_closure_function());
6750 if (!func.HasCode()) { 6761 if (!func.HasCode()) {
6751 set_implicit_closure_function(Function::Handle()); 6762 set_implicit_closure_function(Function::Handle());
6752 } 6763 }
6753 } 6764 }
6754 } 6765 }
6755 6766
6756 6767
6757 RawString* Function::UserVisibleFormalParameters() const { 6768 RawString* Function::UserVisibleFormalParameters() const {
6769 Thread* thread = Thread::Current();
6770 Zone* zone = thread->zone();
6758 // Typically 3, 5,.. elements in 'pieces', e.g.: 6771 // Typically 3, 5,.. elements in 'pieces', e.g.:
6759 // '_LoadRequest', CommaSpace, '_LoadError'. 6772 // '_LoadRequest', CommaSpace, '_LoadError'.
6760 GrowableHandlePtrArray<const String> pieces(Thread::Current()->zone(), 5); 6773 GrowableHandlePtrArray<const String> pieces(zone, 5);
6761 const TypeArguments& instantiator = TypeArguments::Handle(); 6774 const TypeArguments& instantiator = TypeArguments::Handle(zone);
6762 BuildSignatureParameters(false, kUserVisibleName, instantiator, &pieces); 6775 BuildSignatureParameters(thread, zone,
6763 return Symbols::FromConcatAll(pieces); 6776 false, kUserVisibleName, instantiator, &pieces);
6777 return Symbols::FromConcatAll(thread, pieces);
6764 } 6778 }
6765 6779
6766 6780
6767 void Function::BuildSignatureParameters( 6781 void Function::BuildSignatureParameters(
6782 Thread* thread,
6783 Zone* zone,
6768 bool instantiate, 6784 bool instantiate,
6769 NameVisibility name_visibility, 6785 NameVisibility name_visibility,
6770 const TypeArguments& instantiator, 6786 const TypeArguments& instantiator,
6771 GrowableHandlePtrArray<const String>* pieces) const { 6787 GrowableHandlePtrArray<const String>* pieces) const {
6772 Thread* thread = Thread::Current();
6773 Zone* zone = thread->zone();
6774
6775 AbstractType& param_type = AbstractType::Handle(zone); 6788 AbstractType& param_type = AbstractType::Handle(zone);
6776 const intptr_t num_params = NumParameters(); 6789 const intptr_t num_params = NumParameters();
6777 const intptr_t num_fixed_params = num_fixed_parameters(); 6790 const intptr_t num_fixed_params = num_fixed_parameters();
6778 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters(); 6791 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters();
6779 const intptr_t num_opt_named_params = NumOptionalNamedParameters(); 6792 const intptr_t num_opt_named_params = NumOptionalNamedParameters();
6780 const intptr_t num_opt_params = num_opt_pos_params + num_opt_named_params; 6793 const intptr_t num_opt_params = num_opt_pos_params + num_opt_named_params;
6781 ASSERT((num_fixed_params + num_opt_params) == num_params); 6794 ASSERT((num_fixed_params + num_opt_params) == num_params);
6782 intptr_t i = 0; 6795 intptr_t i = 0;
6783 if (name_visibility == kUserVisibleName) { 6796 if (name_visibility == kUserVisibleName) {
6784 // Hide implicit parameters. 6797 // Hide implicit parameters.
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
6904 pieces.Add(name); 6917 pieces.Add(name);
6905 } 6918 }
6906 if (i < num_type_parameters - 1) { 6919 if (i < num_type_parameters - 1) {
6907 pieces.Add(Symbols::CommaSpace()); 6920 pieces.Add(Symbols::CommaSpace());
6908 } 6921 }
6909 } 6922 }
6910 pieces.Add(Symbols::RAngleBracket()); 6923 pieces.Add(Symbols::RAngleBracket());
6911 } 6924 }
6912 } 6925 }
6913 pieces.Add(Symbols::LParen()); 6926 pieces.Add(Symbols::LParen());
6914 BuildSignatureParameters(instantiate, 6927 BuildSignatureParameters(thread, zone,
6928 instantiate,
6915 name_visibility, 6929 name_visibility,
6916 instantiator, 6930 instantiator,
6917 &pieces); 6931 &pieces);
6918 pieces.Add(Symbols::RParenArrow()); 6932 pieces.Add(Symbols::RParenArrow());
6919 AbstractType& res_type = AbstractType::Handle(zone, result_type()); 6933 AbstractType& res_type = AbstractType::Handle(zone, result_type());
6920 if (instantiate && res_type.IsFinalized() && !res_type.IsInstantiated()) { 6934 if (instantiate && res_type.IsFinalized() && !res_type.IsInstantiated()) {
6921 res_type = res_type.InstantiateFrom(instantiator, NULL, 6935 res_type = res_type.InstantiateFrom(instantiator, NULL,
6922 NULL, NULL, Heap::kNew); 6936 NULL, NULL, Heap::kNew);
6923 } 6937 }
6924 name = res_type.BuildName(name_visibility); 6938 name = res_type.BuildName(name_visibility);
6925 pieces.Add(name); 6939 pieces.Add(name);
6926 return Symbols::FromConcatAll(pieces); 6940 return Symbols::FromConcatAll(thread, pieces);
6927 } 6941 }
6928 6942
6929 6943
6930 bool Function::HasInstantiatedSignature() const { 6944 bool Function::HasInstantiatedSignature() const {
6931 AbstractType& type = AbstractType::Handle(result_type()); 6945 AbstractType& type = AbstractType::Handle(result_type());
6932 if (!type.IsInstantiated()) { 6946 if (!type.IsInstantiated()) {
6933 return false; 6947 return false;
6934 } 6948 }
6935 const intptr_t num_parameters = NumParameters(); 6949 const intptr_t num_parameters = NumParameters();
6936 for (intptr_t i = 0; i < num_parameters; i++) { 6950 for (intptr_t i = 0; i < num_parameters; i++) {
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
7340 StorePointer(&raw_ptr()->owner_, reinterpret_cast<RawObject*>(value.raw())); 7354 StorePointer(&raw_ptr()->owner_, reinterpret_cast<RawObject*>(value.raw()));
7341 } 7355 }
7342 7356
7343 7357
7344 RawString* Field::GetterName(const String& field_name) { 7358 RawString* Field::GetterName(const String& field_name) {
7345 return String::Concat(Symbols::GetterPrefix(), field_name); 7359 return String::Concat(Symbols::GetterPrefix(), field_name);
7346 } 7360 }
7347 7361
7348 7362
7349 RawString* Field::GetterSymbol(const String& field_name) { 7363 RawString* Field::GetterSymbol(const String& field_name) {
7350 return Symbols::FromConcat(Symbols::GetterPrefix(), field_name); 7364 return Symbols::FromGet(Thread::Current(), field_name);
7351 } 7365 }
7352 7366
7353 7367
7354 RawString* Field::LookupGetterSymbol(const String& field_name) { 7368 RawString* Field::LookupGetterSymbol(const String& field_name) {
7355 return Symbols::LookupFromConcat(Symbols::GetterPrefix(), field_name); 7369 return Symbols::LookupFromGet(Thread::Current(), field_name);
7356 } 7370 }
7357 7371
7358 7372
7359 RawString* Field::SetterName(const String& field_name) { 7373 RawString* Field::SetterName(const String& field_name) {
7360 return String::Concat(Symbols::SetterPrefix(), field_name); 7374 return String::Concat(Symbols::SetterPrefix(), field_name);
7361 } 7375 }
7362 7376
7363 7377
7364 RawString* Field::SetterSymbol(const String& field_name) { 7378 RawString* Field::SetterSymbol(const String& field_name) {
7365 return Symbols::FromConcat(Symbols::SetterPrefix(), field_name); 7379 return Symbols::FromSet(Thread::Current(), field_name);
7366 } 7380 }
7367 7381
7368 7382
7369 RawString* Field::LookupSetterSymbol(const String& field_name) { 7383 RawString* Field::LookupSetterSymbol(const String& field_name) {
7370 return Symbols::LookupFromConcat(Symbols::SetterPrefix(), field_name); 7384 return Symbols::LookupFromSet(Thread::Current(), field_name);
7371 } 7385 }
7372 7386
7373 7387
7374 RawString* Field::NameFromGetter(const String& getter_name) { 7388 RawString* Field::NameFromGetter(const String& getter_name) {
7375 return Symbols::New(getter_name, kGetterPrefixLength, 7389 return Symbols::New(Thread::Current(), getter_name, kGetterPrefixLength,
7376 getter_name.Length() - kGetterPrefixLength); 7390 getter_name.Length() - kGetterPrefixLength);
7377 } 7391 }
7378 7392
7379 7393
7380 RawString* Field::NameFromSetter(const String& setter_name) { 7394 RawString* Field::NameFromSetter(const String& setter_name) {
7381 return Symbols::New(setter_name, kSetterPrefixLength, 7395 return Symbols::New(Thread::Current(), setter_name, kSetterPrefixLength,
7382 setter_name.Length() - kSetterPrefixLength); 7396 setter_name.Length() - kSetterPrefixLength);
7383 } 7397 }
7384 7398
7385 7399
7386 bool Field::IsGetterName(const String& function_name) { 7400 bool Field::IsGetterName(const String& function_name) {
7387 return function_name.StartsWith(Symbols::GetterPrefix()); 7401 return function_name.StartsWith(Symbols::GetterPrefix());
7388 } 7402 }
7389 7403
7390 7404
7391 bool Field::IsSetterName(const String& function_name) { 7405 bool Field::IsSetterName(const String& function_name) {
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
7614 const char* cls_name = String::Handle(cls.Name()).ToCString(); 7628 const char* cls_name = String::Handle(cls.Name()).ToCString();
7615 return OS::SCreate(Thread::Current()->zone(), 7629 return OS::SCreate(Thread::Current()->zone(),
7616 "Field <%s.%s>:%s%s%s", cls_name, field_name, kF0, kF1, kF2); 7630 "Field <%s.%s>:%s%s%s", cls_name, field_name, kF0, kF1, kF2);
7617 } 7631 }
7618 7632
7619 7633
7620 // Build a closure object that gets (or sets) the contents of a static 7634 // Build a closure object that gets (or sets) the contents of a static
7621 // field f and cache the closure in a newly created static field 7635 // field f and cache the closure in a newly created static field
7622 // named #f (or #f= in case of a setter). 7636 // named #f (or #f= in case of a setter).
7623 RawInstance* Field::AccessorClosure(bool make_setter) const { 7637 RawInstance* Field::AccessorClosure(bool make_setter) const {
7638 Thread* thread = Thread::Current();
7639 Zone* zone = thread->zone();
7624 ASSERT(is_static()); 7640 ASSERT(is_static());
7625 const Class& field_owner = Class::Handle(Owner()); 7641 const Class& field_owner = Class::Handle(zone, Owner());
7626 7642
7627 String& closure_name = String::Handle(this->name()); 7643 String& closure_name = String::Handle(zone, this->name());
7628 closure_name = Symbols::FromConcat(Symbols::HashMark(), closure_name); 7644 closure_name = Symbols::FromConcat(thread, Symbols::HashMark(), closure_name);
7629 if (make_setter) { 7645 if (make_setter) {
7630 closure_name = Symbols::FromConcat(Symbols::HashMark(), closure_name); 7646 closure_name = Symbols::FromConcat(thread,
7647 Symbols::HashMark(), closure_name);
7631 } 7648 }
7632 7649
7633 Field& closure_field = Field::Handle(); 7650 Field& closure_field = Field::Handle(zone);
7634 closure_field = field_owner.LookupStaticField(closure_name); 7651 closure_field = field_owner.LookupStaticField(closure_name);
7635 if (!closure_field.IsNull()) { 7652 if (!closure_field.IsNull()) {
7636 ASSERT(closure_field.is_static()); 7653 ASSERT(closure_field.is_static());
7637 const Instance& closure = 7654 const Instance& closure = Instance::Handle(zone,
7638 Instance::Handle(closure_field.StaticValue()); 7655 closure_field.StaticValue());
7639 ASSERT(!closure.IsNull()); 7656 ASSERT(!closure.IsNull());
7640 ASSERT(closure.IsClosure()); 7657 ASSERT(closure.IsClosure());
7641 return closure.raw(); 7658 return closure.raw();
7642 } 7659 }
7643 7660
7644 // This is the first time a closure for this field is requested. 7661 // This is the first time a closure for this field is requested.
7645 // Create the closure and a new static field in which it is stored. 7662 // Create the closure and a new static field in which it is stored.
7646 const char* field_name = String::Handle(name()).ToCString(); 7663 const char* field_name = String::Handle(zone, name()).ToCString();
7647 String& expr_src = String::Handle(); 7664 String& expr_src = String::Handle(zone);
7648 if (make_setter) { 7665 if (make_setter) {
7649 expr_src = 7666 expr_src =
7650 String::NewFormatted("(%s_) { return %s = %s_; }", 7667 String::NewFormatted("(%s_) { return %s = %s_; }",
7651 field_name, field_name, field_name); 7668 field_name, field_name, field_name);
7652 } else { 7669 } else {
7653 expr_src = String::NewFormatted("() { return %s; }", field_name); 7670 expr_src = String::NewFormatted("() { return %s; }", field_name);
7654 } 7671 }
7655 Object& result = 7672 Object& result = Object::Handle(zone,
7656 Object::Handle(field_owner.Evaluate(expr_src, 7673 field_owner.Evaluate(expr_src,
7657 Object::empty_array(), 7674 Object::empty_array(),
7658 Object::empty_array())); 7675 Object::empty_array()));
7659 ASSERT(result.IsInstance()); 7676 ASSERT(result.IsInstance());
7660 // The caller may expect the closure to be allocated in old space. Copy 7677 // The caller may expect the closure to be allocated in old space. Copy
7661 // the result here, since Object::Clone() is a private method. 7678 // the result here, since Object::Clone() is a private method.
7662 result = Object::Clone(result, Heap::kOld); 7679 result = Object::Clone(result, Heap::kOld);
7663 7680
7664 closure_field = Field::New(closure_name, 7681 closure_field = Field::New(closure_name,
7665 true, // is_static 7682 true, // is_static
7666 true, // is_final 7683 true, // is_final
7667 true, // is_const 7684 true, // is_const
7668 false, // is_reflectable 7685 false, // is_reflectable
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
8647 } 8664 }
8648 8665
8649 8666
8650 RawString* TokenStream::Iterator::MakeLiteralToken(const Object& obj) const { 8667 RawString* TokenStream::Iterator::MakeLiteralToken(const Object& obj) const {
8651 if (obj.IsString()) { 8668 if (obj.IsString()) {
8652 return reinterpret_cast<RawString*>(obj.raw()); 8669 return reinterpret_cast<RawString*>(obj.raw());
8653 } else if (obj.IsSmi()) { 8670 } else if (obj.IsSmi()) {
8654 Token::Kind kind = static_cast<Token::Kind>( 8671 Token::Kind kind = static_cast<Token::Kind>(
8655 Smi::Value(reinterpret_cast<RawSmi*>(obj.raw()))); 8672 Smi::Value(reinterpret_cast<RawSmi*>(obj.raw())));
8656 ASSERT(kind < Token::kNumTokens); 8673 ASSERT(kind < Token::kNumTokens);
8657 if (Token::IsPseudoKeyword(kind) || Token::IsKeyword(kind)) { 8674 return Symbols::Token(kind).raw();
8658 return Symbols::Keyword(kind).raw();
8659 }
8660 return Symbols::New(Token::Str(kind));
8661 } else { 8675 } else {
8662 ASSERT(obj.IsLiteralToken()); // Must be a literal token. 8676 ASSERT(obj.IsLiteralToken()); // Must be a literal token.
8663 const LiteralToken& literal_token = LiteralToken::Cast(obj); 8677 const LiteralToken& literal_token = LiteralToken::Cast(obj);
8664 return literal_token.literal(); 8678 return literal_token.literal();
8665 } 8679 }
8666 } 8680 }
8667 8681
8668 8682
8669 bool Script::HasSource() const { 8683 bool Script::HasSource() const {
8670 return raw_ptr()->source_ != String::null(); 8684 return raw_ptr()->source_ != String::null();
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
9047 RawObject* raw = Object::Allocate(Script::kClassId, 9061 RawObject* raw = Object::Allocate(Script::kClassId,
9048 Script::InstanceSize(), 9062 Script::InstanceSize(),
9049 Heap::kOld); 9063 Heap::kOld);
9050 return reinterpret_cast<RawScript*>(raw); 9064 return reinterpret_cast<RawScript*>(raw);
9051 } 9065 }
9052 9066
9053 9067
9054 RawScript* Script::New(const String& url, 9068 RawScript* Script::New(const String& url,
9055 const String& source, 9069 const String& source,
9056 RawScript::Kind kind) { 9070 RawScript::Kind kind) {
9057 const Script& result = Script::Handle(Script::New()); 9071 Thread* thread = Thread::Current();
9058 result.set_url(String::Handle(Symbols::New(url))); 9072 Zone* zone = thread->zone();
9073 const Script& result = Script::Handle(zone, Script::New());
9074 result.set_url(String::Handle(zone, Symbols::New(thread, url)));
9059 result.set_source(source); 9075 result.set_source(source);
9060 result.set_kind(kind); 9076 result.set_kind(kind);
9061 result.SetLocationOffset(0, 0); 9077 result.SetLocationOffset(0, 0);
9062 return result.raw(); 9078 return result.raw();
9063 } 9079 }
9064 9080
9065 9081
9066 const char* Script::ToCString() const { 9082 const char* Script::ToCString() const {
9067 return "Script"; 9083 return "Script";
9068 } 9084 }
9069 9085
9070 9086
9071 RawLibrary* Script::FindLibrary() const { 9087 RawLibrary* Script::FindLibrary() const {
9072 Thread* thread = Thread::Current(); 9088 Thread* thread = Thread::Current();
9073 Zone* zone = thread->zone(); 9089 Zone* zone = thread->zone();
9074 Isolate* isolate = thread->isolate(); 9090 Isolate* isolate = thread->isolate();
9075 const GrowableObjectArray& libs = GrowableObjectArray::Handle( 9091 const GrowableObjectArray& libs = GrowableObjectArray::Handle(zone,
9076 zone, isolate->object_store()->libraries()); 9092 isolate->object_store()->libraries());
9077 Library& lib = Library::Handle(); 9093 Library& lib = Library::Handle(zone);
9078 Array& scripts = Array::Handle(); 9094 Array& scripts = Array::Handle(zone);
9079 for (intptr_t i = 0; i < libs.Length(); i++) { 9095 for (intptr_t i = 0; i < libs.Length(); i++) {
9080 lib ^= libs.At(i); 9096 lib ^= libs.At(i);
9081 scripts = lib.LoadedScripts(); 9097 scripts = lib.LoadedScripts();
9082 for (intptr_t j = 0; j < scripts.Length(); j++) { 9098 for (intptr_t j = 0; j < scripts.Length(); j++) {
9083 if (scripts.At(j) == raw()) { 9099 if (scripts.At(j) == raw()) {
9084 return lib.raw(); 9100 return lib.raw();
9085 } 9101 }
9086 } 9102 }
9087 } 9103 }
9088 return Library::null(); 9104 return Library::null();
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
9323 if (i == num_classes) return; 9339 if (i == num_classes) return;
9324 // Replace the entry with the script. We keep the script so that 9340 // Replace the entry with the script. We keep the script so that
9325 // Library::LoadedScripts() can find it without having to iterate 9341 // Library::LoadedScripts() can find it without having to iterate
9326 // over the members of each class. 9342 // over the members of each class.
9327 ASSERT(i < num_classes); // We must have found a class. 9343 ASSERT(i < num_classes); // We must have found a class.
9328 const Script& patch_script = Script::Handle(cls.script()); 9344 const Script& patch_script = Script::Handle(cls.script());
9329 patch_classes.SetAt(i, patch_script); 9345 patch_classes.SetAt(i, patch_script);
9330 } 9346 }
9331 9347
9332 9348
9333 static RawString* MakeClassMetaName(const Class& cls) { 9349 static RawString* MakeClassMetaName(Thread* thread, Zone* zone,
9334 return Symbols::FromConcat(Symbols::At(), String::Handle(cls.Name())); 9350 const Class& cls) {
9351 return Symbols::FromConcat(thread,
9352 Symbols::At(), String::Handle(zone, cls.Name()));
9335 } 9353 }
9336 9354
9337 9355
9338 static RawString* MakeFieldMetaName(const Field& field) { 9356 static RawString* MakeFieldMetaName(Thread* thread, Zone* zone,
9339 const String& cname = 9357 const Field& field) {
9340 String::Handle(MakeClassMetaName(Class::Handle(field.Origin()))); 9358 const String& cname = String::Handle(zone,
9341 GrowableHandlePtrArray<const String> pieces(Thread::Current()->zone(), 3); 9359 MakeClassMetaName(thread, zone, Class::Handle(zone, field.Origin())));
9360 GrowableHandlePtrArray<const String> pieces(zone, 3);
9342 pieces.Add(cname); 9361 pieces.Add(cname);
9343 pieces.Add(Symbols::At()); 9362 pieces.Add(Symbols::At());
9344 pieces.Add(String::Handle(field.name())); 9363 pieces.Add(String::Handle(field.name()));
9345 return Symbols::FromConcatAll(pieces); 9364 return Symbols::FromConcatAll(thread, pieces);
9346 } 9365 }
9347 9366
9348 9367
9349 static RawString* MakeFunctionMetaName(const Function& func) { 9368 static RawString* MakeFunctionMetaName(Thread* thread, Zone* zone,
9350 const String& cname = 9369 const Function& func) {
9351 String::Handle(MakeClassMetaName(Class::Handle(func.origin()))); 9370 const String& cname = String::Handle(zone,
9352 GrowableHandlePtrArray<const String> pieces(Thread::Current()->zone(), 3); 9371 MakeClassMetaName(thread, zone, Class::Handle(zone, func.origin())));
9372 GrowableHandlePtrArray<const String> pieces(zone, 3);
9353 pieces.Add(cname); 9373 pieces.Add(cname);
9354 pieces.Add(Symbols::At()); 9374 pieces.Add(Symbols::At());
9355 pieces.Add(String::Handle(func.QualifiedScrubbedName())); 9375 pieces.Add(String::Handle(func.QualifiedScrubbedName()));
9356 return Symbols::FromConcatAll(pieces); 9376 return Symbols::FromConcatAll(thread, pieces);
9357 } 9377 }
9358 9378
9359 9379
9360 static RawString* MakeTypeParameterMetaName(const TypeParameter& param) { 9380 static RawString* MakeTypeParameterMetaName(Thread* thread, Zone* zone,
9361 const String& cname = String::Handle( 9381 const TypeParameter& param) {
9362 MakeClassMetaName(Class::Handle(param.parameterized_class()))); 9382 const String& cname = String::Handle(zone,
9363 GrowableHandlePtrArray<const String> pieces(Thread::Current()->zone(), 3); 9383 MakeClassMetaName(thread, zone,
9384 Class::Handle(zone, param.parameterized_class())));
9385 GrowableHandlePtrArray<const String> pieces(zone, 3);
9364 pieces.Add(cname); 9386 pieces.Add(cname);
9365 pieces.Add(Symbols::At()); 9387 pieces.Add(Symbols::At());
9366 pieces.Add(String::Handle(param.name())); 9388 pieces.Add(String::Handle(param.name()));
9367 return Symbols::FromConcatAll(pieces); 9389 return Symbols::FromConcatAll(thread, pieces);
9368 } 9390 }
9369 9391
9370 9392
9371 void Library::AddMetadata(const Object& owner, 9393 void Library::AddMetadata(const Object& owner,
9372 const String& name, 9394 const String& name,
9373 TokenPosition token_pos) const { 9395 TokenPosition token_pos) const {
9374 const String& metaname = String::Handle(Symbols::New(name)); 9396 Thread* thread = Thread::Current();
9375 const Field& field = Field::Handle( 9397 Zone* zone = thread->zone();
9398 const String& metaname = String::Handle(zone, Symbols::New(thread, name));
9399 const Field& field = Field::Handle(zone,
9376 Field::NewTopLevel(metaname, 9400 Field::NewTopLevel(metaname,
9377 false, // is_final 9401 false, // is_final
9378 false, // is_const 9402 false, // is_const
9379 owner, 9403 owner,
9380 token_pos)); 9404 token_pos));
9381 field.SetFieldType(Object::dynamic_type()); 9405 field.SetFieldType(Object::dynamic_type());
9382 field.set_is_reflectable(false); 9406 field.set_is_reflectable(false);
9383 field.SetStaticValue(Array::empty_array(), true); 9407 field.SetStaticValue(Array::empty_array(), true);
9384 GrowableObjectArray& metadata = 9408 GrowableObjectArray& metadata =
9385 GrowableObjectArray::Handle(this->metadata()); 9409 GrowableObjectArray::Handle(zone, this->metadata());
9386 metadata.Add(field, Heap::kOld); 9410 metadata.Add(field, Heap::kOld);
9387 } 9411 }
9388 9412
9389 9413
9390 void Library::AddClassMetadata(const Class& cls, 9414 void Library::AddClassMetadata(const Class& cls,
9391 const Object& tl_owner, 9415 const Object& tl_owner,
9392 TokenPosition token_pos) const { 9416 TokenPosition token_pos) const {
9417 Thread* thread = Thread::Current();
9418 Zone* zone = thread->zone();
9393 // We use the toplevel class as the owner of a class's metadata field because 9419 // We use the toplevel class as the owner of a class's metadata field because
9394 // a class's metadata is in scope of the library, not the class. 9420 // a class's metadata is in scope of the library, not the class.
9395 AddMetadata(tl_owner, 9421 AddMetadata(tl_owner,
9396 String::Handle(MakeClassMetaName(cls)), 9422 String::Handle(zone, MakeClassMetaName(thread, zone, cls)),
9397 token_pos); 9423 token_pos);
9398 } 9424 }
9399 9425
9400 9426
9401 void Library::AddFieldMetadata(const Field& field, 9427 void Library::AddFieldMetadata(const Field& field,
9402 TokenPosition token_pos) const { 9428 TokenPosition token_pos) const {
9403 AddMetadata(Object::Handle(field.RawOwner()), 9429 Thread* thread = Thread::Current();
9404 String::Handle(MakeFieldMetaName(field)), 9430 Zone* zone = thread->zone();
9431 AddMetadata(Object::Handle(zone, field.RawOwner()),
9432 String::Handle(zone, MakeFieldMetaName(thread, zone, field)),
9405 token_pos); 9433 token_pos);
9406 } 9434 }
9407 9435
9408 9436
9409 void Library::AddFunctionMetadata(const Function& func, 9437 void Library::AddFunctionMetadata(const Function& func,
9410 TokenPosition token_pos) const { 9438 TokenPosition token_pos) const {
9411 AddMetadata(Object::Handle(func.RawOwner()), 9439 Thread* thread = Thread::Current();
9412 String::Handle(MakeFunctionMetaName(func)), 9440 Zone* zone = thread->zone();
9441 AddMetadata(Object::Handle(zone, func.RawOwner()),
9442 String::Handle(zone, MakeFunctionMetaName(thread, zone, func)),
9413 token_pos); 9443 token_pos);
9414 } 9444 }
9415 9445
9416 9446
9417 void Library::AddTypeParameterMetadata(const TypeParameter& param, 9447 void Library::AddTypeParameterMetadata(const TypeParameter& param,
9418 TokenPosition token_pos) const { 9448 TokenPosition token_pos) const {
9419 AddMetadata(Class::Handle(param.parameterized_class()), 9449 Thread* thread = Thread::Current();
9420 String::Handle(MakeTypeParameterMetaName(param)), 9450 Zone* zone = thread->zone();
9451 AddMetadata(Class::Handle(zone, param.parameterized_class()),
9452 String::Handle(zone,
9453 MakeTypeParameterMetaName(thread, zone, param)),
9421 token_pos); 9454 token_pos);
9422 } 9455 }
9423 9456
9424 9457
9425 void Library::AddLibraryMetadata(const Object& tl_owner, 9458 void Library::AddLibraryMetadata(const Object& tl_owner,
9426 TokenPosition token_pos) const { 9459 TokenPosition token_pos) const {
9427 AddMetadata(tl_owner, Symbols::TopLevel(), token_pos); 9460 AddMetadata(tl_owner, Symbols::TopLevel(), token_pos);
9428 } 9461 }
9429 9462
9430 9463
9431 RawString* Library::MakeMetadataName(const Object& obj) const { 9464 RawString* Library::MakeMetadataName(const Object& obj) const {
9465 Thread* thread = Thread::Current();
9466 Zone* zone = thread->zone();
9432 if (obj.IsClass()) { 9467 if (obj.IsClass()) {
9433 return MakeClassMetaName(Class::Cast(obj)); 9468 return MakeClassMetaName(thread, zone, Class::Cast(obj));
9434 } else if (obj.IsField()) { 9469 } else if (obj.IsField()) {
9435 return MakeFieldMetaName(Field::Cast(obj)); 9470 return MakeFieldMetaName(thread, zone, Field::Cast(obj));
9436 } else if (obj.IsFunction()) { 9471 } else if (obj.IsFunction()) {
9437 return MakeFunctionMetaName(Function::Cast(obj)); 9472 return MakeFunctionMetaName(thread, zone, Function::Cast(obj));
9438 } else if (obj.IsLibrary()) { 9473 } else if (obj.IsLibrary()) {
9439 return Symbols::TopLevel().raw(); 9474 return Symbols::TopLevel().raw();
9440 } else if (obj.IsTypeParameter()) { 9475 } else if (obj.IsTypeParameter()) {
9441 return MakeTypeParameterMetaName(TypeParameter::Cast(obj)); 9476 return MakeTypeParameterMetaName(thread, zone, TypeParameter::Cast(obj));
9442 } 9477 }
9443 UNIMPLEMENTED(); 9478 UNIMPLEMENTED();
9444 return String::null(); 9479 return String::null();
9445 } 9480 }
9446 9481
9447 9482
9448 RawField* Library::GetMetadataField(const String& metaname) const { 9483 RawField* Library::GetMetadataField(const String& metaname) const {
9449 const GrowableObjectArray& metadata = 9484 const GrowableObjectArray& metadata =
9450 GrowableObjectArray::Handle(this->metadata()); 9485 GrowableObjectArray::Handle(this->metadata());
9451 Field& entry = Field::Handle(); 9486 Field& entry = Field::Handle();
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
10301 const Array& param_values) const { 10336 const Array& param_values) const {
10302 // Evaluate the expression as a static function of the toplevel class. 10337 // Evaluate the expression as a static function of the toplevel class.
10303 Class& top_level_class = Class::Handle(toplevel_class()); 10338 Class& top_level_class = Class::Handle(toplevel_class());
10304 ASSERT(top_level_class.is_finalized()); 10339 ASSERT(top_level_class.is_finalized());
10305 return top_level_class.Evaluate(expr, param_names, param_values); 10340 return top_level_class.Evaluate(expr, param_names, param_values);
10306 } 10341 }
10307 10342
10308 10343
10309 void Library::InitNativeWrappersLibrary(Isolate* isolate) { 10344 void Library::InitNativeWrappersLibrary(Isolate* isolate) {
10310 static const int kNumNativeWrappersClasses = 4; 10345 static const int kNumNativeWrappersClasses = 4;
10311 ASSERT(kNumNativeWrappersClasses > 0 && kNumNativeWrappersClasses < 10); 10346 COMPILE_ASSERT((kNumNativeWrappersClasses > 0) &&
10347 (kNumNativeWrappersClasses < 10));
10348 Thread* thread = Thread::Current();
10349 Zone* zone = thread->zone();
10312 const String& native_flds_lib_url = Symbols::DartNativeWrappers(); 10350 const String& native_flds_lib_url = Symbols::DartNativeWrappers();
10313 const Library& native_flds_lib = Library::Handle( 10351 const Library& native_flds_lib = Library::Handle(zone,
10314 Library::NewLibraryHelper(native_flds_lib_url, false)); 10352 Library::NewLibraryHelper(native_flds_lib_url, false));
10315 const String& native_flds_lib_name = Symbols::DartNativeWrappersLibName(); 10353 const String& native_flds_lib_name = Symbols::DartNativeWrappersLibName();
10316 native_flds_lib.SetName(native_flds_lib_name); 10354 native_flds_lib.SetName(native_flds_lib_name);
10317 native_flds_lib.SetLoadRequested(); 10355 native_flds_lib.SetLoadRequested();
10318 native_flds_lib.Register(); 10356 native_flds_lib.Register();
10319 native_flds_lib.SetLoadInProgress(); 10357 native_flds_lib.SetLoadInProgress();
10320 isolate->object_store()->set_native_wrappers_library(native_flds_lib); 10358 isolate->object_store()->set_native_wrappers_library(native_flds_lib);
10321 static const char* const kNativeWrappersClass = "NativeFieldWrapperClass"; 10359 static const char* const kNativeWrappersClass = "NativeFieldWrapperClass";
10322 static const int kNameLength = 25; 10360 static const int kNameLength = 25;
10323 ASSERT(kNameLength == (strlen(kNativeWrappersClass) + 1 + 1)); 10361 ASSERT(kNameLength == (strlen(kNativeWrappersClass) + 1 + 1));
10324 char name_buffer[kNameLength]; 10362 char name_buffer[kNameLength];
10325 String& cls_name = String::Handle(); 10363 String& cls_name = String::Handle(zone);
10326 for (int fld_cnt = 1; fld_cnt <= kNumNativeWrappersClasses; fld_cnt++) { 10364 for (int fld_cnt = 1; fld_cnt <= kNumNativeWrappersClasses; fld_cnt++) {
10327 OS::SNPrint(name_buffer, 10365 OS::SNPrint(name_buffer,
10328 kNameLength, 10366 kNameLength,
10329 "%s%d", 10367 "%s%d",
10330 kNativeWrappersClass, 10368 kNativeWrappersClass,
10331 fld_cnt); 10369 fld_cnt);
10332 cls_name = Symbols::New(name_buffer); 10370 cls_name = Symbols::New(thread, name_buffer);
10333 Class::NewNativeWrapper(native_flds_lib, cls_name, fld_cnt); 10371 Class::NewNativeWrapper(native_flds_lib, cls_name, fld_cnt);
10334 } 10372 }
10335 native_flds_lib.SetLoaded(); 10373 native_flds_lib.SetLoaded();
10336 } 10374 }
10337 10375
10338 10376
10339 // Returns library with given url in current isolate, or NULL. 10377 // Returns library with given url in current isolate, or NULL.
10340 RawLibrary* Library::LookupLibrary(const String &url) { 10378 RawLibrary* Library::LookupLibrary(const String &url) {
10341 Thread* thread = Thread::Current(); 10379 Thread* thread = Thread::Current();
10342 Zone* zone = thread->zone(); 10380 Zone* zone = thread->zone();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
10417 10455
10418 10456
10419 const String& Library::PrivateCoreLibName(const String& member) { 10457 const String& Library::PrivateCoreLibName(const String& member) {
10420 const Library& core_lib = Library::Handle(Library::CoreLibrary()); 10458 const Library& core_lib = Library::Handle(Library::CoreLibrary());
10421 const String& private_name = String::ZoneHandle(core_lib.PrivateName(member)); 10459 const String& private_name = String::ZoneHandle(core_lib.PrivateName(member));
10422 return private_name; 10460 return private_name;
10423 } 10461 }
10424 10462
10425 10463
10426 RawClass* Library::LookupCoreClass(const String& class_name) { 10464 RawClass* Library::LookupCoreClass(const String& class_name) {
10427 const Library& core_lib = Library::Handle(Library::CoreLibrary()); 10465 Thread* thread = Thread::Current();
10428 String& name = String::Handle(class_name.raw()); 10466 Zone* zone = thread->zone();
10467 const Library& core_lib = Library::Handle(zone, Library::CoreLibrary());
10468 String& name = String::Handle(zone, class_name.raw());
10429 if (class_name.CharAt(0) == kPrivateIdentifierStart) { 10469 if (class_name.CharAt(0) == kPrivateIdentifierStart) {
10430 // Private identifiers are mangled on a per library basis. 10470 // Private identifiers are mangled on a per library basis.
10431 name = Symbols::FromConcat(name, String::Handle(core_lib.private_key())); 10471 name = Symbols::FromConcat(thread,
10472 name, String::Handle(zone, core_lib.private_key()));
10432 } 10473 }
10433 return core_lib.LookupClass(name); 10474 return core_lib.LookupClass(name);
10434 } 10475 }
10435 10476
10436 10477
10437 // Cannot handle qualified names properly as it only appends private key to 10478 // Cannot handle qualified names properly as it only appends private key to
10438 // the end (e.g. _Alfa.foo -> _Alfa.foo@...). 10479 // the end (e.g. _Alfa.foo -> _Alfa.foo@...).
10439 RawString* Library::PrivateName(const String& name) const { 10480 RawString* Library::PrivateName(const String& name) const {
10481 Thread* thread = Thread::Current();
10482 Zone* zone = thread->zone();
10440 ASSERT(IsPrivate(name)); 10483 ASSERT(IsPrivate(name));
10441 // ASSERT(strchr(name, '@') == NULL); 10484 // ASSERT(strchr(name, '@') == NULL);
10442 String& str = String::Handle(); 10485 String& str = String::Handle(zone);
10443 str = name.raw(); 10486 str = name.raw();
10444 str = Symbols::FromConcat(str, String::Handle(this->private_key())); 10487 str = Symbols::FromConcat(thread,
10488 str, String::Handle(zone, this->private_key()));
10445 return str.raw(); 10489 return str.raw();
10446 } 10490 }
10447 10491
10448 10492
10449 RawLibrary* Library::GetLibrary(intptr_t index) { 10493 RawLibrary* Library::GetLibrary(intptr_t index) {
10450 Isolate* isolate = Isolate::Current(); 10494 Isolate* isolate = Isolate::Current();
10451 const GrowableObjectArray& libs = 10495 const GrowableObjectArray& libs =
10452 GrowableObjectArray::Handle(isolate->object_store()->libraries()); 10496 GrowableObjectArray::Handle(isolate->object_store()->libraries());
10453 ASSERT(!libs.IsNull()); 10497 ASSERT(!libs.IsNull());
10454 if ((0 <= index) && (index < libs.Length())) { 10498 if ((0 <= index) && (index < libs.Length())) {
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
11067 } 11111 }
11068 } 11112 }
11069 return error.raw(); 11113 return error.raw();
11070 } 11114 }
11071 11115
11072 11116
11073 // Return Function::null() if function does not exist in libs. 11117 // Return Function::null() if function does not exist in libs.
11074 RawFunction* Library::GetFunction(const GrowableArray<Library*>& libs, 11118 RawFunction* Library::GetFunction(const GrowableArray<Library*>& libs,
11075 const char* class_name, 11119 const char* class_name,
11076 const char* function_name) { 11120 const char* function_name) {
11077 Function& func = Function::Handle(); 11121 Thread* thread = Thread::Current();
11078 String& class_str = String::Handle(); 11122 Zone* zone = thread->zone();
11079 String& func_str = String::Handle(); 11123 Function& func = Function::Handle(zone);
11080 Class& cls = Class::Handle(); 11124 String& class_str = String::Handle(zone);
11125 String& func_str = String::Handle(zone);
11126 Class& cls = Class::Handle(zone);
11081 for (intptr_t l = 0; l < libs.length(); l++) { 11127 for (intptr_t l = 0; l < libs.length(); l++) {
11082 const Library& lib = *libs[l]; 11128 const Library& lib = *libs[l];
11083 if (strcmp(class_name, "::") == 0) { 11129 if (strcmp(class_name, "::") == 0) {
11084 func_str = Symbols::New(function_name); 11130 func_str = Symbols::New(thread, function_name);
11085 func = lib.LookupFunctionAllowPrivate(func_str); 11131 func = lib.LookupFunctionAllowPrivate(func_str);
11086 } else { 11132 } else {
11087 class_str = String::New(class_name); 11133 class_str = String::New(class_name);
11088 cls = lib.LookupClassAllowPrivate(class_str); 11134 cls = lib.LookupClassAllowPrivate(class_str);
11089 if (!cls.IsNull()) { 11135 if (!cls.IsNull()) {
11090 func_str = String::New(function_name); 11136 func_str = String::New(function_name);
11091 if (function_name[0] == '.') { 11137 if (function_name[0] == '.') {
11092 func_str = String::Concat(class_str, func_str); 11138 func_str = String::Concat(class_str, func_str);
11093 } 11139 }
11094 func = cls.LookupFunctionAllowPrivate(func_str); 11140 func = cls.LookupFunctionAllowPrivate(func_str);
(...skipping 2580 matching lines...) Expand 10 before | Expand all | Expand 10 after
13675 } else { 13721 } else {
13676 return zone->PrintToString("Code entry:%" Px, EntryPoint()); 13722 return zone->PrintToString("Code entry:%" Px, EntryPoint());
13677 } 13723 }
13678 } 13724 }
13679 13725
13680 13726
13681 RawString* Code::Name() const { 13727 RawString* Code::Name() const {
13682 const Object& obj = Object::Handle(owner()); 13728 const Object& obj = Object::Handle(owner());
13683 if (obj.IsNull()) { 13729 if (obj.IsNull()) {
13684 // Regular stub. 13730 // Regular stub.
13731 Thread* thread = Thread::Current();
13732 Zone* zone = thread->zone();
13685 const char* name = StubCode::NameOfStub(EntryPoint()); 13733 const char* name = StubCode::NameOfStub(EntryPoint());
13686 ASSERT(name != NULL); 13734 ASSERT(name != NULL);
13687 const String& stub_name = String::Handle(Symbols::New(name)); 13735 const String& stub_name = String::Handle(zone, String::New(name));
13688 return Symbols::FromConcat(Symbols::StubPrefix(), stub_name); 13736 return Symbols::FromConcat(thread, Symbols::StubPrefix(), stub_name);
13689 } else if (obj.IsClass()) { 13737 } else if (obj.IsClass()) {
13690 // Allocation stub. 13738 // Allocation stub.
13739 Thread* thread = Thread::Current();
13740 Zone* zone = thread->zone();
13691 const Class& cls = Class::Cast(obj); 13741 const Class& cls = Class::Cast(obj);
13692 String& cls_name = String::Handle(cls.ScrubbedName()); 13742 String& cls_name = String::Handle(zone, cls.ScrubbedName());
13693 ASSERT(!cls_name.IsNull()); 13743 ASSERT(!cls_name.IsNull());
13694 return Symbols::FromConcat(Symbols::AllocationStubFor(), cls_name); 13744 return Symbols::FromConcat(thread, Symbols::AllocationStubFor(), cls_name);
13695 } else { 13745 } else {
13696 ASSERT(obj.IsFunction()); 13746 ASSERT(obj.IsFunction());
13697 // Dart function. 13747 // Dart function.
13698 return Function::Cast(obj).UserVisibleName(); // Same as scrubbed name. 13748 return Function::Cast(obj).UserVisibleName(); // Same as scrubbed name.
13699 } 13749 }
13700 } 13750 }
13701 13751
13702 13752
13703 RawString* Code::QualifiedName() const { 13753 RawString* Code::QualifiedName() const {
13704 const Object& obj = Object::Handle(owner()); 13754 const Object& obj = Object::Handle(owner());
(...skipping 1722 matching lines...) Expand 10 before | Expand all | Expand 10 after
15427 } 15477 }
15428 } 15478 }
15429 (*trail)->Add(*this); 15479 (*trail)->Add(*this);
15430 (*trail)->Add(buddy); 15480 (*trail)->Add(buddy);
15431 return false; 15481 return false;
15432 } 15482 }
15433 15483
15434 15484
15435 RawString* AbstractType::BuildName(NameVisibility name_visibility) const { 15485 RawString* AbstractType::BuildName(NameVisibility name_visibility) const {
15436 ASSERT(name_visibility != kScrubbedName); 15486 ASSERT(name_visibility != kScrubbedName);
15437 Zone* zone = Thread::Current()->zone(); 15487 Thread* thread = Thread::Current();
15488 Zone* zone = thread->zone();
15438 if (IsBoundedType()) { 15489 if (IsBoundedType()) {
15439 const AbstractType& type = AbstractType::Handle( 15490 const AbstractType& type = AbstractType::Handle(zone,
15440 BoundedType::Cast(*this).type()); 15491 BoundedType::Cast(*this).type());
15441 if (name_visibility == kUserVisibleName) { 15492 if (name_visibility == kUserVisibleName) {
15442 return type.BuildName(kUserVisibleName); 15493 return type.BuildName(kUserVisibleName);
15443 } 15494 }
15444 GrowableHandlePtrArray<const String> pieces(zone, 5); 15495 GrowableHandlePtrArray<const String> pieces(zone, 5);
15445 String& type_name = String::Handle(zone, type.BuildName(kInternalName)); 15496 String& type_name = String::Handle(zone, type.BuildName(kInternalName));
15446 pieces.Add(type_name); 15497 pieces.Add(type_name);
15447 pieces.Add(Symbols::SpaceExtendsSpace()); 15498 pieces.Add(Symbols::SpaceExtendsSpace());
15448 // Build the bound name without causing divergence. 15499 // Build the bound name without causing divergence.
15449 const AbstractType& bound = AbstractType::Handle( 15500 const AbstractType& bound = AbstractType::Handle(zone,
15450 zone, BoundedType::Cast(*this).bound()); 15501 BoundedType::Cast(*this).bound());
15451 String& bound_name = String::Handle(zone); 15502 String& bound_name = String::Handle(zone);
15452 if (bound.IsTypeParameter()) { 15503 if (bound.IsTypeParameter()) {
15453 bound_name = TypeParameter::Cast(bound).name(); 15504 bound_name = TypeParameter::Cast(bound).name();
15454 pieces.Add(bound_name); 15505 pieces.Add(bound_name);
15455 } else if (bound.IsType()) { 15506 } else if (bound.IsType()) {
15456 const Class& cls = Class::Handle(zone, Type::Cast(bound).type_class()); 15507 const Class& cls = Class::Handle(zone, Type::Cast(bound).type_class());
15457 bound_name = cls.Name(); 15508 bound_name = cls.Name();
15458 pieces.Add(bound_name); 15509 pieces.Add(bound_name);
15459 if (Type::Cast(bound).arguments() != TypeArguments::null()) { 15510 if (Type::Cast(bound).arguments() != TypeArguments::null()) {
15460 pieces.Add(Symbols::OptimizedOut()); 15511 pieces.Add(Symbols::OptimizedOut());
15461 } 15512 }
15462 } else { 15513 } else {
15463 pieces.Add(Symbols::OptimizedOut()); 15514 pieces.Add(Symbols::OptimizedOut());
15464 } 15515 }
15465 return Symbols::FromConcatAll(pieces); 15516 return Symbols::FromConcatAll(thread, pieces);
15466 } 15517 }
15467 if (IsTypeParameter()) { 15518 if (IsTypeParameter()) {
15468 return TypeParameter::Cast(*this).name(); 15519 return TypeParameter::Cast(*this).name();
15469 } 15520 }
15470 // If the type is still being finalized, we may be reporting an error about 15521 // If the type is still being finalized, we may be reporting an error about
15471 // a malformed type, so proceed with caution. 15522 // a malformed type, so proceed with caution.
15472 const TypeArguments& args = TypeArguments::Handle(zone, arguments()); 15523 const TypeArguments& args = TypeArguments::Handle(zone, arguments());
15473 const intptr_t num_args = args.IsNull() ? 0 : args.Length(); 15524 const intptr_t num_args = args.IsNull() ? 0 : args.Length();
15474 String& class_name = String::Handle(zone); 15525 String& class_name = String::Handle(zone);
15475 intptr_t first_type_param_index; 15526 intptr_t first_type_param_index;
15476 intptr_t num_type_params; // Number of type parameters to print. 15527 intptr_t num_type_params; // Number of type parameters to print.
15477 Class& cls = Class::Handle(zone); 15528 Class& cls = Class::Handle(zone);
15478 if (IsFunctionType()) { 15529 if (IsFunctionType()) {
15479 cls = type_class(); 15530 cls = type_class();
15480 const Function& signature_function = Function::Handle( 15531 const Function& signature_function = Function::Handle(zone,
15481 zone, Type::Cast(*this).signature()); 15532 Type::Cast(*this).signature());
15482 if (!cls.IsTypedefClass() || 15533 if (!cls.IsTypedefClass() ||
15483 (cls.signature_function() != signature_function.raw())) { 15534 (cls.signature_function() != signature_function.raw())) {
15484 if (!IsFinalized() || IsBeingFinalized() || IsMalformed()) { 15535 if (!IsFinalized() || IsBeingFinalized() || IsMalformed()) {
15485 return signature_function.UserVisibleSignature(); 15536 return signature_function.UserVisibleSignature();
15486 } 15537 }
15487 return signature_function.InstantiatedSignatureFrom(args, 15538 return signature_function.InstantiatedSignatureFrom(args,
15488 name_visibility); 15539 name_visibility);
15489 } 15540 }
15490 class_name = cls.Name(); // Typedef name. 15541 class_name = cls.Name(); // Typedef name.
15491 // We may be reporting an error about a malformed function type. In that 15542 // We may be reporting an error about a malformed function type. In that
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
15546 } else { 15597 } else {
15547 const String& args_name = String::Handle(zone, 15598 const String& args_name = String::Handle(zone,
15548 args.SubvectorName(first_type_param_index, 15599 args.SubvectorName(first_type_param_index,
15549 num_type_params, 15600 num_type_params,
15550 name_visibility)); 15601 name_visibility));
15551 pieces.Add(args_name); 15602 pieces.Add(args_name);
15552 } 15603 }
15553 // The name is only used for type checking and debugging purposes. 15604 // The name is only used for type checking and debugging purposes.
15554 // Unless profiling data shows otherwise, it is not worth caching the name in 15605 // Unless profiling data shows otherwise, it is not worth caching the name in
15555 // the type. 15606 // the type.
15556 return Symbols::FromConcatAll(pieces); 15607 return Symbols::FromConcatAll(thread, pieces);
15557 } 15608 }
15558 15609
15559 15610
15560 // Same as user visible name, but including the URI of each occuring type. 15611 // Same as user visible name, but including the URI of each occuring type.
15561 // Used to report errors involving types with identical names. 15612 // Used to report errors involving types with identical names.
15562 // 15613 //
15563 // e.g. 15614 // e.g.
15564 // MyClass<String> -> MyClass<String> where 15615 // MyClass<String> -> MyClass<String> where
15565 // MyClass is from my_uri 15616 // MyClass is from my_uri
15566 // String is from dart:core 15617 // String is from dart:core
15567 // MyClass<dynamic, T> -> MyClass<dynamic, T> where 15618 // MyClass<dynamic, T> -> MyClass<dynamic, T> where
15568 // MyClass is from my_uri 15619 // MyClass is from my_uri
15569 // T of OtherClass is from other_uri 15620 // T of OtherClass is from other_uri
15570 // (MyClass) => int -> (MyClass) => int where 15621 // (MyClass) => int -> (MyClass) => int where
15571 // MyClass is from my_uri 15622 // MyClass is from my_uri
15572 // int is from dart:core 15623 // int is from dart:core
15573 RawString* AbstractType::UserVisibleNameWithURI() const { 15624 RawString* AbstractType::UserVisibleNameWithURI() const {
15574 Zone* zone = Thread::Current()->zone(); 15625 Thread* thread = Thread::Current();
15626 Zone* zone = thread->zone();
15575 GrowableHandlePtrArray<const String> pieces(zone, 3); 15627 GrowableHandlePtrArray<const String> pieces(zone, 3);
15576 pieces.Add(String::Handle(zone, BuildName(kUserVisibleName))); 15628 pieces.Add(String::Handle(zone, BuildName(kUserVisibleName)));
15577 if (!IsDynamicType() && !IsVoidType()) { 15629 if (!IsDynamicType() && !IsVoidType()) {
15578 pieces.Add(Symbols::SpaceWhereNewLine()); 15630 pieces.Add(Symbols::SpaceWhereNewLine());
15579 pieces.Add(String::Handle(zone, EnumerateURIs())); 15631 pieces.Add(String::Handle(zone, EnumerateURIs()));
15580 } 15632 }
15581 return Symbols::FromConcatAll(pieces); 15633 return Symbols::FromConcatAll(thread, pieces);
15582 } 15634 }
15583 15635
15584 15636
15585 RawString* AbstractType::ClassName() const { 15637 RawString* AbstractType::ClassName() const {
15586 ASSERT(!IsFunctionType()); 15638 ASSERT(!IsFunctionType());
15587 if (HasResolvedTypeClass()) { 15639 if (HasResolvedTypeClass()) {
15588 return Class::Handle(type_class()).Name(); 15640 return Class::Handle(type_class()).Name();
15589 } else { 15641 } else {
15590 return UnresolvedClass::Handle(unresolved_class()).Name(); 15642 return UnresolvedClass::Handle(unresolved_class()).Name();
15591 } 15643 }
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
16544 } 16596 }
16545 } 16597 }
16546 return cls.LookupOrAddCanonicalType(*this, index); 16598 return cls.LookupOrAddCanonicalType(*this, index);
16547 } 16599 }
16548 16600
16549 16601
16550 RawString* Type::EnumerateURIs() const { 16602 RawString* Type::EnumerateURIs() const {
16551 if (IsDynamicType() || IsVoidType()) { 16603 if (IsDynamicType() || IsVoidType()) {
16552 return Symbols::Empty().raw(); 16604 return Symbols::Empty().raw();
16553 } 16605 }
16554 Zone* zone = Thread::Current()->zone(); 16606 Thread* thread = Thread::Current();
16607 Zone* zone = thread->zone();
16555 GrowableHandlePtrArray<const String> pieces(zone, 6); 16608 GrowableHandlePtrArray<const String> pieces(zone, 6);
16556 if (IsFunctionType()) { 16609 if (IsFunctionType()) {
16557 // The scope class and type arguments do not appear explicitly in the user 16610 // The scope class and type arguments do not appear explicitly in the user
16558 // visible name. The type arguments were used to instantiate the function 16611 // visible name. The type arguments were used to instantiate the function
16559 // type prior to this call. 16612 // type prior to this call.
16560 const Function& sig_fun = Function::Handle(zone, signature()); 16613 const Function& sig_fun = Function::Handle(zone, signature());
16561 AbstractType& type = AbstractType::Handle(zone); 16614 AbstractType& type = AbstractType::Handle(zone);
16562 const intptr_t num_params = sig_fun.NumParameters(); 16615 const intptr_t num_params = sig_fun.NumParameters();
16563 GrowableHandlePtrArray<const String> pieces(zone, num_params + 1); 16616 GrowableHandlePtrArray<const String> pieces(zone, num_params + 1);
16564 for (intptr_t i = 0; i < num_params; i++) { 16617 for (intptr_t i = 0; i < num_params; i++) {
16565 type = sig_fun.ParameterTypeAt(i); 16618 type = sig_fun.ParameterTypeAt(i);
16566 pieces.Add(String::Handle(zone, type.EnumerateURIs())); 16619 pieces.Add(String::Handle(zone, type.EnumerateURIs()));
16567 } 16620 }
16568 // Handle result type last, since it appears last in the user visible name. 16621 // Handle result type last, since it appears last in the user visible name.
16569 type = sig_fun.result_type(); 16622 type = sig_fun.result_type();
16570 pieces.Add(String::Handle(zone, type.EnumerateURIs())); 16623 pieces.Add(String::Handle(zone, type.EnumerateURIs()));
16571 } else { 16624 } else {
16572 const Class& cls = Class::Handle(zone, type_class()); 16625 const Class& cls = Class::Handle(zone, type_class());
16573 pieces.Add(Symbols::TwoSpaces()); 16626 pieces.Add(Symbols::TwoSpaces());
16574 pieces.Add(String::Handle(zone, cls.UserVisibleName())); 16627 pieces.Add(String::Handle(zone, cls.UserVisibleName()));
16575 pieces.Add(Symbols::SpaceIsFromSpace()); 16628 pieces.Add(Symbols::SpaceIsFromSpace());
16576 const Library& library = Library::Handle(zone, cls.library()); 16629 const Library& library = Library::Handle(zone, cls.library());
16577 pieces.Add(String::Handle(zone, library.url())); 16630 pieces.Add(String::Handle(zone, library.url()));
16578 pieces.Add(Symbols::NewLine()); 16631 pieces.Add(Symbols::NewLine());
16579 const TypeArguments& type_args = TypeArguments::Handle(zone, arguments()); 16632 const TypeArguments& type_args = TypeArguments::Handle(zone, arguments());
16580 pieces.Add(String::Handle(zone, type_args.EnumerateURIs())); 16633 pieces.Add(String::Handle(zone, type_args.EnumerateURIs()));
16581 } 16634 }
16582 return Symbols::FromConcatAll(pieces); 16635 return Symbols::FromConcatAll(thread, pieces);
16583 } 16636 }
16584 16637
16585 16638
16586 intptr_t Type::Hash() const { 16639 intptr_t Type::Hash() const {
16587 ASSERT(IsFinalized()); 16640 ASSERT(IsFinalized());
16588 uint32_t result = 1; 16641 uint32_t result = 1;
16589 if (IsMalformed()) return result; 16642 if (IsMalformed()) return result;
16590 result = CombineHashes(result, Class::Handle(type_class()).id()); 16643 result = CombineHashes(result, Class::Handle(type_class()).id());
16591 result = CombineHashes(result, TypeArguments::Handle(arguments()).Hash()); 16644 result = CombineHashes(result, TypeArguments::Handle(arguments()).Hash());
16592 if (IsFunctionType()) { 16645 if (IsFunctionType()) {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
16788 // TODO(regis): Try to reduce the number of nodes required to represent the 16841 // TODO(regis): Try to reduce the number of nodes required to represent the
16789 // referenced recursive type. 16842 // referenced recursive type.
16790 AbstractType& ref_type = AbstractType::Handle(type()); 16843 AbstractType& ref_type = AbstractType::Handle(type());
16791 ref_type = ref_type.Canonicalize(trail); 16844 ref_type = ref_type.Canonicalize(trail);
16792 set_type(ref_type); 16845 set_type(ref_type);
16793 return raw(); 16846 return raw();
16794 } 16847 }
16795 16848
16796 16849
16797 RawString* TypeRef::EnumerateURIs() const { 16850 RawString* TypeRef::EnumerateURIs() const {
16798 const AbstractType& ref_type = AbstractType::Handle(type()); 16851 Thread* thread = Thread::Current();
16852 Zone* zone = thread->zone();
16853 const AbstractType& ref_type = AbstractType::Handle(zone, type());
16799 ASSERT(!ref_type.IsDynamicType() && !ref_type.IsVoidType()); 16854 ASSERT(!ref_type.IsDynamicType() && !ref_type.IsVoidType());
16800 Zone* zone = Thread::Current()->zone();
16801 GrowableHandlePtrArray<const String> pieces(zone, 6); 16855 GrowableHandlePtrArray<const String> pieces(zone, 6);
16802 const Class& cls = Class::Handle(zone, ref_type.type_class()); 16856 const Class& cls = Class::Handle(zone, ref_type.type_class());
16803 pieces.Add(Symbols::TwoSpaces()); 16857 pieces.Add(Symbols::TwoSpaces());
16804 pieces.Add(String::Handle(zone, cls.UserVisibleName())); 16858 pieces.Add(String::Handle(zone, cls.UserVisibleName()));
16805 // Break cycle by not printing type arguments, but '<optimized out>' instead. 16859 // Break cycle by not printing type arguments, but '<optimized out>' instead.
16806 pieces.Add(Symbols::OptimizedOut()); 16860 pieces.Add(Symbols::OptimizedOut());
16807 pieces.Add(Symbols::SpaceIsFromSpace()); 16861 pieces.Add(Symbols::SpaceIsFromSpace());
16808 const Library& library = Library::Handle(zone, cls.library()); 16862 const Library& library = Library::Handle(zone, cls.library());
16809 pieces.Add(String::Handle(zone, library.url())); 16863 pieces.Add(String::Handle(zone, library.url()));
16810 pieces.Add(Symbols::NewLine()); 16864 pieces.Add(Symbols::NewLine());
16811 return Symbols::FromConcatAll(pieces); 16865 return Symbols::FromConcatAll(thread, pieces);
16812 } 16866 }
16813 16867
16814 16868
16815 intptr_t TypeRef::Hash() const { 16869 intptr_t TypeRef::Hash() const {
16816 // Do not calculate the hash of the referenced type to avoid divergence. 16870 // Do not calculate the hash of the referenced type to avoid divergence.
16817 const uint32_t result = 16871 const uint32_t result =
16818 Class::Handle(AbstractType::Handle(type()).type_class()).id(); 16872 Class::Handle(AbstractType::Handle(type()).type_class()).id();
16819 return FinalizeHash(result); 16873 return FinalizeHash(result);
16820 } 16874 }
16821 16875
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
17023 token_pos()); 17077 token_pos());
17024 clone.SetIsFinalized(); 17078 clone.SetIsFinalized();
17025 AddOnlyBuddyToTrail(&trail, clone); 17079 AddOnlyBuddyToTrail(&trail, clone);
17026 upper_bound = upper_bound.CloneUninstantiated(new_owner, trail); 17080 upper_bound = upper_bound.CloneUninstantiated(new_owner, trail);
17027 clone.set_bound(upper_bound); 17081 clone.set_bound(upper_bound);
17028 return clone.raw(); 17082 return clone.raw();
17029 } 17083 }
17030 17084
17031 17085
17032 RawString* TypeParameter::EnumerateURIs() const { 17086 RawString* TypeParameter::EnumerateURIs() const {
17033 Zone* zone = Thread::Current()->zone(); 17087 Thread* thread = Thread::Current();
17088 Zone* zone = thread->zone();
17034 GrowableHandlePtrArray<const String> pieces(zone, 4); 17089 GrowableHandlePtrArray<const String> pieces(zone, 4);
17035 pieces.Add(Symbols::TwoSpaces()); 17090 pieces.Add(Symbols::TwoSpaces());
17036 pieces.Add(String::Handle(zone, name())); 17091 pieces.Add(String::Handle(zone, name()));
17037 pieces.Add(Symbols::SpaceOfSpace()); 17092 pieces.Add(Symbols::SpaceOfSpace());
17038 const Class& cls = Class::Handle(zone, parameterized_class()); 17093 const Class& cls = Class::Handle(zone, parameterized_class());
17039 pieces.Add(String::Handle(zone, cls.UserVisibleName())); 17094 pieces.Add(String::Handle(zone, cls.UserVisibleName()));
17040 pieces.Add(Symbols::SpaceIsFromSpace()); 17095 pieces.Add(Symbols::SpaceIsFromSpace());
17041 const Library& library = Library::Handle(zone, cls.library()); 17096 const Library& library = Library::Handle(zone, cls.library());
17042 pieces.Add(String::Handle(zone, library.url())); 17097 pieces.Add(String::Handle(zone, library.url()));
17043 pieces.Add(Symbols::NewLine()); 17098 pieces.Add(Symbols::NewLine());
17044 return Symbols::FromConcatAll(pieces); 17099 return Symbols::FromConcatAll(thread, pieces);
17045 } 17100 }
17046 17101
17047 17102
17048 intptr_t TypeParameter::Hash() const { 17103 intptr_t TypeParameter::Hash() const {
17049 ASSERT(IsFinalized()); 17104 ASSERT(IsFinalized());
17050 uint32_t result = Class::Handle(parameterized_class()).id(); 17105 uint32_t result = Class::Handle(parameterized_class()).id();
17051 // No need to include the hash of the bound, since the type parameter is fully 17106 // No need to include the hash of the bound, since the type parameter is fully
17052 // identified by its class and index. 17107 // identified by its class and index.
17053 result = CombineHashes(result, index()); 17108 result = CombineHashes(result, index());
17054 return FinalizeHash(result); 17109 return FinalizeHash(result);
(...skipping 2105 matching lines...) Expand 10 before | Expand all | Expand 10 after
19160 } 19215 }
19161 } 19216 }
19162 return true; 19217 return true;
19163 } 19218 }
19164 19219
19165 19220
19166 RawInstance* String::CheckAndCanonicalize(const char** error_str) const { 19221 RawInstance* String::CheckAndCanonicalize(const char** error_str) const {
19167 if (IsCanonical()) { 19222 if (IsCanonical()) {
19168 return this->raw(); 19223 return this->raw();
19169 } 19224 }
19170 return Symbols::New(*this); 19225 return Symbols::New(Thread::Current(), *this);
19171 } 19226 }
19172 19227
19173 19228
19174 RawString* String::New(const char* cstr, Heap::Space space) { 19229 RawString* String::New(const char* cstr, Heap::Space space) {
19175 ASSERT(cstr != NULL); 19230 ASSERT(cstr != NULL);
19176 intptr_t array_len = strlen(cstr); 19231 intptr_t array_len = strlen(cstr);
19177 const uint8_t* utf8_array = reinterpret_cast<const uint8_t*>(cstr); 19232 const uint8_t* utf8_array = reinterpret_cast<const uint8_t*>(cstr);
19178 return String::FromUTF8(utf8_array, array_len, space); 19233 return String::FromUTF8(utf8_array, array_len, space);
19179 } 19234 }
19180 19235
(...skipping 2775 matching lines...) Expand 10 before | Expand all | Expand 10 after
21956 return UserTag::null(); 22011 return UserTag::null();
21957 } 22012 }
21958 22013
21959 22014
21960 const char* UserTag::ToCString() const { 22015 const char* UserTag::ToCString() const {
21961 const String& tag_label = String::Handle(label()); 22016 const String& tag_label = String::Handle(label());
21962 return tag_label.ToCString(); 22017 return tag_label.ToCString();
21963 } 22018 }
21964 22019
21965 } // namespace dart 22020 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_id_ring_test.cc » ('j') | runtime/vm/symbols.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698