OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/object.h" | 5 #include "vm/object.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
11 #include "vm/datastream.h" | 11 #include "vm/datastream.h" |
12 #include "vm/code_generator.h" | 12 #include "vm/code_generator.h" |
13 #include "vm/code_patcher.h" | 13 #include "vm/code_patcher.h" |
14 #include "vm/compiler.h" | 14 #include "vm/compiler.h" |
15 #include "vm/compiler_stats.h" | 15 #include "vm/compiler_stats.h" |
16 #include "vm/class_finalizer.h" | 16 #include "vm/class_finalizer.h" |
17 #include "vm/dart.h" | 17 #include "vm/dart.h" |
18 #include "vm/dart_api_state.h" | 18 #include "vm/dart_api_state.h" |
19 #include "vm/dart_entry.h" | 19 #include "vm/dart_entry.h" |
20 #include "vm/debuginfo.h" | 20 #include "vm/debuginfo.h" |
21 #include "vm/double_conversion.h" | 21 #include "vm/double_conversion.h" |
22 #include "vm/exceptions.h" | 22 #include "vm/exceptions.h" |
23 #include "vm/growable_array.h" | 23 #include "vm/growable_array.h" |
24 #include "vm/heap.h" | 24 #include "vm/heap.h" |
25 #include "vm/object_store.h" | 25 #include "vm/object_store.h" |
26 #include "vm/parser.h" | 26 #include "vm/parser.h" |
27 #include "vm/runtime_entry.h" | 27 #include "vm/runtime_entry.h" |
28 #include "vm/scopes.h" | 28 #include "vm/scopes.h" |
29 #include "vm/stack_frame.h" | 29 #include "vm/stack_frame.h" |
30 #include "vm/symbols.h" | |
30 #include "vm/timer.h" | 31 #include "vm/timer.h" |
31 #include "vm/unicode.h" | 32 #include "vm/unicode.h" |
32 | 33 |
33 namespace dart { | 34 namespace dart { |
34 | 35 |
35 DEFINE_FLAG(bool, generate_gdb_symbols, false, | 36 DEFINE_FLAG(bool, generate_gdb_symbols, false, |
36 "Generate symbols of generated dart functions for debugging with GDB"); | 37 "Generate symbols of generated dart functions for debugging with GDB"); |
37 DECLARE_FLAG(bool, trace_compiler); | 38 DECLARE_FLAG(bool, trace_compiler); |
38 DECLARE_FLAG(bool, enable_type_checks); | 39 DECLARE_FLAG(bool, enable_type_checks); |
39 | 40 |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
301 null_class_ = cls.raw(); | 302 null_class_ = cls.raw(); |
302 | 303 |
303 // Allocate and initialize the free list element class. | 304 // Allocate and initialize the free list element class. |
304 cls = Class::New<FreeListElement::FakeInstance>(kFreeListElement); | 305 cls = Class::New<FreeListElement::FakeInstance>(kFreeListElement); |
305 cls.set_is_finalized(); | 306 cls.set_is_finalized(); |
306 | 307 |
307 // Allocate and initialize the sentinel values of Null class. | 308 // Allocate and initialize the sentinel values of Null class. |
308 { | 309 { |
309 cls = null_class_; | 310 cls = null_class_; |
310 Instance& sentinel = Instance::Handle(); | 311 Instance& sentinel = Instance::Handle(); |
311 sentinel ^= Object::Allocate(cls, Instance::InstanceSize(), Heap::kOld); | 312 sentinel ^= |
313 Object::Allocate(cls.id(), Instance::InstanceSize(), Heap::kOld); | |
Ivan Posva
2012/07/23 18:26:34
Why are you even setting up cls here? Can't you ju
siva
2012/07/23 23:09:00
Done.
| |
312 sentinel_ = sentinel.raw(); | 314 sentinel_ = sentinel.raw(); |
313 | 315 |
314 Instance& transition_sentinel = Instance::Handle(); | 316 Instance& transition_sentinel = Instance::Handle(); |
315 transition_sentinel ^= | 317 transition_sentinel ^= |
316 Object::Allocate(cls, Instance::InstanceSize(), Heap::kOld); | 318 Object::Allocate(cls.id(), Instance::InstanceSize(), Heap::kOld); |
317 transition_sentinel_ = transition_sentinel.raw(); | 319 transition_sentinel_ = transition_sentinel.raw(); |
318 } | 320 } |
319 | 321 |
320 // The interface "Dynamic" is not a VM internal class. It is the type class of | 322 // The interface "Dynamic" is not a VM internal class. It is the type class of |
321 // the "unknown type". For efficiency, we allocate it in the VM isolate. | 323 // the "unknown type". For efficiency, we allocate it in the VM isolate. |
322 // Therefore, it cannot have a heap allocated name (the name is hard coded, | 324 // Therefore, it cannot have a heap allocated name (the name is hard coded, |
323 // see GetSingletonClassIndex) and its array fields cannot be set to the empty | 325 // see GetSingletonClassIndex) and its array fields cannot be set to the empty |
324 // array, but remain null. | 326 // array, but remain null. |
325 // | 327 // |
326 // TODO(turnidge): Once the empty array is allocated in the vm | 328 // TODO(turnidge): Once the empty array is allocated in the vm |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
413 cls = Class::New<UnwindError>(); | 415 cls = Class::New<UnwindError>(); |
414 unwind_error_class_ = cls.raw(); | 416 unwind_error_class_ = cls.raw(); |
415 | 417 |
416 ASSERT(class_class() != null_); | 418 ASSERT(class_class() != null_); |
417 } | 419 } |
418 | 420 |
419 | 421 |
420 RawClass* Object::CreateAndRegisterInterface(const char* cname, | 422 RawClass* Object::CreateAndRegisterInterface(const char* cname, |
421 const Script& script, | 423 const Script& script, |
422 const Library& lib) { | 424 const Library& lib) { |
423 const String& name = String::Handle(String::NewSymbol(cname)); | 425 const String& name = String::Handle(Symbols::New(cname)); |
424 const Class& cls = Class::Handle( | 426 const Class& cls = Class::Handle( |
425 Class::NewInterface(name, script, Scanner::kDummyTokenIndex)); | 427 Class::NewInterface(name, script, Scanner::kDummyTokenIndex)); |
426 lib.AddClass(cls); | 428 lib.AddClass(cls); |
427 return cls.raw(); | 429 return cls.raw(); |
428 } | 430 } |
429 | 431 |
430 | 432 |
431 void Object::RegisterClass(const Class& cls, | 433 void Object::RegisterClass(const Class& cls, |
432 const char* cname, | 434 const char* cname, |
433 const Script& script, | 435 const Script& script, |
434 const Library& lib) { | 436 const Library& lib) { |
435 const String& name = String::Handle(String::NewSymbol(cname)); | 437 const String& name = String::Handle(Symbols::New(cname)); |
436 cls.set_name(name); | 438 cls.set_name(name); |
437 cls.set_script(script); | 439 cls.set_script(script); |
438 lib.AddClass(cls); | 440 lib.AddClass(cls); |
439 } | 441 } |
440 | 442 |
441 | 443 |
442 void Object::RegisterPrivateClass(const Class& cls, | 444 void Object::RegisterPrivateClass(const Class& cls, |
443 const char* public_class_name, | 445 const char* public_class_name, |
444 const Script& script, | 446 const Script& script, |
445 const Library& lib) { | 447 const Library& lib) { |
446 String& str = String::Handle(); | 448 String& str = String::Handle(); |
447 str = String::NewSymbol(public_class_name); | 449 str = Symbols::New(public_class_name); |
448 str = lib.PrivateName(str); | 450 str = lib.PrivateName(str); |
449 cls.set_name(str); | 451 cls.set_name(str); |
450 cls.set_script(script); | 452 cls.set_script(script); |
451 lib.AddClass(cls); | 453 lib.AddClass(cls); |
452 } | 454 } |
453 | 455 |
454 | 456 |
455 RawError* Object::Init(Isolate* isolate) { | 457 RawError* Object::Init(Isolate* isolate) { |
456 TIMERSCOPE(time_bootstrap); | 458 TIMERSCOPE(time_bootstrap); |
457 ObjectStore* object_store = isolate->object_store(); | 459 ObjectStore* object_store = isolate->object_store(); |
(...skipping 21 matching lines...) Expand all Loading... | |
479 // has been created. | 481 // has been created. |
480 cls.InitEmptyFields(); | 482 cls.InitEmptyFields(); |
481 | 483 |
482 // Set up the growable object array class (Has to be done after the array | 484 // Set up the growable object array class (Has to be done after the array |
483 // class is setup as one of its field is an array object). | 485 // class is setup as one of its field is an array object). |
484 cls = Class::New<GrowableObjectArray>(); | 486 cls = Class::New<GrowableObjectArray>(); |
485 object_store->set_growable_object_array_class(cls); | 487 object_store->set_growable_object_array_class(cls); |
486 cls.set_type_arguments_instance_field_offset( | 488 cls.set_type_arguments_instance_field_offset( |
487 GrowableObjectArray::type_arguments_offset()); | 489 GrowableObjectArray::type_arguments_offset()); |
488 | 490 |
489 // Setup the symbol table used within the String class. | |
490 const int kInitialSymbolTableSize = 16; | |
491 array = Array::New(kInitialSymbolTableSize + 1); | |
492 // Last element contains the count of used slots. | |
493 array.SetAt(kInitialSymbolTableSize, Smi::Handle(Smi::New(0))); | |
494 object_store->set_symbol_table(array); | |
495 | |
496 // canonical_type_arguments_ are NULL terminated. | 491 // canonical_type_arguments_ are NULL terminated. |
497 array = Array::New(4); | 492 array = Array::New(4); |
498 object_store->set_canonical_type_arguments(array); | 493 object_store->set_canonical_type_arguments(array); |
499 | 494 |
500 // Pre-allocate the OneByteString class needed by the symbol table. | 495 // Pre-allocate the OneByteString class needed by the symbol table. |
501 cls = Class::New<OneByteString>(); | 496 cls = Class::New<OneByteString>(); |
502 object_store->set_one_byte_string_class(cls); | 497 object_store->set_one_byte_string_class(cls); |
503 | 498 |
499 // Setup the symbol table for the symbols created in the isolate. | |
500 Symbols::SetupSymbolTable(isolate); | |
501 | |
504 // Set up the libraries array before initializing the core library. | 502 // Set up the libraries array before initializing the core library. |
505 const GrowableObjectArray& libraries = | 503 const GrowableObjectArray& libraries = |
506 GrowableObjectArray::Handle(GrowableObjectArray::New(Heap::kOld)); | 504 GrowableObjectArray::Handle(GrowableObjectArray::New(Heap::kOld)); |
507 object_store->set_libraries(libraries); | 505 object_store->set_libraries(libraries); |
508 | 506 |
509 // Basic infrastructure has been setup, initialize the class dictionary. | 507 // Basic infrastructure has been setup, initialize the class dictionary. |
510 Library::InitCoreLibrary(isolate); | 508 Library::InitCoreLibrary(isolate); |
511 Library& core_lib = Library::Handle(Library::CoreLibrary()); | 509 Library& core_lib = Library::Handle(Library::CoreLibrary()); |
512 ASSERT(!core_lib.IsNull()); | 510 ASSERT(!core_lib.IsNull()); |
513 Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary()); | 511 Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary()); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
606 pending_classes.Add(cls, Heap::kOld); | 604 pending_classes.Add(cls, Heap::kOld); |
607 | 605 |
608 // Initialize the base interfaces used by the core VM classes. | 606 // Initialize the base interfaces used by the core VM classes. |
609 const Script& script = Script::Handle(Bootstrap::LoadScript()); | 607 const Script& script = Script::Handle(Bootstrap::LoadScript()); |
610 | 608 |
611 // Allocate and initialize the Object class and type. The Object | 609 // Allocate and initialize the Object class and type. The Object |
612 // class and ByteArray subclasses are the only pre-allocated, | 610 // class and ByteArray subclasses are the only pre-allocated, |
613 // non-interface classes in the core library. | 611 // non-interface classes in the core library. |
614 cls = Class::New<Instance>(); | 612 cls = Class::New<Instance>(); |
615 object_store->set_object_class(cls); | 613 object_store->set_object_class(cls); |
616 cls.set_name(String::Handle(String::NewSymbol("Object"))); | 614 cls.set_name(String::Handle(Symbols::New("Object"))); |
617 cls.set_script(script); | 615 cls.set_script(script); |
618 cls.set_is_prefinalized(); | 616 cls.set_is_prefinalized(); |
619 core_lib.AddClass(cls); | 617 core_lib.AddClass(cls); |
620 pending_classes.Add(cls, Heap::kOld); | 618 pending_classes.Add(cls, Heap::kOld); |
621 type = Type::NewNonParameterizedType(cls); | 619 type = Type::NewNonParameterizedType(cls); |
622 object_store->set_object_type(type); | 620 object_store->set_object_type(type); |
623 | 621 |
624 cls = Class::New<Int8Array>(); | 622 cls = Class::New<Int8Array>(); |
625 object_store->set_int8_array_class(cls); | 623 object_store->set_int8_array_class(cls); |
626 RegisterPrivateClass(cls, "_Int8Array", script, core_lib); | 624 RegisterPrivateClass(cls, "_Int8Array", script, core_lib); |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
972 cur += kWordSize; | 970 cur += kWordSize; |
973 } | 971 } |
974 uword tags = 0; | 972 uword tags = 0; |
975 ASSERT(index != kIllegalObjectKind); | 973 ASSERT(index != kIllegalObjectKind); |
976 tags = RawObject::ClassIdTag::update(index, tags); | 974 tags = RawObject::ClassIdTag::update(index, tags); |
977 tags = RawObject::SizeTag::update(size, tags); | 975 tags = RawObject::SizeTag::update(size, tags); |
978 reinterpret_cast<RawObject*>(address)->tags_ = tags; | 976 reinterpret_cast<RawObject*>(address)->tags_ = tags; |
979 } | 977 } |
980 | 978 |
981 | 979 |
982 RawObject* Object::Allocate(const Class& cls, | 980 RawObject* Object::Allocate(intptr_t cls_id, |
983 intptr_t size, | 981 intptr_t size, |
984 Heap::Space space) { | 982 Heap::Space space) { |
985 ASSERT(Utils::IsAligned(size, kObjectAlignment)); | 983 ASSERT(Utils::IsAligned(size, kObjectAlignment)); |
986 Isolate* isolate = Isolate::Current(); | 984 Isolate* isolate = Isolate::Current(); |
987 Heap* heap = isolate->heap(); | 985 Heap* heap = isolate->heap(); |
988 | 986 |
989 uword address = heap->Allocate(size, space); | 987 uword address = heap->Allocate(size, space); |
990 if (address == 0) { | 988 if (address == 0) { |
991 // Use the preallocated out of memory exception to avoid calling | 989 // Use the preallocated out of memory exception to avoid calling |
992 // into dart code or allocating any code. | 990 // into dart code or allocating any code. |
993 const Instance& exception = | 991 const Instance& exception = |
994 Instance::Handle(isolate->object_store()->out_of_memory()); | 992 Instance::Handle(isolate->object_store()->out_of_memory()); |
995 Exceptions::Throw(exception); | 993 Exceptions::Throw(exception); |
996 UNREACHABLE(); | 994 UNREACHABLE(); |
997 } | 995 } |
998 NoGCScope no_gc; | 996 NoGCScope no_gc; |
999 InitializeObject(address, cls.id(), size); | 997 InitializeObject(address, cls_id, size); |
1000 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); | 998 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); |
1001 ASSERT(cls.id() == RawObject::ClassIdTag::decode(raw_obj->ptr()->tags_)); | 999 ASSERT(cls_id == RawObject::ClassIdTag::decode(raw_obj->ptr()->tags_)); |
1002 return raw_obj; | 1000 return raw_obj; |
1003 } | 1001 } |
1004 | 1002 |
1005 | 1003 |
1006 class StoreBufferObjectPointerVisitor : public ObjectPointerVisitor { | 1004 class StoreBufferObjectPointerVisitor : public ObjectPointerVisitor { |
1007 public: | 1005 public: |
1008 explicit StoreBufferObjectPointerVisitor(Isolate* isolate) : | 1006 explicit StoreBufferObjectPointerVisitor(Isolate* isolate) : |
1009 ObjectPointerVisitor(isolate) { | 1007 ObjectPointerVisitor(isolate) { |
1010 } | 1008 } |
1011 void VisitPointers(RawObject** first, RawObject** last) { | 1009 void VisitPointers(RawObject** first, RawObject** last) { |
1012 for (RawObject** curr = first; curr <= last; ++curr) { | 1010 for (RawObject** curr = first; curr <= last; ++curr) { |
1013 if ((*curr)->IsNewObject()) { | 1011 if ((*curr)->IsNewObject()) { |
1014 uword ptr = reinterpret_cast<uword>(curr); | 1012 uword ptr = reinterpret_cast<uword>(curr); |
1015 isolate()->store_buffer()->AddPointer(ptr); | 1013 isolate()->store_buffer()->AddPointer(ptr); |
1016 } | 1014 } |
1017 } | 1015 } |
1018 } | 1016 } |
1019 | 1017 |
1020 private: | 1018 private: |
1021 DISALLOW_COPY_AND_ASSIGN(StoreBufferObjectPointerVisitor); | 1019 DISALLOW_COPY_AND_ASSIGN(StoreBufferObjectPointerVisitor); |
1022 }; | 1020 }; |
1023 | 1021 |
1024 | 1022 |
1025 RawObject* Object::Clone(const Object& src, Heap::Space space) { | 1023 RawObject* Object::Clone(const Object& src, Heap::Space space) { |
1026 const Class& cls = Class::Handle(src.clazz()); | 1024 const Class& cls = Class::Handle(src.clazz()); |
1027 intptr_t size = src.raw()->Size(); | 1025 intptr_t size = src.raw()->Size(); |
1028 RawObject* raw_obj = Object::Allocate(cls, size, space); | 1026 RawObject* raw_obj = Object::Allocate(cls.id(), size, space); |
1029 NoGCScope no_gc; | 1027 NoGCScope no_gc; |
1030 memmove(raw_obj->ptr(), src.raw()->ptr(), size); | 1028 memmove(raw_obj->ptr(), src.raw()->ptr(), size); |
1031 if (space == Heap::kOld) { | 1029 if (space == Heap::kOld) { |
1032 StoreBufferObjectPointerVisitor visitor(Isolate::Current()); | 1030 StoreBufferObjectPointerVisitor visitor(Isolate::Current()); |
1033 raw_obj->VisitPointers(&visitor); | 1031 raw_obj->VisitPointers(&visitor); |
1034 } | 1032 } |
1035 return raw_obj; | 1033 return raw_obj; |
1036 } | 1034 } |
1037 | 1035 |
1038 | 1036 |
1039 RawString* Class::Name() const { | 1037 RawString* Class::Name() const { |
1040 if (raw_ptr()->name_ != String::null()) { | 1038 if (raw_ptr()->name_ != String::null()) { |
1041 return raw_ptr()->name_; | 1039 return raw_ptr()->name_; |
1042 } | 1040 } |
1043 ASSERT(class_class() != Class::null()); // class_class_ should be set up. | 1041 ASSERT(class_class() != Class::null()); // class_class_ should be set up. |
1044 intptr_t index = GetSingletonClassIndex(raw()); | 1042 intptr_t index = GetSingletonClassIndex(raw()); |
1045 return String::NewSymbol(GetSingletonClassName(index)); | 1043 return Symbols::New(GetSingletonClassName(index)); |
1046 } | 1044 } |
1047 | 1045 |
1048 | 1046 |
1049 RawType* Class::SignatureType() const { | 1047 RawType* Class::SignatureType() const { |
1050 ASSERT(IsSignatureClass()); | 1048 ASSERT(IsSignatureClass()); |
1051 const Function& function = Function::Handle(signature_function()); | 1049 const Function& function = Function::Handle(signature_function()); |
1052 ASSERT(!function.IsNull()); | 1050 ASSERT(!function.IsNull()); |
1053 if (function.signature_class() != raw()) { | 1051 if (function.signature_class() != raw()) { |
1054 // This class is a function type alias. Return the canonical signature type. | 1052 // This class is a function type alias. Return the canonical signature type. |
1055 const Class& canonical_class = Class::Handle(function.signature_class()); | 1053 const Class& canonical_class = Class::Handle(function.signature_class()); |
(...skipping 22 matching lines...) Expand all Loading... | |
1078 Type::New(*this, signature_type_arguments, token_pos())); | 1076 Type::New(*this, signature_type_arguments, token_pos())); |
1079 | 1077 |
1080 // Return the still unfinalized signature type. | 1078 // Return the still unfinalized signature type. |
1081 ASSERT(!signature_type.IsFinalized()); | 1079 ASSERT(!signature_type.IsFinalized()); |
1082 return signature_type.raw(); | 1080 return signature_type.raw(); |
1083 } | 1081 } |
1084 | 1082 |
1085 | 1083 |
1086 template <class FakeObject> | 1084 template <class FakeObject> |
1087 RawClass* Class::New() { | 1085 RawClass* Class::New() { |
1088 Class& class_class = Class::Handle(Object::class_class()); | 1086 ASSERT(Object::class_class() != Class::null()); |
1089 Class& result = Class::Handle(); | 1087 Class& result = Class::Handle(); |
1090 { | 1088 { |
1091 RawObject* raw = Object::Allocate(class_class, | 1089 RawObject* raw = Object::Allocate(Class::kInstanceKind, |
1092 Class::InstanceSize(), | 1090 Class::InstanceSize(), |
1093 Heap::kOld); | 1091 Heap::kOld); |
1094 NoGCScope no_gc; | 1092 NoGCScope no_gc; |
1095 result ^= raw; | 1093 result ^= raw; |
1096 } | 1094 } |
1097 FakeObject fake; | 1095 FakeObject fake; |
1098 result.set_handle_vtable(fake.vtable()); | 1096 result.set_handle_vtable(fake.vtable()); |
1099 result.set_instance_size(FakeObject::InstanceSize()); | 1097 result.set_instance_size(FakeObject::InstanceSize()); |
1100 result.set_next_field_offset(FakeObject::InstanceSize()); | 1098 result.set_next_field_offset(FakeObject::InstanceSize()); |
1101 result.set_instance_kind(FakeObject::kInstanceKind); | 1099 result.set_instance_kind(FakeObject::kInstanceKind); |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1413 ASSERT(!(field.is_static() && field.is_final()) || | 1411 ASSERT(!(field.is_static() && field.is_final()) || |
1414 (field.value() == Object::sentinel())); | 1412 (field.value() == Object::sentinel())); |
1415 } | 1413 } |
1416 // The value of static fields is already initialized to null. | 1414 // The value of static fields is already initialized to null. |
1417 StorePointer(&raw_ptr()->fields_, value.raw()); | 1415 StorePointer(&raw_ptr()->fields_, value.raw()); |
1418 } | 1416 } |
1419 | 1417 |
1420 | 1418 |
1421 template <class FakeInstance> | 1419 template <class FakeInstance> |
1422 RawClass* Class::New(intptr_t index) { | 1420 RawClass* Class::New(intptr_t index) { |
1423 Class& class_class = Class::Handle(Object::class_class()); | 1421 ASSERT(Object::class_class() != Class::null()); |
1424 Class& result = Class::Handle(); | 1422 Class& result = Class::Handle(); |
1425 { | 1423 { |
1426 RawObject* raw = Object::Allocate(class_class, | 1424 RawObject* raw = Object::Allocate(Class::kInstanceKind, |
1427 Class::InstanceSize(), | 1425 Class::InstanceSize(), |
1428 Heap::kOld); | 1426 Heap::kOld); |
1429 NoGCScope no_gc; | 1427 NoGCScope no_gc; |
1430 result ^= raw; | 1428 result ^= raw; |
1431 } | 1429 } |
1432 FakeInstance fake; | 1430 FakeInstance fake; |
1433 ASSERT(fake.IsInstance()); | 1431 ASSERT(fake.IsInstance()); |
1434 result.set_handle_vtable(fake.vtable()); | 1432 result.set_handle_vtable(fake.vtable()); |
1435 result.set_instance_size(FakeInstance::InstanceSize()); | 1433 result.set_instance_size(FakeInstance::InstanceSize()); |
1436 result.set_next_field_offset(FakeInstance::InstanceSize()); | 1434 result.set_next_field_offset(FakeInstance::InstanceSize()); |
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2137 intptr_t token_pos) { | 2135 intptr_t token_pos) { |
2138 const UnresolvedClass& type = UnresolvedClass::Handle(UnresolvedClass::New()); | 2136 const UnresolvedClass& type = UnresolvedClass::Handle(UnresolvedClass::New()); |
2139 type.set_library_prefix(library_prefix); | 2137 type.set_library_prefix(library_prefix); |
2140 type.set_ident(ident); | 2138 type.set_ident(ident); |
2141 type.set_token_pos(token_pos); | 2139 type.set_token_pos(token_pos); |
2142 return type.raw(); | 2140 return type.raw(); |
2143 } | 2141 } |
2144 | 2142 |
2145 | 2143 |
2146 RawUnresolvedClass* UnresolvedClass::New() { | 2144 RawUnresolvedClass* UnresolvedClass::New() { |
2147 const Class& unresolved_class_class = | 2145 ASSERT(Object::unresolved_class_class() != Class::null()); |
2148 Class::Handle(Object::unresolved_class_class()); | 2146 RawObject* raw = Object::Allocate(UnresolvedClass::kInstanceKind, |
2149 RawObject* raw = Object::Allocate(unresolved_class_class, | |
2150 UnresolvedClass::InstanceSize(), | 2147 UnresolvedClass::InstanceSize(), |
2151 Heap::kOld); | 2148 Heap::kOld); |
2152 return reinterpret_cast<RawUnresolvedClass*>(raw); | 2149 return reinterpret_cast<RawUnresolvedClass*>(raw); |
2153 } | 2150 } |
2154 | 2151 |
2155 | 2152 |
2156 void UnresolvedClass::set_token_pos(intptr_t token_pos) const { | 2153 void UnresolvedClass::set_token_pos(intptr_t token_pos) const { |
2157 ASSERT(token_pos >= 0); | 2154 ASSERT(token_pos >= 0); |
2158 raw_ptr()->token_pos_ = token_pos; | 2155 raw_ptr()->token_pos_ = token_pos; |
2159 } | 2156 } |
(...skipping 14 matching lines...) Expand all Loading... | |
2174 StorePointer(&raw_ptr()->factory_signature_class_, value.raw()); | 2171 StorePointer(&raw_ptr()->factory_signature_class_, value.raw()); |
2175 } | 2172 } |
2176 | 2173 |
2177 | 2174 |
2178 RawString* UnresolvedClass::Name() const { | 2175 RawString* UnresolvedClass::Name() const { |
2179 if (library_prefix() != LibraryPrefix::null()) { | 2176 if (library_prefix() != LibraryPrefix::null()) { |
2180 const LibraryPrefix& lib_prefix = LibraryPrefix::Handle(library_prefix()); | 2177 const LibraryPrefix& lib_prefix = LibraryPrefix::Handle(library_prefix()); |
2181 String& name = String::Handle(); | 2178 String& name = String::Handle(); |
2182 String& str = String::Handle(); | 2179 String& str = String::Handle(); |
2183 name = lib_prefix.name(); // Qualifier. | 2180 name = lib_prefix.name(); // Qualifier. |
2184 str = String::New("."); | 2181 str = Symbols::Dot(); |
2185 name = String::Concat(name, str); | 2182 name = String::Concat(name, str); |
2186 str = ident(); | 2183 str = ident(); |
2187 name = String::Concat(name, str); | 2184 name = String::Concat(name, str); |
2188 return name.raw(); | 2185 return name.raw(); |
2189 } else { | 2186 } else { |
2190 return ident(); | 2187 return ident(); |
2191 } | 2188 } |
2192 } | 2189 } |
2193 | 2190 |
2194 | 2191 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2365 if (num_type_params == 0) { | 2362 if (num_type_params == 0) { |
2366 type_name = class_name.raw(); | 2363 type_name = class_name.raw(); |
2367 } else { | 2364 } else { |
2368 const String& args_name = String::Handle( | 2365 const String& args_name = String::Handle( |
2369 args.SubvectorName(first_type_param_index, num_type_params)); | 2366 args.SubvectorName(first_type_param_index, num_type_params)); |
2370 type_name = String::Concat(class_name, args_name); | 2367 type_name = String::Concat(class_name, args_name); |
2371 } | 2368 } |
2372 // The name is only used for type checking and debugging purposes. | 2369 // The name is only used for type checking and debugging purposes. |
2373 // Unless profiling data shows otherwise, it is not worth caching the name in | 2370 // Unless profiling data shows otherwise, it is not worth caching the name in |
2374 // the type. | 2371 // the type. |
2375 return String::NewSymbol(type_name); | 2372 return Symbols::New(type_name); |
2376 } | 2373 } |
2377 | 2374 |
2378 | 2375 |
2379 RawString* AbstractType::ClassName() const { | 2376 RawString* AbstractType::ClassName() const { |
2380 if (HasResolvedTypeClass()) { | 2377 if (HasResolvedTypeClass()) { |
2381 return Class::Handle(type_class()).Name(); | 2378 return Class::Handle(type_class()).Name(); |
2382 } else { | 2379 } else { |
2383 return UnresolvedClass::Handle(unresolved_class()).Name(); | 2380 return UnresolvedClass::Handle(unresolved_class()).Name(); |
2384 } | 2381 } |
2385 } | 2382 } |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2777 StorePointer(&raw_ptr()->type_class_, value.raw()); | 2774 StorePointer(&raw_ptr()->type_class_, value.raw()); |
2778 } | 2775 } |
2779 | 2776 |
2780 | 2777 |
2781 void Type::set_arguments(const AbstractTypeArguments& value) const { | 2778 void Type::set_arguments(const AbstractTypeArguments& value) const { |
2782 StorePointer(&raw_ptr()->arguments_, value.raw()); | 2779 StorePointer(&raw_ptr()->arguments_, value.raw()); |
2783 } | 2780 } |
2784 | 2781 |
2785 | 2782 |
2786 RawType* Type::New(Heap::Space space) { | 2783 RawType* Type::New(Heap::Space space) { |
2787 const Class& type_class = Class::Handle(Object::type_class()); | 2784 ASSERT(Object::type_class() != Class::null()); |
2788 RawObject* raw = Object::Allocate(type_class, | 2785 RawObject* raw = Object::Allocate(Type::kInstanceKind, |
2789 Type::InstanceSize(), | 2786 Type::InstanceSize(), |
2790 space); | 2787 space); |
2791 return reinterpret_cast<RawType*>(raw); | 2788 return reinterpret_cast<RawType*>(raw); |
2792 } | 2789 } |
2793 | 2790 |
2794 | 2791 |
2795 RawType* Type::New(const Object& clazz, | 2792 RawType* Type::New(const Object& clazz, |
2796 const AbstractTypeArguments& arguments, | 2793 const AbstractTypeArguments& arguments, |
2797 intptr_t token_pos, | 2794 intptr_t token_pos, |
2798 Heap::Space space) { | 2795 Heap::Space space) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2938 const AbstractTypeArguments& instantiator_type_arguments) const { | 2935 const AbstractTypeArguments& instantiator_type_arguments) const { |
2939 ASSERT(IsFinalized()); | 2936 ASSERT(IsFinalized()); |
2940 if (instantiator_type_arguments.IsNull()) { | 2937 if (instantiator_type_arguments.IsNull()) { |
2941 return Type::DynamicType(); | 2938 return Type::DynamicType(); |
2942 } | 2939 } |
2943 return instantiator_type_arguments.TypeAt(index()); | 2940 return instantiator_type_arguments.TypeAt(index()); |
2944 } | 2941 } |
2945 | 2942 |
2946 | 2943 |
2947 RawTypeParameter* TypeParameter::New() { | 2944 RawTypeParameter* TypeParameter::New() { |
2948 const Class& type_parameter_class = | 2945 ASSERT(Object::type_parameter_class() != Class::null()); |
2949 Class::Handle(Object::type_parameter_class()); | 2946 RawObject* raw = Object::Allocate(TypeParameter::kInstanceKind, |
2950 RawObject* raw = Object::Allocate(type_parameter_class, | |
2951 TypeParameter::InstanceSize(), | 2947 TypeParameter::InstanceSize(), |
2952 Heap::kOld); | 2948 Heap::kOld); |
2953 return reinterpret_cast<RawTypeParameter*>(raw); | 2949 return reinterpret_cast<RawTypeParameter*>(raw); |
2954 } | 2950 } |
2955 | 2951 |
2956 | 2952 |
2957 RawTypeParameter* TypeParameter::New(const Class& parameterized_class, | 2953 RawTypeParameter* TypeParameter::New(const Class& parameterized_class, |
2958 intptr_t index, | 2954 intptr_t index, |
2959 const String& name, | 2955 const String& name, |
2960 const AbstractType& bound, | 2956 const AbstractType& bound, |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3037 } | 3033 } |
3038 | 3034 |
3039 | 3035 |
3040 RawString* AbstractTypeArguments::SubvectorName(intptr_t from_index, | 3036 RawString* AbstractTypeArguments::SubvectorName(intptr_t from_index, |
3041 intptr_t len) const { | 3037 intptr_t len) const { |
3042 ASSERT(from_index + len <= Length()); | 3038 ASSERT(from_index + len <= Length()); |
3043 String& name = String::Handle(); | 3039 String& name = String::Handle(); |
3044 const intptr_t num_strings = 2*len + 1; // "<""T"", ""T"">". | 3040 const intptr_t num_strings = 2*len + 1; // "<""T"", ""T"">". |
3045 const Array& strings = Array::Handle(Array::New(num_strings)); | 3041 const Array& strings = Array::Handle(Array::New(num_strings)); |
3046 intptr_t s = 0; | 3042 intptr_t s = 0; |
3047 strings.SetAt(s++, String::Handle(String::NewSymbol("<"))); | 3043 strings.SetAt(s++, String::Handle(Symbols::New("<"))); |
3048 const String& kCommaSpace = String::Handle(String::NewSymbol(", ")); | 3044 const String& kCommaSpace = String::Handle(Symbols::New(", ")); |
3049 AbstractType& type = AbstractType::Handle(); | 3045 AbstractType& type = AbstractType::Handle(); |
3050 for (intptr_t i = 0; i < len; i++) { | 3046 for (intptr_t i = 0; i < len; i++) { |
3051 type = TypeAt(from_index + i); | 3047 type = TypeAt(from_index + i); |
3052 name = type.Name(); | 3048 name = type.Name(); |
3053 strings.SetAt(s++, name); | 3049 strings.SetAt(s++, name); |
3054 if (i < len - 1) { | 3050 if (i < len - 1) { |
3055 strings.SetAt(s++, kCommaSpace); | 3051 strings.SetAt(s++, kCommaSpace); |
3056 } | 3052 } |
3057 } | 3053 } |
3058 strings.SetAt(s++, String::Handle(String::NewSymbol(">"))); | 3054 strings.SetAt(s++, String::Handle(Symbols::New(">"))); |
3059 ASSERT(s == num_strings); | 3055 ASSERT(s == num_strings); |
3060 name = String::ConcatAll(strings); | 3056 name = String::ConcatAll(strings); |
3061 return String::NewSymbol(name); | 3057 return Symbols::New(name); |
3062 } | 3058 } |
3063 | 3059 |
3064 | 3060 |
3065 bool AbstractTypeArguments::Equals(const AbstractTypeArguments& other) const { | 3061 bool AbstractTypeArguments::Equals(const AbstractTypeArguments& other) const { |
3066 ASSERT(!IsNull()); // Use AbstractTypeArguments::AreEqual(). | 3062 ASSERT(!IsNull()); // Use AbstractTypeArguments::AreEqual(). |
3067 if (this->raw() == other.raw()) { | 3063 if (this->raw() == other.raw()) { |
3068 return true; | 3064 return true; |
3069 } | 3065 } |
3070 if (other.IsNull()) { | 3066 if (other.IsNull()) { |
3071 return false; | 3067 return false; |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3361 } | 3357 } |
3362 | 3358 |
3363 | 3359 |
3364 RawTypeArguments* TypeArguments::New(intptr_t len, Heap::Space space) { | 3360 RawTypeArguments* TypeArguments::New(intptr_t len, Heap::Space space) { |
3365 if ((len < 0) || (len > kMaxTypes)) { | 3361 if ((len < 0) || (len > kMaxTypes)) { |
3366 // TODO(iposva): Should we throw an illegal parameter exception? | 3362 // TODO(iposva): Should we throw an illegal parameter exception? |
3367 UNIMPLEMENTED(); | 3363 UNIMPLEMENTED(); |
3368 return null(); | 3364 return null(); |
3369 } | 3365 } |
3370 | 3366 |
3371 const Class& type_arguments_class = | |
3372 Class::Handle(Object::type_arguments_class()); | |
3373 TypeArguments& result = TypeArguments::Handle(); | 3367 TypeArguments& result = TypeArguments::Handle(); |
3374 { | 3368 { |
3375 RawObject* raw = Object::Allocate(type_arguments_class, | 3369 RawObject* raw = Object::Allocate(TypeArguments::kInstanceKind, |
3376 TypeArguments::InstanceSize(len), | 3370 TypeArguments::InstanceSize(len), |
3377 space); | 3371 space); |
3378 NoGCScope no_gc; | 3372 NoGCScope no_gc; |
3379 result ^= raw; | 3373 result ^= raw; |
3380 // Length must be set before we start storing into the array. | 3374 // Length must be set before we start storing into the array. |
3381 result.SetLength(len); | 3375 result.SetLength(len); |
3382 } | 3376 } |
3383 return result.raw(); | 3377 return result.raw(); |
3384 } | 3378 } |
3385 | 3379 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3485 } | 3479 } |
3486 | 3480 |
3487 | 3481 |
3488 void InstantiatedTypeArguments::set_instantiator_type_arguments( | 3482 void InstantiatedTypeArguments::set_instantiator_type_arguments( |
3489 const AbstractTypeArguments& value) const { | 3483 const AbstractTypeArguments& value) const { |
3490 StorePointer(&raw_ptr()->instantiator_type_arguments_, value.raw()); | 3484 StorePointer(&raw_ptr()->instantiator_type_arguments_, value.raw()); |
3491 } | 3485 } |
3492 | 3486 |
3493 | 3487 |
3494 RawInstantiatedTypeArguments* InstantiatedTypeArguments::New() { | 3488 RawInstantiatedTypeArguments* InstantiatedTypeArguments::New() { |
3495 const Class& instantiated_type_arguments_class = | 3489 ASSERT(Object::instantiated_type_arguments_class() != Class::null()); |
3496 Class::Handle(Object::instantiated_type_arguments_class()); | 3490 RawObject* raw = Object::Allocate(InstantiatedTypeArguments::kInstanceKind, |
3497 RawObject* raw = Object::Allocate(instantiated_type_arguments_class, | |
3498 InstantiatedTypeArguments::InstanceSize(), | 3491 InstantiatedTypeArguments::InstanceSize(), |
3499 Heap::kNew); | 3492 Heap::kNew); |
3500 return reinterpret_cast<RawInstantiatedTypeArguments*>(raw); | 3493 return reinterpret_cast<RawInstantiatedTypeArguments*>(raw); |
3501 } | 3494 } |
3502 | 3495 |
3503 | 3496 |
3504 RawInstantiatedTypeArguments* InstantiatedTypeArguments::New( | 3497 RawInstantiatedTypeArguments* InstantiatedTypeArguments::New( |
3505 const AbstractTypeArguments& uninstantiated_type_arguments, | 3498 const AbstractTypeArguments& uninstantiated_type_arguments, |
3506 const AbstractTypeArguments& instantiator_type_arguments) { | 3499 const AbstractTypeArguments& instantiator_type_arguments) { |
3507 const InstantiatedTypeArguments& result = | 3500 const InstantiatedTypeArguments& result = |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3989 bool Function::IsImplicitClosureFunction() const { | 3982 bool Function::IsImplicitClosureFunction() const { |
3990 if (!IsClosureFunction()) { | 3983 if (!IsClosureFunction()) { |
3991 return false; | 3984 return false; |
3992 } | 3985 } |
3993 const Function& parent = Function::Handle(parent_function()); | 3986 const Function& parent = Function::Handle(parent_function()); |
3994 return parent.raw_ptr()->implicit_closure_function_ == raw(); | 3987 return parent.raw_ptr()->implicit_closure_function_ == raw(); |
3995 } | 3988 } |
3996 | 3989 |
3997 | 3990 |
3998 RawFunction* Function::New() { | 3991 RawFunction* Function::New() { |
3999 const Class& function_class = Class::Handle(Object::function_class()); | 3992 ASSERT(Object::function_class() != Class::null()); |
4000 RawObject* raw = Object::Allocate(function_class, | 3993 RawObject* raw = Object::Allocate(Function::kInstanceKind, |
4001 Function::InstanceSize(), | 3994 Function::InstanceSize(), |
4002 Heap::kOld); | 3995 Heap::kOld); |
4003 return reinterpret_cast<RawFunction*>(raw); | 3996 return reinterpret_cast<RawFunction*>(raw); |
4004 } | 3997 } |
4005 | 3998 |
4006 | 3999 |
4007 RawFunction* Function::New(const String& name, | 4000 RawFunction* Function::New(const String& name, |
4008 RawFunction::Kind kind, | 4001 RawFunction::Kind kind, |
4009 bool is_static, | 4002 bool is_static, |
4010 bool is_const, | 4003 bool is_const, |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4120 ASSERT(closure_function.IsImplicitClosureFunction()); | 4113 ASSERT(closure_function.IsImplicitClosureFunction()); |
4121 return closure_function.raw(); | 4114 return closure_function.raw(); |
4122 } | 4115 } |
4123 | 4116 |
4124 | 4117 |
4125 RawString* Function::BuildSignature( | 4118 RawString* Function::BuildSignature( |
4126 bool instantiate, | 4119 bool instantiate, |
4127 const AbstractTypeArguments& instantiator) const { | 4120 const AbstractTypeArguments& instantiator) const { |
4128 const GrowableObjectArray& pieces = | 4121 const GrowableObjectArray& pieces = |
4129 GrowableObjectArray::Handle(GrowableObjectArray::New()); | 4122 GrowableObjectArray::Handle(GrowableObjectArray::New()); |
4130 const String& kCommaSpace = String::Handle(String::NewSymbol(", ")); | 4123 const String& kCommaSpace = String::Handle(Symbols::New(", ")); |
4131 const String& kColonSpace = String::Handle(String::NewSymbol(": ")); | 4124 const String& kColonSpace = String::Handle(Symbols::New(": ")); |
4132 const String& kLParen = String::Handle(String::NewSymbol("(")); | 4125 const String& kLParen = String::Handle(Symbols::New("(")); |
4133 const String& kRParen = String::Handle(String::NewSymbol(") => ")); | 4126 const String& kRParen = String::Handle(Symbols::New(") => ")); |
4134 const String& kLBracket = String::Handle(String::NewSymbol("[")); | 4127 const String& kLBracket = String::Handle(Symbols::New("[")); |
4135 const String& kRBracket = String::Handle(String::NewSymbol("]")); | 4128 const String& kRBracket = String::Handle(Symbols::New("]")); |
4136 String& name = String::Handle(); | 4129 String& name = String::Handle(); |
4137 if (!instantiate && !is_static()) { | 4130 if (!instantiate && !is_static()) { |
4138 const String& kSpaceExtendsSpace = | 4131 const String& kSpaceExtendsSpace = |
4139 String::Handle(String::NewSymbol(" extends ")); | 4132 String::Handle(Symbols::New(" extends ")); |
4140 const String& kLAngleBracket = String::Handle(String::NewSymbol("<")); | 4133 const String& kLAngleBracket = String::Handle(Symbols::New("<")); |
4141 const String& kRAngleBracket = String::Handle(String::NewSymbol(">")); | 4134 const String& kRAngleBracket = String::Handle(Symbols::New(">")); |
4142 const Class& function_class = Class::Handle(owner()); | 4135 const Class& function_class = Class::Handle(owner()); |
4143 ASSERT(!function_class.IsNull()); | 4136 ASSERT(!function_class.IsNull()); |
4144 const TypeArguments& type_parameters = TypeArguments::Handle( | 4137 const TypeArguments& type_parameters = TypeArguments::Handle( |
4145 function_class.type_parameters()); | 4138 function_class.type_parameters()); |
4146 if (!type_parameters.IsNull()) { | 4139 if (!type_parameters.IsNull()) { |
4147 intptr_t num_type_parameters = type_parameters.Length(); | 4140 intptr_t num_type_parameters = type_parameters.Length(); |
4148 pieces.Add(kLAngleBracket); | 4141 pieces.Add(kLAngleBracket); |
4149 TypeParameter& type_parameter = TypeParameter::Handle(); | 4142 TypeParameter& type_parameter = TypeParameter::Handle(); |
4150 AbstractType& bound = AbstractType::Handle(); | 4143 AbstractType& bound = AbstractType::Handle(); |
4151 for (intptr_t i = 0; i < num_type_parameters; i++) { | 4144 for (intptr_t i = 0; i < num_type_parameters; i++) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4203 pieces.Add(kRBracket); | 4196 pieces.Add(kRBracket); |
4204 } | 4197 } |
4205 pieces.Add(kRParen); | 4198 pieces.Add(kRParen); |
4206 AbstractType& res_type = AbstractType::Handle(result_type()); | 4199 AbstractType& res_type = AbstractType::Handle(result_type()); |
4207 if (instantiate && !res_type.IsInstantiated()) { | 4200 if (instantiate && !res_type.IsInstantiated()) { |
4208 res_type = res_type.InstantiateFrom(instantiator); | 4201 res_type = res_type.InstantiateFrom(instantiator); |
4209 } | 4202 } |
4210 name = res_type.Name(); | 4203 name = res_type.Name(); |
4211 pieces.Add(name); | 4204 pieces.Add(name); |
4212 const Array& strings = Array::Handle(Array::MakeArray(pieces)); | 4205 const Array& strings = Array::Handle(Array::MakeArray(pieces)); |
4213 return String::NewSymbol(String::Handle(String::ConcatAll(strings))); | 4206 return Symbols::New(String::Handle(String::ConcatAll(strings))); |
4214 } | 4207 } |
4215 | 4208 |
4216 | 4209 |
4217 bool Function::HasInstantiatedSignature() const { | 4210 bool Function::HasInstantiatedSignature() const { |
4218 AbstractType& type = AbstractType::Handle(result_type()); | 4211 AbstractType& type = AbstractType::Handle(result_type()); |
4219 if (!type.IsInstantiated()) { | 4212 if (!type.IsInstantiated()) { |
4220 return false; | 4213 return false; |
4221 } | 4214 } |
4222 const intptr_t num_parameters = NumberOfParameters(); | 4215 const intptr_t num_parameters = NumberOfParameters(); |
4223 for (intptr_t i = 0; i < num_parameters; i++) { | 4216 for (intptr_t i = 0; i < num_parameters; i++) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4281 String& str = String::Handle(); | 4274 String& str = String::Handle(); |
4282 str = String::New(kGetterPrefix); | 4275 str = String::New(kGetterPrefix); |
4283 str = String::Concat(str, field_name); | 4276 str = String::Concat(str, field_name); |
4284 return str.raw(); | 4277 return str.raw(); |
4285 } | 4278 } |
4286 | 4279 |
4287 | 4280 |
4288 RawString* Field::GetterSymbol(const String& field_name) { | 4281 RawString* Field::GetterSymbol(const String& field_name) { |
4289 String& str = String::Handle(); | 4282 String& str = String::Handle(); |
4290 str = Field::GetterName(field_name); | 4283 str = Field::GetterName(field_name); |
4291 return String::NewSymbol(str); | 4284 return Symbols::New(str); |
4292 } | 4285 } |
4293 | 4286 |
4294 | 4287 |
4295 RawString* Field::SetterName(const String& field_name) { | 4288 RawString* Field::SetterName(const String& field_name) { |
4296 String& str = String::Handle(); | 4289 String& str = String::Handle(); |
4297 str = String::New(kSetterPrefix); | 4290 str = String::New(kSetterPrefix); |
4298 str = String::Concat(str, field_name); | 4291 str = String::Concat(str, field_name); |
4299 return str.raw(); | 4292 return str.raw(); |
4300 } | 4293 } |
4301 | 4294 |
4302 | 4295 |
4303 RawString* Field::SetterSymbol(const String& field_name) { | 4296 RawString* Field::SetterSymbol(const String& field_name) { |
4304 String& str = String::Handle(); | 4297 String& str = String::Handle(); |
4305 str = Field::SetterName(field_name); | 4298 str = Field::SetterName(field_name); |
4306 return String::NewSymbol(str); | 4299 return Symbols::New(str); |
4307 } | 4300 } |
4308 | 4301 |
4309 | 4302 |
4310 RawString* Field::NameFromGetter(const String& getter_name) { | 4303 RawString* Field::NameFromGetter(const String& getter_name) { |
4311 String& str = String::Handle(); | 4304 String& str = String::Handle(); |
4312 str = String::SubString(getter_name, strlen(kGetterPrefix)); | 4305 str = String::SubString(getter_name, strlen(kGetterPrefix)); |
4313 return str.raw(); | 4306 return str.raw(); |
4314 } | 4307 } |
4315 | 4308 |
4316 | 4309 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4349 } | 4342 } |
4350 | 4343 |
4351 | 4344 |
4352 void Field::set_type(const AbstractType& value) const { | 4345 void Field::set_type(const AbstractType& value) const { |
4353 ASSERT(!value.IsNull()); | 4346 ASSERT(!value.IsNull()); |
4354 StorePointer(&raw_ptr()->type_, value.raw()); | 4347 StorePointer(&raw_ptr()->type_, value.raw()); |
4355 } | 4348 } |
4356 | 4349 |
4357 | 4350 |
4358 RawField* Field::New() { | 4351 RawField* Field::New() { |
4359 const Class& field_class = Class::Handle(Object::field_class()); | 4352 ASSERT(Object::field_class() != Class::null()); |
4360 RawObject* raw = Object::Allocate(field_class, | 4353 RawObject* raw = Object::Allocate(Field::kInstanceKind, |
4361 Field::InstanceSize(), | 4354 Field::InstanceSize(), |
4362 Heap::kOld); | 4355 Heap::kOld); |
4363 return reinterpret_cast<RawField*>(raw); | 4356 return reinterpret_cast<RawField*>(raw); |
4364 } | 4357 } |
4365 | 4358 |
4366 | 4359 |
4367 RawField* Field::New(const String& name, | 4360 RawField* Field::New(const String& name, |
4368 bool is_static, | 4361 bool is_static, |
4369 bool is_final, | 4362 bool is_final, |
4370 intptr_t token_pos) { | 4363 intptr_t token_pos) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4404 StorePointer(&raw_ptr()->literal_, literal.raw()); | 4397 StorePointer(&raw_ptr()->literal_, literal.raw()); |
4405 } | 4398 } |
4406 | 4399 |
4407 | 4400 |
4408 void LiteralToken::set_value(const Object& value) const { | 4401 void LiteralToken::set_value(const Object& value) const { |
4409 StorePointer(&raw_ptr()->value_, value.raw()); | 4402 StorePointer(&raw_ptr()->value_, value.raw()); |
4410 } | 4403 } |
4411 | 4404 |
4412 | 4405 |
4413 RawLiteralToken* LiteralToken::New() { | 4406 RawLiteralToken* LiteralToken::New() { |
4414 const Class& cls = Class::Handle(Object::literal_token_class()); | 4407 ASSERT(Object::literal_token_class() != Class::null()); |
4415 RawObject* raw = Object::Allocate(cls, | 4408 RawObject* raw = Object::Allocate(LiteralToken::kInstanceKind, |
4416 LiteralToken::InstanceSize(), | 4409 LiteralToken::InstanceSize(), |
4417 Heap::kOld); | 4410 Heap::kOld); |
4418 return reinterpret_cast<RawLiteralToken*>(raw); | 4411 return reinterpret_cast<RawLiteralToken*>(raw); |
4419 } | 4412 } |
4420 | 4413 |
4421 | 4414 |
4422 RawLiteralToken* LiteralToken::New(Token::Kind kind, const String& literal) { | 4415 RawLiteralToken* LiteralToken::New(Token::Kind kind, const String& literal) { |
4423 const LiteralToken& result = LiteralToken::Handle(LiteralToken::New()); | 4416 const LiteralToken& result = LiteralToken::Handle(LiteralToken::New()); |
4424 result.set_kind(kind); | 4417 result.set_kind(kind); |
4425 result.set_literal(literal); | 4418 result.set_literal(literal); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4524 while (index < src_pos && kind != Token::kEOS) { | 4517 while (index < src_pos && kind != Token::kEOS) { |
4525 iterator.Advance(); | 4518 iterator.Advance(); |
4526 kind = iterator.CurrentTokenKind(); | 4519 kind = iterator.CurrentTokenKind(); |
4527 index += 1; | 4520 index += 1; |
4528 } | 4521 } |
4529 return iterator.CurrentPosition(); | 4522 return iterator.CurrentPosition(); |
4530 } | 4523 } |
4531 | 4524 |
4532 | 4525 |
4533 RawTokenStream* TokenStream::New(intptr_t len) { | 4526 RawTokenStream* TokenStream::New(intptr_t len) { |
4534 const Class& token_stream_class = Class::Handle(Object::token_stream_class()); | 4527 ASSERT(Object::token_stream_class() != Class::null()); |
4535 TokenStream& result = TokenStream::Handle(); | 4528 TokenStream& result = TokenStream::Handle(); |
4536 { | 4529 { |
4537 RawObject* raw = Object::Allocate(token_stream_class, | 4530 RawObject* raw = Object::Allocate(TokenStream::kInstanceKind, |
4538 TokenStream::InstanceSize(len), | 4531 TokenStream::InstanceSize(len), |
4539 Heap::kOld); | 4532 Heap::kOld); |
4540 NoGCScope no_gc; | 4533 NoGCScope no_gc; |
4541 result ^= raw; | 4534 result ^= raw; |
4542 result.SetLength(len); | 4535 result.SetLength(len); |
4543 } | 4536 } |
4544 return result.raw(); | 4537 return result.raw(); |
4545 } | 4538 } |
4546 | 4539 |
4547 | 4540 |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4826 Isolate* isolate = Isolate::Current(); | 4819 Isolate* isolate = Isolate::Current(); |
4827 ObjectStore* object_store = isolate->object_store(); | 4820 ObjectStore* object_store = isolate->object_store(); |
4828 String& str = String::Handle(isolate, String::null()); | 4821 String& str = String::Handle(isolate, String::null()); |
4829 const Array& symbols = Array::Handle(isolate, | 4822 const Array& symbols = Array::Handle(isolate, |
4830 object_store->keyword_symbols()); | 4823 object_store->keyword_symbols()); |
4831 ASSERT(!symbols.IsNull()); | 4824 ASSERT(!symbols.IsNull()); |
4832 str ^= symbols.At(kind - Token::kFirstKeyword); | 4825 str ^= symbols.At(kind - Token::kFirstKeyword); |
4833 ASSERT(!str.IsNull()); | 4826 ASSERT(!str.IsNull()); |
4834 return str.raw(); | 4827 return str.raw(); |
4835 } | 4828 } |
4836 return String::NewSymbol(Token::Str(kind)); | 4829 return Symbols::New(Token::Str(kind)); |
4837 } else { | 4830 } else { |
4838 ASSERT(obj.IsLiteralToken()); // Must be a literal token. | 4831 ASSERT(obj.IsLiteralToken()); // Must be a literal token. |
4839 const LiteralToken& literal_token = LiteralToken::Cast(obj); | 4832 const LiteralToken& literal_token = LiteralToken::Cast(obj); |
4840 return literal_token.literal(); | 4833 return literal_token.literal(); |
4841 } | 4834 } |
4842 } | 4835 } |
4843 | 4836 |
4844 | 4837 |
4845 intptr_t TokenStream::Iterator::ReadToken() { | 4838 intptr_t TokenStream::Iterator::ReadToken() { |
4846 uint8_t b = ReadByte(); | 4839 uint8_t b = ReadByte(); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4964 current_line++; | 4957 current_line++; |
4965 } else if (src.CharAt(ix) == '\r') { | 4958 } else if (src.CharAt(ix) == '\r') { |
4966 if ((ix + 1 != src.Length()) && (src.CharAt(ix + 1) != '\n')) { | 4959 if ((ix + 1 != src.Length()) && (src.CharAt(ix + 1) != '\n')) { |
4967 current_line++; | 4960 current_line++; |
4968 } | 4961 } |
4969 } else { | 4962 } else { |
4970 last_char = ix; | 4963 last_char = ix; |
4971 } | 4964 } |
4972 } | 4965 } |
4973 // Guarantee that returned string is never NULL. | 4966 // Guarantee that returned string is never NULL. |
4974 String& line = String::Handle(String::NewSymbol("")); | 4967 String& line = String::Handle(Symbols::New("")); |
4975 if (line_start >= 0) { | 4968 if (line_start >= 0) { |
4976 line = String::SubString(src, line_start, last_char - line_start + 1); | 4969 line = String::SubString(src, line_start, last_char - line_start + 1); |
4977 } | 4970 } |
4978 return line.raw(); | 4971 return line.raw(); |
4979 } | 4972 } |
4980 | 4973 |
4981 | 4974 |
4982 RawString* Script::GetSnippet(intptr_t from_line, | 4975 RawString* Script::GetSnippet(intptr_t from_line, |
4983 intptr_t from_column, | 4976 intptr_t from_column, |
4984 intptr_t to_line, | 4977 intptr_t to_line, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5021 String& snippet = String::Handle(); | 5014 String& snippet = String::Handle(); |
5022 if ((snippet_start != -1) && (snippet_end != -1)) { | 5015 if ((snippet_start != -1) && (snippet_end != -1)) { |
5023 snippet = | 5016 snippet = |
5024 String::SubString(src, snippet_start, snippet_end - snippet_start); | 5017 String::SubString(src, snippet_start, snippet_end - snippet_start); |
5025 } | 5018 } |
5026 return snippet.raw(); | 5019 return snippet.raw(); |
5027 } | 5020 } |
5028 | 5021 |
5029 | 5022 |
5030 RawScript* Script::New() { | 5023 RawScript* Script::New() { |
5031 const Class& script_class = Class::Handle(Object::script_class()); | 5024 ASSERT(Object::script_class() != Class::null()); |
5032 RawObject* raw = Object::Allocate(script_class, | 5025 RawObject* raw = Object::Allocate(Script::kInstanceKind, |
5033 Script::InstanceSize(), | 5026 Script::InstanceSize(), |
5034 Heap::kOld); | 5027 Heap::kOld); |
5035 return reinterpret_cast<RawScript*>(raw); | 5028 return reinterpret_cast<RawScript*>(raw); |
5036 } | 5029 } |
5037 | 5030 |
5038 | 5031 |
5039 RawScript* Script::New(const String& url, | 5032 RawScript* Script::New(const String& url, |
5040 const String& source, | 5033 const String& source, |
5041 RawScript::Kind kind) { | 5034 RawScript::Kind kind) { |
5042 const Script& result = Script::Handle(Script::New()); | 5035 const Script& result = Script::Handle(Script::New()); |
5043 result.set_url(String::Handle(String::NewSymbol(url))); | 5036 result.set_url(String::Handle(Symbols::New(url))); |
5044 result.set_source(source); | 5037 result.set_source(source); |
5045 result.set_kind(kind); | 5038 result.set_kind(kind); |
5046 return result.raw(); | 5039 return result.raw(); |
5047 } | 5040 } |
5048 | 5041 |
5049 | 5042 |
5050 const char* Script::ToCString() const { | 5043 const char* Script::ToCString() const { |
5051 return "Script"; | 5044 return "Script"; |
5052 } | 5045 } |
5053 | 5046 |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5829 | 5822 |
5830 void Library::InitImportedIntoList() const { | 5823 void Library::InitImportedIntoList() const { |
5831 const Array& imported_into = | 5824 const Array& imported_into = |
5832 Array::Handle(Array::New(kInitialImportedIntoCapacity, Heap::kOld)); | 5825 Array::Handle(Array::New(kInitialImportedIntoCapacity, Heap::kOld)); |
5833 StorePointer(&raw_ptr()->imported_into_, imported_into.raw()); | 5826 StorePointer(&raw_ptr()->imported_into_, imported_into.raw()); |
5834 raw_ptr()->num_imported_into_ = 0; | 5827 raw_ptr()->num_imported_into_ = 0; |
5835 } | 5828 } |
5836 | 5829 |
5837 | 5830 |
5838 RawLibrary* Library::New() { | 5831 RawLibrary* Library::New() { |
5839 const Class& library_class = Class::Handle(Object::library_class()); | 5832 ASSERT(Object::library_class() != Class::null()); |
5840 RawObject* raw = Object::Allocate(library_class, | 5833 RawObject* raw = Object::Allocate(Library::kInstanceKind, |
5841 Library::InstanceSize(), | 5834 Library::InstanceSize(), |
5842 Heap::kOld); | 5835 Heap::kOld); |
5843 return reinterpret_cast<RawLibrary*>(raw); | 5836 return reinterpret_cast<RawLibrary*>(raw); |
5844 } | 5837 } |
5845 | 5838 |
5846 | 5839 |
5847 RawLibrary* Library::NewLibraryHelper(const String& url, | 5840 RawLibrary* Library::NewLibraryHelper(const String& url, |
5848 bool import_core_lib) { | 5841 bool import_core_lib) { |
5849 const Library& result = Library::Handle(Library::New()); | 5842 const Library& result = Library::Handle(Library::New()); |
5850 result.raw_ptr()->name_ = url.raw(); | 5843 result.raw_ptr()->name_ = url.raw(); |
(...skipping 20 matching lines...) Expand all Loading... | |
5871 return result.raw(); | 5864 return result.raw(); |
5872 } | 5865 } |
5873 | 5866 |
5874 | 5867 |
5875 RawLibrary* Library::New(const String& url) { | 5868 RawLibrary* Library::New(const String& url) { |
5876 return NewLibraryHelper(url, true); | 5869 return NewLibraryHelper(url, true); |
5877 } | 5870 } |
5878 | 5871 |
5879 | 5872 |
5880 void Library::InitCoreLibrary(Isolate* isolate) { | 5873 void Library::InitCoreLibrary(Isolate* isolate) { |
5881 const String& core_lib_url = String::Handle(String::NewSymbol("dart:core")); | 5874 const String& core_lib_url = String::Handle(Symbols::New("dart:core")); |
5882 const Library& core_lib = | 5875 const Library& core_lib = |
5883 Library::Handle(Library::NewLibraryHelper(core_lib_url, false)); | 5876 Library::Handle(Library::NewLibraryHelper(core_lib_url, false)); |
5884 core_lib.Register(); | 5877 core_lib.Register(); |
5885 isolate->object_store()->set_core_library(core_lib); | 5878 isolate->object_store()->set_core_library(core_lib); |
5886 const String& core_impl_lib_url = | 5879 const String& core_impl_lib_url = |
5887 String::Handle(String::NewSymbol("dart:coreimpl")); | 5880 String::Handle(Symbols::New("dart:coreimpl")); |
5888 const Library& core_impl_lib = | 5881 const Library& core_impl_lib = |
5889 Library::Handle(Library::NewLibraryHelper(core_impl_lib_url, false)); | 5882 Library::Handle(Library::NewLibraryHelper(core_impl_lib_url, false)); |
5890 isolate->object_store()->set_core_impl_library(core_impl_lib); | 5883 isolate->object_store()->set_core_impl_library(core_impl_lib); |
5891 core_impl_lib.Register(); | 5884 core_impl_lib.Register(); |
5892 core_lib.AddImport(core_impl_lib); | 5885 core_lib.AddImport(core_impl_lib); |
5893 core_impl_lib.AddImport(core_lib); | 5886 core_impl_lib.AddImport(core_lib); |
5894 isolate->object_store()->set_root_library(Library::Handle()); | 5887 isolate->object_store()->set_root_library(Library::Handle()); |
5895 } | 5888 } |
5896 | 5889 |
5897 | 5890 |
5898 void Library::InitMathLibrary(Isolate* isolate) { | 5891 void Library::InitMathLibrary(Isolate* isolate) { |
5899 const String& url = String::Handle(String::NewSymbol("dart:math")); | 5892 const String& url = String::Handle(Symbols::New("dart:math")); |
5900 const Library& lib = Library::Handle(Library::New(url)); | 5893 const Library& lib = Library::Handle(Library::New(url)); |
5901 lib.Register(); | 5894 lib.Register(); |
5902 const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary()); | 5895 const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary()); |
5903 lib.AddImport(core_impl_lib); | 5896 lib.AddImport(core_impl_lib); |
5904 isolate->object_store()->set_math_library(lib); | 5897 isolate->object_store()->set_math_library(lib); |
5905 } | 5898 } |
5906 | 5899 |
5907 | 5900 |
5908 void Library::InitIsolateLibrary(Isolate* isolate) { | 5901 void Library::InitIsolateLibrary(Isolate* isolate) { |
5909 const String& url = String::Handle(String::NewSymbol("dart:isolate")); | 5902 const String& url = String::Handle(Symbols::New("dart:isolate")); |
5910 const Library& lib = Library::Handle(Library::New(url)); | 5903 const Library& lib = Library::Handle(Library::New(url)); |
5911 lib.Register(); | 5904 lib.Register(); |
5912 isolate->object_store()->set_isolate_library(lib); | 5905 isolate->object_store()->set_isolate_library(lib); |
5913 } | 5906 } |
5914 | 5907 |
5915 | 5908 |
5916 void Library::InitMirrorsLibrary(Isolate* isolate) { | 5909 void Library::InitMirrorsLibrary(Isolate* isolate) { |
5917 const String& url = String::Handle(String::NewSymbol("dart:mirrors")); | 5910 const String& url = String::Handle(Symbols::New("dart:mirrors")); |
5918 const Library& lib = Library::Handle(Library::New(url)); | 5911 const Library& lib = Library::Handle(Library::New(url)); |
5919 lib.Register(); | 5912 lib.Register(); |
5920 const Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); | 5913 const Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); |
5921 lib.AddImport(isolate_lib); | 5914 lib.AddImport(isolate_lib); |
5922 const Library& wrappers_lib = | 5915 const Library& wrappers_lib = |
5923 Library::Handle(Library::NativeWrappersLibrary()); | 5916 Library::Handle(Library::NativeWrappersLibrary()); |
5924 lib.AddImport(wrappers_lib); | 5917 lib.AddImport(wrappers_lib); |
5925 isolate->object_store()->set_mirrors_library(lib); | 5918 isolate->object_store()->set_mirrors_library(lib); |
5926 } | 5919 } |
5927 | 5920 |
5928 | 5921 |
5929 void Library::InitNativeWrappersLibrary(Isolate* isolate) { | 5922 void Library::InitNativeWrappersLibrary(Isolate* isolate) { |
5930 static const int kNumNativeWrappersClasses = 4; | 5923 static const int kNumNativeWrappersClasses = 4; |
5931 ASSERT(kNumNativeWrappersClasses > 0 && kNumNativeWrappersClasses < 10); | 5924 ASSERT(kNumNativeWrappersClasses > 0 && kNumNativeWrappersClasses < 10); |
5932 const String& native_flds_lib_url = String::Handle( | 5925 const String& native_flds_lib_url = String::Handle( |
5933 String::NewSymbol("dart:nativewrappers")); | 5926 Symbols::New("dart:nativewrappers")); |
5934 Library& native_flds_lib = Library::Handle( | 5927 Library& native_flds_lib = Library::Handle( |
5935 Library::NewLibraryHelper(native_flds_lib_url, false)); | 5928 Library::NewLibraryHelper(native_flds_lib_url, false)); |
5936 native_flds_lib.Register(); | 5929 native_flds_lib.Register(); |
5937 isolate->object_store()->set_native_wrappers_library(native_flds_lib); | 5930 isolate->object_store()->set_native_wrappers_library(native_flds_lib); |
5938 static const char* const kNativeWrappersClass = "NativeFieldWrapperClass"; | 5931 static const char* const kNativeWrappersClass = "NativeFieldWrapperClass"; |
5939 static const int kNameLength = 25; | 5932 static const int kNameLength = 25; |
5940 ASSERT(kNameLength == (strlen(kNativeWrappersClass) + 1 + 1)); | 5933 ASSERT(kNameLength == (strlen(kNativeWrappersClass) + 1 + 1)); |
5941 char name_buffer[kNameLength]; | 5934 char name_buffer[kNameLength]; |
5942 String& cls_name = String::Handle(); | 5935 String& cls_name = String::Handle(); |
5943 for (int fld_cnt = 1; fld_cnt <= kNumNativeWrappersClasses; fld_cnt++) { | 5936 for (int fld_cnt = 1; fld_cnt <= kNumNativeWrappersClasses; fld_cnt++) { |
5944 OS::SNPrint(name_buffer, | 5937 OS::SNPrint(name_buffer, |
5945 kNameLength, | 5938 kNameLength, |
5946 "%s%d", | 5939 "%s%d", |
5947 kNativeWrappersClass, | 5940 kNativeWrappersClass, |
5948 fld_cnt); | 5941 fld_cnt); |
5949 cls_name = String::NewSymbol(name_buffer); | 5942 cls_name = Symbols::New(name_buffer); |
5950 Class::NewNativeWrapper(&native_flds_lib, cls_name, fld_cnt); | 5943 Class::NewNativeWrapper(&native_flds_lib, cls_name, fld_cnt); |
5951 } | 5944 } |
5952 } | 5945 } |
5953 | 5946 |
5954 | 5947 |
5955 RawLibrary* Library::LookupLibrary(const String &url) { | 5948 RawLibrary* Library::LookupLibrary(const String &url) { |
5956 Isolate* isolate = Isolate::Current(); | 5949 Isolate* isolate = Isolate::Current(); |
5957 Library& lib = Library::Handle(isolate, Library::null()); | 5950 Library& lib = Library::Handle(isolate, Library::null()); |
5958 String& lib_url = String::Handle(isolate, String::null()); | 5951 String& lib_url = String::Handle(isolate, String::null()); |
5959 GrowableObjectArray& libs = GrowableObjectArray::Handle( | 5952 GrowableObjectArray& libs = GrowableObjectArray::Handle( |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6006 return false; | 5999 return false; |
6007 } | 6000 } |
6008 | 6001 |
6009 | 6002 |
6010 RawString* Library::PrivateName(const String& name) const { | 6003 RawString* Library::PrivateName(const String& name) const { |
6011 ASSERT(ShouldBePrivate(name)); | 6004 ASSERT(ShouldBePrivate(name)); |
6012 // ASSERT(strchr(name, '@') == NULL); | 6005 // ASSERT(strchr(name, '@') == NULL); |
6013 String& str = String::Handle(); | 6006 String& str = String::Handle(); |
6014 str ^= name.raw(); | 6007 str ^= name.raw(); |
6015 str = String::Concat(str, String::Handle(this->private_key())); | 6008 str = String::Concat(str, String::Handle(this->private_key())); |
6016 str = String::NewSymbol(str); | 6009 str = Symbols::New(str); |
6017 return str.raw(); | 6010 return str.raw(); |
6018 } | 6011 } |
6019 | 6012 |
6020 | 6013 |
6021 RawLibrary* Library::GetLibrary(intptr_t index) { | 6014 RawLibrary* Library::GetLibrary(intptr_t index) { |
6022 Isolate* isolate = Isolate::Current(); | 6015 Isolate* isolate = Isolate::Current(); |
6023 const GrowableObjectArray& libs = | 6016 const GrowableObjectArray& libs = |
6024 GrowableObjectArray::Handle(isolate->object_store()->libraries()); | 6017 GrowableObjectArray::Handle(isolate->object_store()->libraries()); |
6025 ASSERT(!libs.IsNull()); | 6018 ASSERT(!libs.IsNull()); |
6026 if ((0 <= index) && (index < libs.Length())) { | 6019 if ((0 <= index) && (index < libs.Length())) { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6144 resolved_class = lib.LookupLocalClass(class_name); | 6137 resolved_class = lib.LookupLocalClass(class_name); |
6145 if (!resolved_class.IsNull()) { | 6138 if (!resolved_class.IsNull()) { |
6146 return resolved_class.raw(); | 6139 return resolved_class.raw(); |
6147 } | 6140 } |
6148 } | 6141 } |
6149 return Class::null(); | 6142 return Class::null(); |
6150 } | 6143 } |
6151 | 6144 |
6152 | 6145 |
6153 RawLibraryPrefix* LibraryPrefix::New() { | 6146 RawLibraryPrefix* LibraryPrefix::New() { |
6154 const Class& library_prefix_class = | 6147 ASSERT(Object::library_prefix_class() != Class::null()); |
6155 Class::Handle(Object::library_prefix_class()); | 6148 RawObject* raw = Object::Allocate(LibraryPrefix::kInstanceKind, |
6156 RawObject* raw = Object::Allocate(library_prefix_class, | |
6157 LibraryPrefix::InstanceSize(), | 6149 LibraryPrefix::InstanceSize(), |
6158 Heap::kOld); | 6150 Heap::kOld); |
6159 return reinterpret_cast<RawLibraryPrefix*>(raw); | 6151 return reinterpret_cast<RawLibraryPrefix*>(raw); |
6160 } | 6152 } |
6161 | 6153 |
6162 | 6154 |
6163 RawLibraryPrefix* LibraryPrefix::New(const String& name, const Library& lib) { | 6155 RawLibraryPrefix* LibraryPrefix::New(const String& name, const Library& lib) { |
6164 const LibraryPrefix& result = LibraryPrefix::Handle(LibraryPrefix::New()); | 6156 const LibraryPrefix& result = LibraryPrefix::Handle(LibraryPrefix::New()); |
6165 result.set_name(name); | 6157 result.set_name(name); |
6166 result.set_num_libs(0); | 6158 result.set_num_libs(0); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6271 if (!error.IsNull()) { | 6263 if (!error.IsNull()) { |
6272 return error.raw(); | 6264 return error.raw(); |
6273 } | 6265 } |
6274 } | 6266 } |
6275 } | 6267 } |
6276 return error.raw(); | 6268 return error.raw(); |
6277 } | 6269 } |
6278 | 6270 |
6279 | 6271 |
6280 RawInstructions* Instructions::New(intptr_t size) { | 6272 RawInstructions* Instructions::New(intptr_t size) { |
6281 const Class& instructions_class = Class::Handle(Object::instructions_class()); | 6273 ASSERT(Object::instructions_class() != Class::null()); |
6282 Instructions& result = Instructions::Handle(); | 6274 Instructions& result = Instructions::Handle(); |
6283 { | 6275 { |
6284 uword aligned_size = Instructions::InstanceSize(size); | 6276 uword aligned_size = Instructions::InstanceSize(size); |
6285 RawObject* raw = Object::Allocate(instructions_class, | 6277 RawObject* raw = Object::Allocate(Instructions::kInstanceKind, |
6286 aligned_size, | 6278 aligned_size, |
6287 Heap::kCode); | 6279 Heap::kCode); |
6288 NoGCScope no_gc; | 6280 NoGCScope no_gc; |
6289 // TODO(iposva): Remove premarking once old and code spaces are merged. | 6281 // TODO(iposva): Remove premarking once old and code spaces are merged. |
6290 raw->SetMarkBit(); | 6282 raw->SetMarkBit(); |
6291 result ^= raw; | 6283 result ^= raw; |
6292 result.set_size(size); | 6284 result.set_size(size); |
6293 } | 6285 } |
6294 return result.raw(); | 6286 return result.raw(); |
6295 } | 6287 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6356 return *(EntryAddr(index, kTryIndexEntry)); | 6348 return *(EntryAddr(index, kTryIndexEntry)); |
6357 } | 6349 } |
6358 | 6350 |
6359 | 6351 |
6360 void PcDescriptors::SetTryIndex(intptr_t index, intptr_t value) const { | 6352 void PcDescriptors::SetTryIndex(intptr_t index, intptr_t value) const { |
6361 *(EntryAddr(index, kTryIndexEntry)) = value; | 6353 *(EntryAddr(index, kTryIndexEntry)) = value; |
6362 } | 6354 } |
6363 | 6355 |
6364 | 6356 |
6365 RawPcDescriptors* PcDescriptors::New(intptr_t num_descriptors) { | 6357 RawPcDescriptors* PcDescriptors::New(intptr_t num_descriptors) { |
6366 const Class& cls = Class::Handle(Object::pc_descriptors_class()); | 6358 ASSERT(Object::pc_descriptors_class() != Class::null()); |
6367 PcDescriptors& result = PcDescriptors::Handle(); | 6359 PcDescriptors& result = PcDescriptors::Handle(); |
6368 { | 6360 { |
6369 uword size = PcDescriptors::InstanceSize(num_descriptors); | 6361 uword size = PcDescriptors::InstanceSize(num_descriptors); |
6370 RawObject* raw = Object::Allocate(cls, size, Heap::kOld); | 6362 RawObject* raw = Object::Allocate(PcDescriptors::kInstanceKind, |
6363 size, | |
6364 Heap::kOld); | |
6371 NoGCScope no_gc; | 6365 NoGCScope no_gc; |
6372 result ^= raw; | 6366 result ^= raw; |
6373 result.SetLength(num_descriptors); | 6367 result.SetLength(num_descriptors); |
6374 } | 6368 } |
6375 return result.raw(); | 6369 return result.raw(); |
6376 } | 6370 } |
6377 | 6371 |
6378 | 6372 |
6379 const char* PcDescriptors::KindAsStr(intptr_t index) const { | 6373 const char* PcDescriptors::KindAsStr(intptr_t index) const { |
6380 switch (DescriptorKind(index)) { | 6374 switch (DescriptorKind(index)) { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6477 uint8_t* byte_addr = &(raw_ptr()->data_[byte_offset]); | 6471 uint8_t* byte_addr = &(raw_ptr()->data_[byte_offset]); |
6478 if (value) { | 6472 if (value) { |
6479 *byte_addr |= byte_mask; | 6473 *byte_addr |= byte_mask; |
6480 } else { | 6474 } else { |
6481 *byte_addr &= ~byte_mask; | 6475 *byte_addr &= ~byte_mask; |
6482 } | 6476 } |
6483 } | 6477 } |
6484 | 6478 |
6485 | 6479 |
6486 RawStackmap* Stackmap::New(uword pc_offset, BitmapBuilder* bmap) { | 6480 RawStackmap* Stackmap::New(uword pc_offset, BitmapBuilder* bmap) { |
6487 const Class& cls = Class::Handle(Object::stackmap_class()); | 6481 ASSERT(Object::stackmap_class() != Class::null()); |
6488 ASSERT(!cls.IsNull()); | |
6489 ASSERT(bmap != NULL); | 6482 ASSERT(bmap != NULL); |
6490 Stackmap& result = Stackmap::Handle(); | 6483 Stackmap& result = Stackmap::Handle(); |
6491 intptr_t size = bmap->SizeInBytes(); | 6484 intptr_t size = bmap->SizeInBytes(); |
6492 { | 6485 { |
6493 // Stackmap data objects are associated with a code object, allocate them | 6486 // Stackmap data objects are associated with a code object, allocate them |
6494 // in old generation. | 6487 // in old generation. |
6495 RawObject* raw = | 6488 RawObject* raw = Object::Allocate(Stackmap::kInstanceKind, |
6496 Object::Allocate(cls, Stackmap::InstanceSize(size), Heap::kOld); | 6489 Stackmap::InstanceSize(size), |
6490 Heap::kOld); | |
6497 NoGCScope no_gc; | 6491 NoGCScope no_gc; |
6498 result ^= raw; | 6492 result ^= raw; |
6499 result.set_bitmap_size_in_bytes(size); | 6493 result.set_bitmap_size_in_bytes(size); |
6500 } | 6494 } |
6501 result.SetPC(pc_offset); | 6495 result.SetPC(pc_offset); |
6502 intptr_t bound = bmap->SizeInBits(); | 6496 intptr_t bound = bmap->SizeInBits(); |
6503 for (intptr_t i = 0; i < bound; i++) { | 6497 for (intptr_t i = 0; i < bound; i++) { |
6504 result.SetBit(i, bmap->Get(i)); | 6498 result.SetBit(i, bmap->Get(i)); |
6505 } | 6499 } |
6506 result.SetMinBitOffset(bmap->Minimum()); | 6500 result.SetMinBitOffset(bmap->Minimum()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6566 } | 6560 } |
6567 | 6561 |
6568 | 6562 |
6569 const char* LocalVarDescriptors::ToCString() const { | 6563 const char* LocalVarDescriptors::ToCString() const { |
6570 UNIMPLEMENTED(); | 6564 UNIMPLEMENTED(); |
6571 return "LocalVarDescriptors"; | 6565 return "LocalVarDescriptors"; |
6572 } | 6566 } |
6573 | 6567 |
6574 | 6568 |
6575 RawLocalVarDescriptors* LocalVarDescriptors::New(intptr_t num_variables) { | 6569 RawLocalVarDescriptors* LocalVarDescriptors::New(intptr_t num_variables) { |
6576 const Class& cls = Class::Handle(Object::var_descriptors_class()); | 6570 ASSERT(Object::var_descriptors_class() != Class::null()); |
6577 LocalVarDescriptors& result = LocalVarDescriptors::Handle(); | 6571 LocalVarDescriptors& result = LocalVarDescriptors::Handle(); |
6578 { | 6572 { |
6579 uword size = LocalVarDescriptors::InstanceSize(num_variables); | 6573 uword size = LocalVarDescriptors::InstanceSize(num_variables); |
6580 RawObject* raw = Object::Allocate(cls, size, Heap::kOld); | 6574 RawObject* raw = Object::Allocate(LocalVarDescriptors::kInstanceKind, |
6575 size, | |
6576 Heap::kOld); | |
6581 NoGCScope no_gc; | 6577 NoGCScope no_gc; |
6582 result ^= raw; | 6578 result ^= raw; |
6583 result.raw_ptr()->length_ = num_variables; | 6579 result.raw_ptr()->length_ = num_variables; |
6584 } | 6580 } |
6585 const Array& names = Array::Handle(Array::New(num_variables, Heap::kOld)); | 6581 const Array& names = Array::Handle(Array::New(num_variables, Heap::kOld)); |
6586 result.raw_ptr()->names_ = names.raw(); | 6582 result.raw_ptr()->names_ = names.raw(); |
6587 return result.raw(); | 6583 return result.raw(); |
6588 } | 6584 } |
6589 | 6585 |
6590 | 6586 |
(...skipping 29 matching lines...) Expand all Loading... | |
6620 } | 6616 } |
6621 | 6617 |
6622 | 6618 |
6623 void ExceptionHandlers::SetHandlerPC(intptr_t index, | 6619 void ExceptionHandlers::SetHandlerPC(intptr_t index, |
6624 intptr_t value) const { | 6620 intptr_t value) const { |
6625 *(EntryAddr(index, kHandlerPcEntry)) = value; | 6621 *(EntryAddr(index, kHandlerPcEntry)) = value; |
6626 } | 6622 } |
6627 | 6623 |
6628 | 6624 |
6629 RawExceptionHandlers* ExceptionHandlers::New(intptr_t num_handlers) { | 6625 RawExceptionHandlers* ExceptionHandlers::New(intptr_t num_handlers) { |
6630 const Class& cls = Class::Handle(Object::exception_handlers_class()); | 6626 ASSERT(Object::exception_handlers_class() != Class::null()); |
6631 ExceptionHandlers& result = ExceptionHandlers::Handle(); | 6627 ExceptionHandlers& result = ExceptionHandlers::Handle(); |
6632 { | 6628 { |
6633 uword size = ExceptionHandlers::InstanceSize(num_handlers); | 6629 uword size = ExceptionHandlers::InstanceSize(num_handlers); |
6634 RawObject* raw = Object::Allocate(cls, size, Heap::kOld); | 6630 RawObject* raw = Object::Allocate(ExceptionHandlers::kInstanceKind, |
6631 size, | |
6632 Heap::kOld); | |
6635 NoGCScope no_gc; | 6633 NoGCScope no_gc; |
6636 result ^= raw; | 6634 result ^= raw; |
6637 result.SetLength(num_handlers); | 6635 result.SetLength(num_handlers); |
6638 } | 6636 } |
6639 return result.raw(); | 6637 return result.raw(); |
6640 } | 6638 } |
6641 | 6639 |
6642 | 6640 |
6643 const char* ExceptionHandlers::ToCString() const { | 6641 const char* ExceptionHandlers::ToCString() const { |
6644 if (Length() == 0) { | 6642 if (Length() == 0) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6723 return *comments; | 6721 return *comments; |
6724 } | 6722 } |
6725 | 6723 |
6726 | 6724 |
6727 void Code::set_comments(const Code::Comments& comments) const { | 6725 void Code::set_comments(const Code::Comments& comments) const { |
6728 StorePointer(&raw_ptr()->comments_, comments.comments_.raw()); | 6726 StorePointer(&raw_ptr()->comments_, comments.comments_.raw()); |
6729 } | 6727 } |
6730 | 6728 |
6731 | 6729 |
6732 RawCode* Code::New(int pointer_offsets_length) { | 6730 RawCode* Code::New(int pointer_offsets_length) { |
6733 const Class& cls = Class::Handle(Object::code_class()); | 6731 ASSERT(Object::code_class() != Class::null()); |
6734 Code& result = Code::Handle(); | 6732 Code& result = Code::Handle(); |
6735 { | 6733 { |
6736 uword size = Code::InstanceSize(pointer_offsets_length); | 6734 uword size = Code::InstanceSize(pointer_offsets_length); |
6737 RawObject* raw = Object::Allocate(cls, size, Heap::kOld); | 6735 RawObject* raw = Object::Allocate(Code::kInstanceKind, size, Heap::kOld); |
6738 NoGCScope no_gc; | 6736 NoGCScope no_gc; |
6739 result ^= raw; | 6737 result ^= raw; |
6740 result.set_pointer_offsets_length(pointer_offsets_length); | 6738 result.set_pointer_offsets_length(pointer_offsets_length); |
6741 result.set_is_optimized(false); | 6739 result.set_is_optimized(false); |
6742 result.set_comments(Comments::New(0)); | 6740 result.set_comments(Comments::New(0)); |
6743 } | 6741 } |
6744 return result.raw(); | 6742 return result.raw(); |
6745 } | 6743 } |
6746 | 6744 |
6747 | 6745 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6952 } | 6950 } |
6953 previous_map = map->raw(); | 6951 previous_map = map->raw(); |
6954 } | 6952 } |
6955 return map->raw(); | 6953 return map->raw(); |
6956 } | 6954 } |
6957 | 6955 |
6958 | 6956 |
6959 RawContext* Context::New(intptr_t num_variables, Heap::Space space) { | 6957 RawContext* Context::New(intptr_t num_variables, Heap::Space space) { |
6960 ASSERT(num_variables >= 0); | 6958 ASSERT(num_variables >= 0); |
6961 | 6959 |
6962 const Class& context_class = Class::Handle(Object::context_class()); | |
Ivan Posva
2012/07/23 18:26:34
No assertion here? Maybe others...
siva
2012/07/23 23:09:00
Done.
| |
6963 Context& result = Context::Handle(); | 6960 Context& result = Context::Handle(); |
6964 { | 6961 { |
6965 RawObject* raw = Object::Allocate(context_class, | 6962 RawObject* raw = Object::Allocate(Context::kInstanceKind, |
6966 Context::InstanceSize(num_variables), | 6963 Context::InstanceSize(num_variables), |
6967 space); | 6964 space); |
6968 NoGCScope no_gc; | 6965 NoGCScope no_gc; |
6969 result ^= raw; | 6966 result ^= raw; |
6970 result.set_num_variables(num_variables); | 6967 result.set_num_variables(num_variables); |
6971 } | 6968 } |
6972 result.set_isolate(Isolate::Current()); | 6969 result.set_isolate(Isolate::Current()); |
6973 return result.raw(); | 6970 return result.raw(); |
6974 } | 6971 } |
6975 | 6972 |
6976 | 6973 |
6977 const char* Context::ToCString() const { | 6974 const char* Context::ToCString() const { |
6978 return "Context"; | 6975 return "Context"; |
6979 } | 6976 } |
6980 | 6977 |
6981 | 6978 |
6982 RawContextScope* ContextScope::New(intptr_t num_variables) { | 6979 RawContextScope* ContextScope::New(intptr_t num_variables) { |
6983 const Class& context_scope_class = | 6980 ASSERT(Object::context_scope_class() != Class::null()); |
6984 Class::Handle(Object::context_scope_class()); | |
6985 intptr_t size = ContextScope::InstanceSize(num_variables); | 6981 intptr_t size = ContextScope::InstanceSize(num_variables); |
6986 ContextScope& result = ContextScope::Handle(); | 6982 ContextScope& result = ContextScope::Handle(); |
6987 { | 6983 { |
6988 RawObject* raw = Object::Allocate(context_scope_class, size, Heap::kOld); | 6984 RawObject* raw = Object::Allocate(ContextScope::kInstanceKind, |
6985 size, | |
6986 Heap::kOld); | |
6989 NoGCScope no_gc; | 6987 NoGCScope no_gc; |
6990 result ^= raw; | 6988 result ^= raw; |
6991 result.set_num_variables(num_variables); | 6989 result.set_num_variables(num_variables); |
6992 } | 6990 } |
6993 return result.raw(); | 6991 return result.raw(); |
6994 } | 6992 } |
6995 | 6993 |
6996 | 6994 |
6997 intptr_t ContextScope::TokenIndexAt(intptr_t scope_index) const { | 6995 intptr_t ContextScope::TokenIndexAt(intptr_t scope_index) const { |
6998 return Smi::Value(VariableDescAddr(scope_index)->token_pos); | 6996 return Smi::Value(VariableDescAddr(scope_index)->token_pos); |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7249 } | 7247 } |
7250 } | 7248 } |
7251 return result.raw(); | 7249 return result.raw(); |
7252 } | 7250 } |
7253 | 7251 |
7254 | 7252 |
7255 RawICData* ICData::New(const Function& function, | 7253 RawICData* ICData::New(const Function& function, |
7256 const String& target_name, | 7254 const String& target_name, |
7257 intptr_t id, | 7255 intptr_t id, |
7258 intptr_t num_args_tested) { | 7256 intptr_t num_args_tested) { |
7257 ASSERT(Object::icdata_class() != Class::null()); | |
7259 ASSERT(num_args_tested > 0); | 7258 ASSERT(num_args_tested > 0); |
7260 const Class& cls = Class::Handle(Object::icdata_class()); | |
7261 ASSERT(!cls.IsNull()); | |
7262 ICData& result = ICData::Handle(); | 7259 ICData& result = ICData::Handle(); |
7263 { | 7260 { |
7264 // IC data objects are long living objects, allocate them in old generation. | 7261 // IC data objects are long living objects, allocate them in old generation. |
7265 RawObject* raw = Object::Allocate(cls, ICData::InstanceSize(), Heap::kOld); | 7262 RawObject* raw = Object::Allocate(ICData::kInstanceKind, |
7263 ICData::InstanceSize(), | |
7264 Heap::kOld); | |
7266 NoGCScope no_gc; | 7265 NoGCScope no_gc; |
7267 result ^= raw; | 7266 result ^= raw; |
7268 } | 7267 } |
7269 result.set_function(function); | 7268 result.set_function(function); |
7270 result.set_target_name(target_name); | 7269 result.set_target_name(target_name); |
7271 result.set_id(id); | 7270 result.set_id(id); |
7272 result.set_num_args_tested(num_args_tested); | 7271 result.set_num_args_tested(num_args_tested); |
7273 // Number of array elements in one test entry (num_args_tested + 1) | 7272 // Number of array elements in one test entry (num_args_tested + 1) |
7274 intptr_t len = result.TestEntryLength(); | 7273 intptr_t len = result.TestEntryLength(); |
7275 // IC data array must be null terminated (sentinel entry). | 7274 // IC data array must be null terminated (sentinel entry). |
7276 const Array& ic_data = Array::Handle(Array::New(len, Heap::kOld)); | 7275 const Array& ic_data = Array::Handle(Array::New(len, Heap::kOld)); |
7277 result.set_ic_data(ic_data); | 7276 result.set_ic_data(ic_data); |
7278 return result.raw(); | 7277 return result.raw(); |
7279 } | 7278 } |
7280 | 7279 |
7281 | 7280 |
7282 RawSubtypeTestCache* SubtypeTestCache::New() { | 7281 RawSubtypeTestCache* SubtypeTestCache::New() { |
7283 const Class& cls = Class::Handle(Object::subtypetestcache_class()); | 7282 ASSERT(Object::subtypetestcache_class() != Class::null()); |
7284 ASSERT(!cls.IsNull()); | |
7285 SubtypeTestCache& result = SubtypeTestCache::Handle(); | 7283 SubtypeTestCache& result = SubtypeTestCache::Handle(); |
7286 { | 7284 { |
7287 // SubtypeTestCache objects are long living objects, allocate them in the | 7285 // SubtypeTestCache objects are long living objects, allocate them in the |
7288 // old generation. | 7286 // old generation. |
7289 RawObject* raw = | 7287 RawObject* raw = Object::Allocate(SubtypeTestCache::kInstanceKind, |
7290 Object::Allocate(cls, SubtypeTestCache::InstanceSize(), Heap::kOld); | 7288 SubtypeTestCache::InstanceSize(), |
7289 Heap::kOld); | |
7291 NoGCScope no_gc; | 7290 NoGCScope no_gc; |
7292 result ^= raw; | 7291 result ^= raw; |
7293 } | 7292 } |
7294 const Array& cache = Array::Handle(Array::New(kTestEntryLength)); | 7293 const Array& cache = Array::Handle(Array::New(kTestEntryLength)); |
7295 result.set_cache(cache); | 7294 result.set_cache(cache); |
7296 return result.raw(); | 7295 return result.raw(); |
7297 } | 7296 } |
7298 | 7297 |
7299 | 7298 |
7300 void SubtypeTestCache::set_cache(const Array& value) const { | 7299 void SubtypeTestCache::set_cache(const Array& value) const { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7358 | 7357 |
7359 | 7358 |
7360 const char* Error::ToCString() const { | 7359 const char* Error::ToCString() const { |
7361 // Error is an abstract class. We should never reach here. | 7360 // Error is an abstract class. We should never reach here. |
7362 UNREACHABLE(); | 7361 UNREACHABLE(); |
7363 return "Error"; | 7362 return "Error"; |
7364 } | 7363 } |
7365 | 7364 |
7366 | 7365 |
7367 RawApiError* ApiError::New(const String& message, Heap::Space space) { | 7366 RawApiError* ApiError::New(const String& message, Heap::Space space) { |
7368 const Class& cls = Class::Handle(Object::api_error_class()); | 7367 ASSERT(Object::api_error_class() != Class::null()); |
7369 ApiError& result = ApiError::Handle(); | 7368 ApiError& result = ApiError::Handle(); |
7370 { | 7369 { |
7371 RawObject* raw = Object::Allocate(cls, | 7370 RawObject* raw = Object::Allocate(ApiError::kInstanceKind, |
7372 ApiError::InstanceSize(), | 7371 ApiError::InstanceSize(), |
7373 space); | 7372 space); |
7374 NoGCScope no_gc; | 7373 NoGCScope no_gc; |
7375 result ^= raw; | 7374 result ^= raw; |
7376 } | 7375 } |
7377 result.set_message(message); | 7376 result.set_message(message); |
7378 return result.raw(); | 7377 return result.raw(); |
7379 } | 7378 } |
7380 | 7379 |
7381 | 7380 |
7382 void ApiError::set_message(const String& message) const { | 7381 void ApiError::set_message(const String& message) const { |
7383 StorePointer(&raw_ptr()->message_, message.raw()); | 7382 StorePointer(&raw_ptr()->message_, message.raw()); |
7384 } | 7383 } |
7385 | 7384 |
7386 | 7385 |
7387 const char* ApiError::ToErrorCString() const { | 7386 const char* ApiError::ToErrorCString() const { |
7388 const String& msg_str = String::Handle(message()); | 7387 const String& msg_str = String::Handle(message()); |
7389 return msg_str.ToCString(); | 7388 return msg_str.ToCString(); |
7390 } | 7389 } |
7391 | 7390 |
7392 | 7391 |
7393 const char* ApiError::ToCString() const { | 7392 const char* ApiError::ToCString() const { |
7394 return "ApiError"; | 7393 return "ApiError"; |
7395 } | 7394 } |
7396 | 7395 |
7397 | 7396 |
7398 RawLanguageError* LanguageError::New(const String& message, Heap::Space space) { | 7397 RawLanguageError* LanguageError::New(const String& message, Heap::Space space) { |
7399 const Class& cls = Class::Handle(Object::language_error_class()); | 7398 ASSERT(Object::language_error_class() != Class::null()); |
7400 LanguageError& result = LanguageError::Handle(); | 7399 LanguageError& result = LanguageError::Handle(); |
7401 { | 7400 { |
7402 RawObject* raw = Object::Allocate(cls, | 7401 RawObject* raw = Object::Allocate(LanguageError::kInstanceKind, |
7403 LanguageError::InstanceSize(), | 7402 LanguageError::InstanceSize(), |
7404 space); | 7403 space); |
7405 NoGCScope no_gc; | 7404 NoGCScope no_gc; |
7406 result ^= raw; | 7405 result ^= raw; |
7407 } | 7406 } |
7408 result.set_message(message); | 7407 result.set_message(message); |
7409 return result.raw(); | 7408 return result.raw(); |
7410 } | 7409 } |
7411 | 7410 |
7412 | 7411 |
7413 void LanguageError::set_message(const String& message) const { | 7412 void LanguageError::set_message(const String& message) const { |
7414 StorePointer(&raw_ptr()->message_, message.raw()); | 7413 StorePointer(&raw_ptr()->message_, message.raw()); |
7415 } | 7414 } |
7416 | 7415 |
7417 | 7416 |
7418 const char* LanguageError::ToErrorCString() const { | 7417 const char* LanguageError::ToErrorCString() const { |
7419 const String& msg_str = String::Handle(message()); | 7418 const String& msg_str = String::Handle(message()); |
7420 return msg_str.ToCString(); | 7419 return msg_str.ToCString(); |
7421 } | 7420 } |
7422 | 7421 |
7423 | 7422 |
7424 const char* LanguageError::ToCString() const { | 7423 const char* LanguageError::ToCString() const { |
7425 return "LanguageError"; | 7424 return "LanguageError"; |
7426 } | 7425 } |
7427 | 7426 |
7428 | 7427 |
7429 RawUnhandledException* UnhandledException::New(const Instance& exception, | 7428 RawUnhandledException* UnhandledException::New(const Instance& exception, |
7430 const Instance& stacktrace, | 7429 const Instance& stacktrace, |
7431 Heap::Space space) { | 7430 Heap::Space space) { |
7432 const Class& cls = Class::Handle(Object::unhandled_exception_class()); | 7431 ASSERT(Object::unhandled_exception_class() != Class::null()); |
7433 UnhandledException& result = UnhandledException::Handle(); | 7432 UnhandledException& result = UnhandledException::Handle(); |
7434 { | 7433 { |
7435 RawObject* raw = Object::Allocate(cls, | 7434 RawObject* raw = Object::Allocate(UnhandledException::kInstanceKind, |
7436 UnhandledException::InstanceSize(), | 7435 UnhandledException::InstanceSize(), |
7437 space); | 7436 space); |
7438 NoGCScope no_gc; | 7437 NoGCScope no_gc; |
7439 result ^= raw; | 7438 result ^= raw; |
7440 } | 7439 } |
7441 result.set_exception(exception); | 7440 result.set_exception(exception); |
7442 result.set_stacktrace(stacktrace); | 7441 result.set_stacktrace(stacktrace); |
7443 return result.raw(); | 7442 return result.raw(); |
7444 } | 7443 } |
7445 | 7444 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7483 return chars; | 7482 return chars; |
7484 } | 7483 } |
7485 | 7484 |
7486 | 7485 |
7487 const char* UnhandledException::ToCString() const { | 7486 const char* UnhandledException::ToCString() const { |
7488 return "UnhandledException"; | 7487 return "UnhandledException"; |
7489 } | 7488 } |
7490 | 7489 |
7491 | 7490 |
7492 RawUnwindError* UnwindError::New(const String& message, Heap::Space space) { | 7491 RawUnwindError* UnwindError::New(const String& message, Heap::Space space) { |
7493 const Class& cls = Class::Handle(Object::unwind_error_class()); | 7492 ASSERT(Object::unwind_error_class() != Class::null()); |
7494 UnwindError& result = UnwindError::Handle(); | 7493 UnwindError& result = UnwindError::Handle(); |
7495 { | 7494 { |
7496 RawObject* raw = Object::Allocate(cls, | 7495 RawObject* raw = Object::Allocate(UnwindError::kInstanceKind, |
7497 UnwindError::InstanceSize(), | 7496 UnwindError::InstanceSize(), |
7498 space); | 7497 space); |
7499 NoGCScope no_gc; | 7498 NoGCScope no_gc; |
7500 result ^= raw; | 7499 result ^= raw; |
7501 } | 7500 } |
7502 result.set_message(message); | 7501 result.set_message(message); |
7503 return result.raw(); | 7502 return result.raw(); |
7504 } | 7503 } |
7505 | 7504 |
7506 | 7505 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7710 const Class& cls = Class::Handle(clazz()); | 7709 const Class& cls = Class::Handle(clazz()); |
7711 return (index >= 0 && index < cls.num_native_fields()); | 7710 return (index >= 0 && index < cls.num_native_fields()); |
7712 } | 7711 } |
7713 | 7712 |
7714 | 7713 |
7715 RawInstance* Instance::New(const Class& cls, Heap::Space space) { | 7714 RawInstance* Instance::New(const Class& cls, Heap::Space space) { |
7716 Instance& result = Instance::Handle(); | 7715 Instance& result = Instance::Handle(); |
7717 { | 7716 { |
7718 intptr_t instance_size = cls.instance_size(); | 7717 intptr_t instance_size = cls.instance_size(); |
7719 ASSERT(instance_size > 0); | 7718 ASSERT(instance_size > 0); |
7720 RawObject* raw = Object::Allocate(cls, instance_size, space); | 7719 RawObject* raw = Object::Allocate(cls.id(), instance_size, space); |
7721 NoGCScope no_gc; | 7720 NoGCScope no_gc; |
7722 result ^= raw; | 7721 result ^= raw; |
7723 uword addr = reinterpret_cast<uword>(result.raw_ptr()); | 7722 uword addr = reinterpret_cast<uword>(result.raw_ptr()); |
7724 // Initialize fields. | 7723 // Initialize fields. |
7725 intptr_t offset = sizeof(RawObject); | 7724 intptr_t offset = sizeof(RawObject); |
7726 // Initialize all native fields to NULL. | 7725 // Initialize all native fields to NULL. |
7727 for (intptr_t i = 0; i < cls.num_native_fields(); i++) { | 7726 for (intptr_t i = 0; i < cls.num_native_fields(); i++) { |
7728 *reinterpret_cast<uword*>(addr + offset) = 0; | 7727 *reinterpret_cast<uword*>(addr + offset) = 0; |
7729 offset += kWordSize; | 7728 offset += kWordSize; |
7730 } | 7729 } |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7900 | 7899 |
7901 | 7900 |
7902 void Mint::set_value(int64_t value) const { | 7901 void Mint::set_value(int64_t value) const { |
7903 raw_ptr()->value_ = value; | 7902 raw_ptr()->value_ = value; |
7904 } | 7903 } |
7905 | 7904 |
7906 | 7905 |
7907 RawMint* Mint::New(int64_t val, Heap::Space space) { | 7906 RawMint* Mint::New(int64_t val, Heap::Space space) { |
7908 // Do not allocate a Mint if Smi would do. | 7907 // Do not allocate a Mint if Smi would do. |
7909 ASSERT(!Smi::IsValid64(val)); | 7908 ASSERT(!Smi::IsValid64(val)); |
7910 Isolate* isolate = Isolate::Current(); | 7909 ASSERT(Isolate::Current()->object_store()->mint_class() != Class::null()); |
7911 const Class& cls = | |
7912 Class::Handle(isolate->object_store()->mint_class()); | |
7913 Mint& result = Mint::Handle(); | 7910 Mint& result = Mint::Handle(); |
7914 { | 7911 { |
7915 RawObject* raw = Object::Allocate(cls, Mint::InstanceSize(), space); | 7912 RawObject* raw = Object::Allocate(Mint::kInstanceKind, |
7913 Mint::InstanceSize(), | |
7914 space); | |
7916 NoGCScope no_gc; | 7915 NoGCScope no_gc; |
7917 result ^= raw; | 7916 result ^= raw; |
7918 } | 7917 } |
7919 result.set_value(val); | 7918 result.set_value(val); |
7920 return result.raw(); | 7919 return result.raw(); |
7921 } | 7920 } |
7922 | 7921 |
7923 | 7922 |
7924 RawMint* Mint::NewCanonical(int64_t value) { | 7923 RawMint* Mint::NewCanonical(int64_t value) { |
7925 // Do not allocate a Mint if Smi would do. | 7924 // Do not allocate a Mint if Smi would do. |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8028 return true; // "===". | 8027 return true; // "===". |
8029 } | 8028 } |
8030 if (other.IsNull() || !other.IsDouble()) { | 8029 if (other.IsNull() || !other.IsDouble()) { |
8031 return false; | 8030 return false; |
8032 } | 8031 } |
8033 return EqualsToDouble(Double::Cast(other).value()); | 8032 return EqualsToDouble(Double::Cast(other).value()); |
8034 } | 8033 } |
8035 | 8034 |
8036 | 8035 |
8037 RawDouble* Double::New(double d, Heap::Space space) { | 8036 RawDouble* Double::New(double d, Heap::Space space) { |
8038 Isolate* isolate = Isolate::Current(); | 8037 ASSERT(Isolate::Current()->object_store()->double_class() != Class::null()); |
8039 const Class& cls = | |
8040 Class::Handle(isolate->object_store()->double_class()); | |
8041 Double& result = Double::Handle(); | 8038 Double& result = Double::Handle(); |
8042 { | 8039 { |
8043 RawObject* raw = Object::Allocate(cls, Double::InstanceSize(), space); | 8040 RawObject* raw = Object::Allocate(Double::kInstanceKind, |
8041 Double::InstanceSize(), | |
8042 space); | |
8044 NoGCScope no_gc; | 8043 NoGCScope no_gc; |
8045 result ^= raw; | 8044 result ^= raw; |
8046 } | 8045 } |
8047 result.set_value(d); | 8046 result.set_value(d); |
8048 return result.raw(); | 8047 return result.raw(); |
8049 } | 8048 } |
8050 | 8049 |
8051 | 8050 |
8052 static bool IsWhiteSpace(char ch) { | 8051 static bool IsWhiteSpace(char ch) { |
8053 return ch == '\0' || ch == '\n' || ch == '\r' || ch == ' ' || ch == '\t'; | 8052 return ch == '\0' || ch == '\n' || ch == '\r' || ch == ' ' || ch == '\t'; |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8189 } | 8188 } |
8190 if (this->IsNegative() == other.IsNegative()) { | 8189 if (this->IsNegative() == other.IsNegative()) { |
8191 return this->IsNegative() ? -1 : 1; | 8190 return this->IsNegative() ? -1 : 1; |
8192 } | 8191 } |
8193 return this->IsNegative() ? -1 : 1; | 8192 return this->IsNegative() ? -1 : 1; |
8194 } | 8193 } |
8195 | 8194 |
8196 | 8195 |
8197 RawBigint* Bigint::Allocate(intptr_t length, Heap::Space space) { | 8196 RawBigint* Bigint::Allocate(intptr_t length, Heap::Space space) { |
8198 ASSERT(length >= 0); | 8197 ASSERT(length >= 0); |
8199 Isolate* isolate = Isolate::Current(); | 8198 ASSERT(Isolate::Current()->object_store()->bigint_class() != Class::null()); |
8200 const Class& cls = Class::Handle(isolate->object_store()->bigint_class()); | |
8201 Bigint& result = Bigint::Handle(); | 8199 Bigint& result = Bigint::Handle(); |
8202 { | 8200 { |
8203 RawObject* raw = Object::Allocate(cls, Bigint::InstanceSize(length), space); | 8201 RawObject* raw = Object::Allocate(Bigint::kInstanceKind, |
8202 Bigint::InstanceSize(length), | |
8203 space); | |
8204 NoGCScope no_gc; | 8204 NoGCScope no_gc; |
8205 result ^= raw; | 8205 result ^= raw; |
8206 result.raw_ptr()->allocated_length_ = length; // Chunk length allocated. | 8206 result.raw_ptr()->allocated_length_ = length; // Chunk length allocated. |
8207 result.raw_ptr()->signed_length_ = length; // Chunk length in use. | 8207 result.raw_ptr()->signed_length_ = length; // Chunk length in use. |
8208 } | 8208 } |
8209 return result.raw(); | 8209 return result.raw(); |
8210 } | 8210 } |
8211 | 8211 |
8212 | 8212 |
8213 static uword ZoneAllocator(intptr_t size) { | 8213 static uword ZoneAllocator(intptr_t size) { |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8419 } | 8419 } |
8420 } | 8420 } |
8421 return true; | 8421 return true; |
8422 } | 8422 } |
8423 | 8423 |
8424 | 8424 |
8425 RawInstance* String::Canonicalize() const { | 8425 RawInstance* String::Canonicalize() const { |
8426 if (IsCanonical()) { | 8426 if (IsCanonical()) { |
8427 return this->raw(); | 8427 return this->raw(); |
8428 } | 8428 } |
8429 return NewSymbol(*this); | 8429 return Symbols::New(*this); |
8430 } | 8430 } |
8431 | 8431 |
8432 | 8432 |
8433 RawString* String::New(const char* str, Heap::Space space) { | 8433 RawString* String::New(const char* str, Heap::Space space) { |
8434 intptr_t width = 0; | 8434 intptr_t width = 0; |
8435 intptr_t len = Utf8::CodePointCount(str, &width); | 8435 intptr_t len = Utf8::CodePointCount(str, &width); |
8436 if (width == 1) { | 8436 if (width == 1) { |
8437 const OneByteString& onestr | 8437 const OneByteString& onestr |
8438 = OneByteString::Handle(OneByteString::New(len, space)); | 8438 = OneByteString::Handle(OneByteString::New(len, space)); |
8439 if (len > 0) { | 8439 if (len > 0) { |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8700 if (str.IsTwoByteString()) { | 8700 if (str.IsTwoByteString()) { |
8701 const TwoByteString& twostr = TwoByteString::Cast(str); | 8701 const TwoByteString& twostr = TwoByteString::Cast(str); |
8702 return twostr.EscapeDoubleQuotes(); | 8702 return twostr.EscapeDoubleQuotes(); |
8703 } | 8703 } |
8704 ASSERT(str.IsFourByteString()); | 8704 ASSERT(str.IsFourByteString()); |
8705 const FourByteString& fourstr = FourByteString::Cast(str); | 8705 const FourByteString& fourstr = FourByteString::Cast(str); |
8706 return fourstr.EscapeDoubleQuotes(); | 8706 return fourstr.EscapeDoubleQuotes(); |
8707 } | 8707 } |
8708 | 8708 |
8709 | 8709 |
8710 static void GrowSymbolTable(const Array& symbol_table, intptr_t table_size) { | |
8711 // TODO(iposva): Avoid exponential growth. | |
8712 intptr_t new_table_size = table_size * 2; | |
8713 Array& new_symbol_table = Array::Handle(Array::New(new_table_size + 1)); | |
8714 // Copy all elements from the original symbol table to the newly allocated | |
8715 // array. | |
8716 String& element = String::Handle(); | |
8717 Object& new_element = Object::Handle(); | |
8718 for (intptr_t i = 0; i < table_size; i++) { | |
8719 element ^= symbol_table.At(i); | |
8720 if (!element.IsNull()) { | |
8721 intptr_t hash = element.Hash(); | |
8722 intptr_t index = hash % new_table_size; | |
8723 new_element = new_symbol_table.At(index); | |
8724 while (!new_element.IsNull()) { | |
8725 index = (index + 1) % new_table_size; // Move to next element. | |
8726 new_element = new_symbol_table.At(index); | |
8727 } | |
8728 new_symbol_table.SetAt(index, element); | |
8729 } | |
8730 } | |
8731 // Copy used count. | |
8732 new_element = symbol_table.At(table_size); | |
8733 new_symbol_table.SetAt(new_table_size, new_element); | |
8734 // Remember the new symbol table now. | |
8735 Isolate::Current()->object_store()->set_symbol_table(new_symbol_table); | |
8736 } | |
8737 | |
8738 | |
8739 static void InsertIntoSymbolTable(const Array& symbol_table, | |
8740 const String& symbol, | |
8741 intptr_t index, | |
8742 intptr_t table_size) { | |
8743 symbol.SetCanonical(); // Mark object as being canonical. | |
8744 symbol_table.SetAt(index, symbol); // Remember the new symbol. | |
8745 Smi& used = Smi::Handle(); | |
8746 used ^= symbol_table.At(table_size); | |
8747 intptr_t used_elements = used.Value() + 1; // One more element added. | |
8748 used = Smi::New(used_elements); | |
8749 symbol_table.SetAt(table_size, used); // Update used count. | |
8750 | |
8751 // Rehash if symbol_table is 75% full. | |
8752 if (used_elements > ((table_size / 4) * 3)) { | |
8753 GrowSymbolTable(symbol_table, table_size); | |
8754 } | |
8755 } | |
8756 | |
8757 | |
8758 RawString* String::NewSymbol(const char* str) { | |
8759 intptr_t width = 0; | |
8760 intptr_t len = Utf8::CodePointCount(str, &width); | |
8761 intptr_t size = len * width; | |
8762 Zone* zone = Isolate::Current()->current_zone(); | |
8763 if (len == 0) { | |
8764 return String::NewSymbol(reinterpret_cast<uint8_t*>(NULL), 0); | |
8765 } else if (width == 1) { | |
8766 uint8_t* characters = reinterpret_cast<uint8_t*>(zone->Allocate(size)); | |
8767 Utf8::Decode(str, characters, len); | |
8768 return NewSymbol(characters, len); | |
8769 } else if (width == 2) { | |
8770 uint16_t* characters = reinterpret_cast<uint16_t*>(zone->Allocate(size)); | |
8771 Utf8::Decode(str, characters, len); | |
8772 return NewSymbol(characters, len); | |
8773 } | |
8774 ASSERT(width == 4); | |
8775 uint32_t* characters = reinterpret_cast<uint32_t*>(zone->Allocate(size)); | |
8776 Utf8::Decode(str, characters, len); | |
8777 return NewSymbol(characters, len); | |
8778 } | |
8779 | |
8780 | |
8781 template<typename T> | |
8782 RawString* String::NewSymbol(const T* characters, intptr_t len) { | |
8783 Isolate* isolate = Isolate::Current(); | |
8784 | |
8785 // Calculate the String hash for this sequence of characters. | |
8786 intptr_t hash = Hash(characters, len); | |
8787 | |
8788 const Array& symbol_table = | |
8789 Array::Handle(isolate, isolate->object_store()->symbol_table()); | |
8790 // Last element of the array is the number of used elements. | |
8791 intptr_t table_size = symbol_table.Length() - 1; | |
8792 intptr_t index = hash % table_size; | |
8793 | |
8794 String& symbol = String::Handle(isolate, String::null()); | |
8795 symbol ^= symbol_table.At(index); | |
8796 while (!symbol.IsNull() && !symbol.Equals(characters, len)) { | |
8797 index = (index + 1) % table_size; // Move to next element. | |
8798 symbol ^= symbol_table.At(index); | |
8799 } | |
8800 // Since we leave enough room in the table to guarantee, that we find an | |
8801 // empty spot, index is the insertion point if symbol is null. | |
8802 if (symbol.IsNull()) { | |
8803 // Allocate new result string. | |
8804 symbol = String::New(characters, len, Heap::kOld); | |
8805 symbol.SetHash(hash); // Remember the calculated hash value. | |
8806 InsertIntoSymbolTable(symbol_table, symbol, index, table_size); | |
8807 } | |
8808 ASSERT(symbol.IsSymbol()); | |
8809 return symbol.raw(); | |
8810 } | |
8811 | |
8812 template RawString* String::NewSymbol(const uint8_t* characters, intptr_t len); | |
8813 template RawString* String::NewSymbol(const uint16_t* characters, intptr_t len); | |
8814 template RawString* String::NewSymbol(const uint32_t* characters, intptr_t len); | |
8815 | |
8816 | |
8817 RawString* String::NewSymbol(const String& str) { | |
8818 if (str.IsSymbol()) { | |
8819 return str.raw(); | |
8820 } | |
8821 return NewSymbol(str, 0, str.Length()); | |
8822 } | |
8823 | |
8824 | |
8825 RawString* String::NewSymbol(const String& str, | |
8826 intptr_t begin_index, | |
8827 intptr_t len) { | |
8828 ASSERT(begin_index >= 0); | |
8829 ASSERT(len >= 0); | |
8830 ASSERT((begin_index + len) <= str.Length()); | |
8831 Isolate* isolate = Isolate::Current(); | |
8832 | |
8833 // Calculate the String hash for this sequence of characters. | |
8834 intptr_t hash = String::Hash(str, begin_index, len); | |
8835 | |
8836 const Array& symbol_table = | |
8837 Array::Handle(isolate, isolate->object_store()->symbol_table()); | |
8838 // Last element of the array is the number of used elements. | |
8839 intptr_t table_size = symbol_table.Length() - 1; | |
8840 intptr_t index = hash % table_size; | |
8841 | |
8842 String& symbol = String::Handle(isolate, String::null()); | |
8843 symbol ^= symbol_table.At(index); | |
8844 while (!symbol.IsNull() && !symbol.Equals(str, begin_index, len)) { | |
8845 index = (index + 1) % table_size; // Move to next element. | |
8846 symbol ^= symbol_table.At(index); | |
8847 } | |
8848 // Since we leave enough room in the table to guarantee, that we find an | |
8849 // empty spot, index is the insertion point if symbol is null. | |
8850 if (symbol.IsNull()) { | |
8851 if (str.IsOld() && begin_index == 0 && len == str.Length()) { | |
8852 // Reuse the incoming str as the symbol value. | |
8853 symbol = str.raw(); | |
8854 } else { | |
8855 // Allocate a copy in old space. | |
8856 symbol = String::SubString(str, begin_index, len, Heap::kOld); | |
8857 } | |
8858 symbol.SetHash(hash); | |
8859 InsertIntoSymbolTable(symbol_table, symbol, index, table_size); | |
8860 } | |
8861 ASSERT(symbol.IsSymbol()); | |
8862 return symbol.raw(); | |
8863 } | |
8864 | |
8865 | |
8866 RawString* String::NewFormatted(const char* format, ...) { | 8710 RawString* String::NewFormatted(const char* format, ...) { |
8867 va_list args; | 8711 va_list args; |
8868 va_start(args, format); | 8712 va_start(args, format); |
8869 intptr_t len = OS::VSNPrint(NULL, 0, format, args); | 8713 intptr_t len = OS::VSNPrint(NULL, 0, format, args); |
8870 va_end(args); | 8714 va_end(args); |
8871 | 8715 |
8872 Zone* zone = Isolate::Current()->current_zone(); | 8716 Zone* zone = Isolate::Current()->current_zone(); |
8873 char* buffer = reinterpret_cast<char*>(zone->Allocate(len + 1)); | 8717 char* buffer = reinterpret_cast<char*>(zone->Allocate(len + 1)); |
8874 va_list args2; | 8718 va_list args2; |
8875 va_start(args2, format); | 8719 va_start(args2, format); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9101 } | 8945 } |
9102 | 8946 |
9103 // We have reached the end of mangled_name string. | 8947 // We have reached the end of mangled_name string. |
9104 ASSERT(pos == len); | 8948 ASSERT(pos == len); |
9105 return (name_pos == name_len); | 8949 return (name_pos == name_len); |
9106 } | 8950 } |
9107 | 8951 |
9108 | 8952 |
9109 RawOneByteString* OneByteString::New(intptr_t len, | 8953 RawOneByteString* OneByteString::New(intptr_t len, |
9110 Heap::Space space) { | 8954 Heap::Space space) { |
9111 Isolate* isolate = Isolate::Current(); | 8955 ASSERT(Isolate::Current() == Dart::vm_isolate() || |
9112 | 8956 Isolate::Current()->object_store()->one_byte_string_class() != |
9113 const Class& cls = | 8957 Class::null()); |
9114 Class::Handle(isolate->object_store()->one_byte_string_class()); | |
9115 OneByteString& result = OneByteString::Handle(); | 8958 OneByteString& result = OneByteString::Handle(); |
9116 { | 8959 { |
9117 RawObject* raw = Object::Allocate(cls, | 8960 RawObject* raw = Object::Allocate(OneByteString::kInstanceKind, |
9118 OneByteString::InstanceSize(len), | 8961 OneByteString::InstanceSize(len), |
9119 space); | 8962 space); |
9120 NoGCScope no_gc; | 8963 NoGCScope no_gc; |
9121 result ^= raw; | 8964 result ^= raw; |
9122 result.SetLength(len); | 8965 result.SetLength(len); |
9123 result.SetHash(0); | 8966 result.SetHash(0); |
9124 } | 8967 } |
9125 return result.raw(); | 8968 return result.raw(); |
9126 } | 8969 } |
9127 | 8970 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9242 } | 9085 } |
9243 } | 9086 } |
9244 return dststr.raw(); | 9087 return dststr.raw(); |
9245 } | 9088 } |
9246 return TwoByteString::null(); | 9089 return TwoByteString::null(); |
9247 } | 9090 } |
9248 | 9091 |
9249 | 9092 |
9250 RawTwoByteString* TwoByteString::New(intptr_t len, | 9093 RawTwoByteString* TwoByteString::New(intptr_t len, |
9251 Heap::Space space) { | 9094 Heap::Space space) { |
9252 Isolate* isolate = Isolate::Current(); | 9095 ASSERT(Isolate::Current()->object_store()->two_byte_string_class()); |
9253 | |
9254 const Class& cls = | |
9255 Class::Handle(isolate->object_store()->two_byte_string_class()); | |
9256 TwoByteString& result = TwoByteString::Handle(); | 9096 TwoByteString& result = TwoByteString::Handle(); |
9257 { | 9097 { |
9258 RawObject* raw = Object::Allocate(cls, | 9098 RawObject* raw = Object::Allocate(TwoByteString::kInstanceKind, |
9259 TwoByteString::InstanceSize(len), | 9099 TwoByteString::InstanceSize(len), |
9260 space); | 9100 space); |
9261 NoGCScope no_gc; | 9101 NoGCScope no_gc; |
9262 result ^= raw; | 9102 result ^= raw; |
9263 result.SetLength(len); | 9103 result.SetLength(len); |
9264 result.SetHash(0); | 9104 result.SetHash(0); |
9265 } | 9105 } |
9266 return result.raw(); | 9106 return result.raw(); |
9267 } | 9107 } |
9268 | 9108 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9373 } | 9213 } |
9374 } | 9214 } |
9375 return dststr.raw(); | 9215 return dststr.raw(); |
9376 } | 9216 } |
9377 return FourByteString::null(); | 9217 return FourByteString::null(); |
9378 } | 9218 } |
9379 | 9219 |
9380 | 9220 |
9381 RawFourByteString* FourByteString::New(intptr_t len, | 9221 RawFourByteString* FourByteString::New(intptr_t len, |
9382 Heap::Space space) { | 9222 Heap::Space space) { |
9383 Isolate* isolate = Isolate::Current(); | 9223 ASSERT(Isolate::Current()->object_store()->four_byte_string_class() != |
9384 | 9224 Class::null()); |
9385 const Class& cls = | |
9386 Class::Handle(isolate->object_store()->four_byte_string_class()); | |
9387 FourByteString& result = FourByteString::Handle(); | 9225 FourByteString& result = FourByteString::Handle(); |
9388 { | 9226 { |
9389 RawObject* raw = Object::Allocate(cls, | 9227 RawObject* raw = Object::Allocate(FourByteString::kInstanceKind, |
9390 FourByteString::InstanceSize(len), | 9228 FourByteString::InstanceSize(len), |
9391 space); | 9229 space); |
9392 NoGCScope no_gc; | 9230 NoGCScope no_gc; |
9393 result ^= raw; | 9231 result ^= raw; |
9394 result.SetLength(len); | 9232 result.SetLength(len); |
9395 result.SetHash(0); | 9233 result.SetHash(0); |
9396 } | 9234 } |
9397 return result.raw(); | 9235 return result.raw(); |
9398 } | 9236 } |
9399 | 9237 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9482 weak_ref->set_callback(callback); | 9320 weak_ref->set_callback(callback); |
9483 } | 9321 } |
9484 | 9322 |
9485 | 9323 |
9486 RawExternalOneByteString* ExternalOneByteString::New( | 9324 RawExternalOneByteString* ExternalOneByteString::New( |
9487 const uint8_t* data, | 9325 const uint8_t* data, |
9488 intptr_t len, | 9326 intptr_t len, |
9489 void* peer, | 9327 void* peer, |
9490 Dart_PeerFinalizer callback, | 9328 Dart_PeerFinalizer callback, |
9491 Heap::Space space) { | 9329 Heap::Space space) { |
9492 Isolate* isolate = Isolate::Current(); | 9330 ASSERT(Isolate::Current()->object_store()->external_one_byte_string_class() != |
9493 | 9331 Class::null()); |
9494 const Class& cls = | |
9495 Class::Handle(isolate->object_store()->external_one_byte_string_class()); | |
9496 ExternalOneByteString& result = ExternalOneByteString::Handle(); | 9332 ExternalOneByteString& result = ExternalOneByteString::Handle(); |
9497 ExternalStringData<uint8_t>* external_data = | 9333 ExternalStringData<uint8_t>* external_data = |
9498 new ExternalStringData<uint8_t>(data, peer, callback); | 9334 new ExternalStringData<uint8_t>(data, peer, callback); |
9499 { | 9335 { |
9500 RawObject* raw = Object::Allocate(cls, | 9336 RawObject* raw = Object::Allocate(ExternalOneByteString::kInstanceKind, |
9501 ExternalOneByteString::InstanceSize(), | 9337 ExternalOneByteString::InstanceSize(), |
9502 space); | 9338 space); |
9503 NoGCScope no_gc; | 9339 NoGCScope no_gc; |
9504 result ^= raw; | 9340 result ^= raw; |
9505 result.SetLength(len); | 9341 result.SetLength(len); |
9506 result.SetHash(0); | 9342 result.SetHash(0); |
9507 result.SetExternalData(external_data); | 9343 result.SetExternalData(external_data); |
9508 } | 9344 } |
9509 AddFinalizer(result, external_data, ExternalOneByteString::Finalize); | 9345 AddFinalizer(result, external_data, ExternalOneByteString::Finalize); |
9510 return result.raw(); | 9346 return result.raw(); |
(...skipping 20 matching lines...) Expand all Loading... | |
9531 return String::ToCString(); | 9367 return String::ToCString(); |
9532 } | 9368 } |
9533 | 9369 |
9534 | 9370 |
9535 RawExternalTwoByteString* ExternalTwoByteString::New( | 9371 RawExternalTwoByteString* ExternalTwoByteString::New( |
9536 const uint16_t* data, | 9372 const uint16_t* data, |
9537 intptr_t len, | 9373 intptr_t len, |
9538 void* peer, | 9374 void* peer, |
9539 Dart_PeerFinalizer callback, | 9375 Dart_PeerFinalizer callback, |
9540 Heap::Space space) { | 9376 Heap::Space space) { |
9541 Isolate* isolate = Isolate::Current(); | 9377 ASSERT(Isolate::Current()->object_store()->external_two_byte_string_class() != |
9542 | 9378 Class::null()); |
9543 const Class& cls = | |
9544 Class::Handle(isolate->object_store()->external_two_byte_string_class()); | |
9545 ExternalTwoByteString& result = ExternalTwoByteString::Handle(); | 9379 ExternalTwoByteString& result = ExternalTwoByteString::Handle(); |
9546 ExternalStringData<uint16_t>* external_data = | 9380 ExternalStringData<uint16_t>* external_data = |
9547 new ExternalStringData<uint16_t>(data, peer, callback); | 9381 new ExternalStringData<uint16_t>(data, peer, callback); |
9548 { | 9382 { |
9549 RawObject* raw = Object::Allocate(cls, | 9383 RawObject* raw = Object::Allocate(ExternalTwoByteString::kInstanceKind, |
9550 ExternalTwoByteString::InstanceSize(), | 9384 ExternalTwoByteString::InstanceSize(), |
9551 space); | 9385 space); |
9552 NoGCScope no_gc; | 9386 NoGCScope no_gc; |
9553 result ^= raw; | 9387 result ^= raw; |
9554 result.SetLength(len); | 9388 result.SetLength(len); |
9555 result.SetHash(0); | 9389 result.SetHash(0); |
9556 result.SetExternalData(external_data); | 9390 result.SetExternalData(external_data); |
9557 } | 9391 } |
9558 AddFinalizer(result, external_data, ExternalTwoByteString::Finalize); | 9392 AddFinalizer(result, external_data, ExternalTwoByteString::Finalize); |
9559 return result.raw(); | 9393 return result.raw(); |
(...skipping 10 matching lines...) Expand all Loading... | |
9570 return String::ToCString(); | 9404 return String::ToCString(); |
9571 } | 9405 } |
9572 | 9406 |
9573 | 9407 |
9574 RawExternalFourByteString* ExternalFourByteString::New( | 9408 RawExternalFourByteString* ExternalFourByteString::New( |
9575 const uint32_t* data, | 9409 const uint32_t* data, |
9576 intptr_t len, | 9410 intptr_t len, |
9577 void* peer, | 9411 void* peer, |
9578 Dart_PeerFinalizer callback, | 9412 Dart_PeerFinalizer callback, |
9579 Heap::Space space) { | 9413 Heap::Space space) { |
9580 Isolate* isolate = Isolate::Current(); | 9414 ASSERT(Isolate::Current()->object_store()-> |
9581 | 9415 external_four_byte_string_class() != Class::null()); |
9582 const Class& cls = | |
9583 Class::Handle(isolate->object_store()->external_four_byte_string_class()); | |
9584 ExternalFourByteString& result = ExternalFourByteString::Handle(); | 9416 ExternalFourByteString& result = ExternalFourByteString::Handle(); |
9585 ExternalStringData<uint32_t>* external_data = | 9417 ExternalStringData<uint32_t>* external_data = |
9586 new ExternalStringData<uint32_t>(data, peer, callback); | 9418 new ExternalStringData<uint32_t>(data, peer, callback); |
9587 { | 9419 { |
9588 RawObject* raw = Object::Allocate(cls, | 9420 RawObject* raw = Object::Allocate(ExternalFourByteString::kInstanceKind, |
9589 ExternalFourByteString::InstanceSize(), | 9421 ExternalFourByteString::InstanceSize(), |
9590 space); | 9422 space); |
9591 NoGCScope no_gc; | 9423 NoGCScope no_gc; |
9592 result ^= raw; | 9424 result ^= raw; |
9593 result.SetLength(len); | 9425 result.SetLength(len); |
9594 result.SetHash(0); | 9426 result.SetHash(0); |
9595 result.SetExternalData(external_data); | 9427 result.SetExternalData(external_data); |
9596 } | 9428 } |
9597 AddFinalizer(result, external_data, ExternalFourByteString::Finalize); | 9429 AddFinalizer(result, external_data, ExternalFourByteString::Finalize); |
9598 return result.raw(); | 9430 return result.raw(); |
(...skipping 15 matching lines...) Expand all Loading... | |
9614 return Isolate::Current()->object_store()->true_value(); | 9446 return Isolate::Current()->object_store()->true_value(); |
9615 } | 9447 } |
9616 | 9448 |
9617 | 9449 |
9618 RawBool* Bool::False() { | 9450 RawBool* Bool::False() { |
9619 return Isolate::Current()->object_store()->false_value(); | 9451 return Isolate::Current()->object_store()->false_value(); |
9620 } | 9452 } |
9621 | 9453 |
9622 | 9454 |
9623 RawBool* Bool::New(bool value) { | 9455 RawBool* Bool::New(bool value) { |
9624 Isolate* isolate = Isolate::Current(); | 9456 ASSERT(Isolate::Current()->object_store()->bool_class() != Class::null()); |
9625 | |
9626 const Class& cls = Class::Handle(isolate->object_store()->bool_class()); | |
9627 Bool& result = Bool::Handle(); | 9457 Bool& result = Bool::Handle(); |
9628 { | 9458 { |
9629 // Since the two boolean instances are singletons we allocate them straight | 9459 // Since the two boolean instances are singletons we allocate them straight |
9630 // in the old generation. | 9460 // in the old generation. |
9631 RawObject* raw = Object::Allocate(cls, Bool::InstanceSize(), Heap::kOld); | 9461 RawObject* raw = Object::Allocate(Bool::kInstanceKind, |
9462 Bool::InstanceSize(), | |
9463 Heap::kOld); | |
9632 NoGCScope no_gc; | 9464 NoGCScope no_gc; |
9633 result ^= raw; | 9465 result ^= raw; |
9634 } | 9466 } |
9635 result.set_value(value); | 9467 result.set_value(value); |
9636 return result.raw(); | 9468 return result.raw(); |
9637 } | 9469 } |
9638 | 9470 |
9639 | 9471 |
9640 const char* Bool::ToCString() const { | 9472 const char* Bool::ToCString() const { |
9641 return value() ? "true" : "false"; | 9473 return value() ? "true" : "false"; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9684 | 9516 |
9685 RawArray* Array::New(const Class& cls, intptr_t len, Heap::Space space) { | 9517 RawArray* Array::New(const Class& cls, intptr_t len, Heap::Space space) { |
9686 if ((len < 0) || (len > kMaxArrayElements)) { | 9518 if ((len < 0) || (len > kMaxArrayElements)) { |
9687 // TODO(srdjan): Verify that illegal argument is the right thing to throw. | 9519 // TODO(srdjan): Verify that illegal argument is the right thing to throw. |
9688 GrowableArray<const Object*> args; | 9520 GrowableArray<const Object*> args; |
9689 args.Add(&Smi::Handle(Smi::New(len))); | 9521 args.Add(&Smi::Handle(Smi::New(len))); |
9690 Exceptions::ThrowByType(Exceptions::kIllegalArgument, args); | 9522 Exceptions::ThrowByType(Exceptions::kIllegalArgument, args); |
9691 } | 9523 } |
9692 Array& result = Array::Handle(); | 9524 Array& result = Array::Handle(); |
9693 { | 9525 { |
9694 RawObject* raw = Object::Allocate(cls, | 9526 RawObject* raw = Object::Allocate(cls.id(), |
9695 Array::InstanceSize(len), | 9527 Array::InstanceSize(len), |
9696 space); | 9528 space); |
9697 NoGCScope no_gc; | 9529 NoGCScope no_gc; |
9698 result ^= raw; | 9530 result ^= raw; |
9699 result.SetLength(len); | 9531 result.SetLength(len); |
9700 } | 9532 } |
9701 return result.raw(); | 9533 return result.raw(); |
9702 } | 9534 } |
9703 | 9535 |
9704 | 9536 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9901 | 9733 |
9902 RawGrowableObjectArray* GrowableObjectArray::New(intptr_t capacity, | 9734 RawGrowableObjectArray* GrowableObjectArray::New(intptr_t capacity, |
9903 Heap::Space space) { | 9735 Heap::Space space) { |
9904 const Array& data = Array::Handle(Array::New(capacity, space)); | 9736 const Array& data = Array::Handle(Array::New(capacity, space)); |
9905 return New(data, space); | 9737 return New(data, space); |
9906 } | 9738 } |
9907 | 9739 |
9908 | 9740 |
9909 RawGrowableObjectArray* GrowableObjectArray::New(const Array& array, | 9741 RawGrowableObjectArray* GrowableObjectArray::New(const Array& array, |
9910 Heap::Space space) { | 9742 Heap::Space space) { |
9911 ObjectStore* object_store = Isolate::Current()->object_store(); | 9743 ASSERT(Isolate::Current()->object_store()->growable_object_array_class() |
9912 Class& cls = Class::Handle(object_store->growable_object_array_class()); | 9744 != Class::null()); |
9913 GrowableObjectArray& result = GrowableObjectArray::Handle(); | 9745 GrowableObjectArray& result = GrowableObjectArray::Handle(); |
9914 { | 9746 { |
9915 RawObject* raw = Object::Allocate(cls, | 9747 RawObject* raw = Object::Allocate(GrowableObjectArray::kInstanceKind, |
9916 GrowableObjectArray::InstanceSize(), | 9748 GrowableObjectArray::InstanceSize(), |
9917 space); | 9749 space); |
9918 NoGCScope no_gc; | 9750 NoGCScope no_gc; |
9919 result ^= raw; | 9751 result ^= raw; |
9920 result.SetLength(0); | 9752 result.SetLength(0); |
9921 result.SetData(array); | 9753 result.SetData(array); |
9922 } | 9754 } |
9923 return result.raw(); | 9755 return result.raw(); |
9924 } | 9756 } |
9925 | 9757 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9984 RawT* ByteArray::NewExternalImpl(const Class& cls, | 9816 RawT* ByteArray::NewExternalImpl(const Class& cls, |
9985 ElementT* data, | 9817 ElementT* data, |
9986 intptr_t len, | 9818 intptr_t len, |
9987 void* peer, | 9819 void* peer, |
9988 Dart_PeerFinalizer callback, | 9820 Dart_PeerFinalizer callback, |
9989 Heap::Space space) { | 9821 Heap::Space space) { |
9990 HandleT& result = HandleT::Handle(); | 9822 HandleT& result = HandleT::Handle(); |
9991 ExternalByteArrayData<ElementT>* external_data = | 9823 ExternalByteArrayData<ElementT>* external_data = |
9992 new ExternalByteArrayData<ElementT>(data, peer, callback); | 9824 new ExternalByteArrayData<ElementT>(data, peer, callback); |
9993 { | 9825 { |
9994 RawObject* raw = Object::Allocate(cls, HandleT::InstanceSize(), space); | 9826 RawObject* raw = Object::Allocate(cls.id(), HandleT::InstanceSize(), space); |
9995 NoGCScope no_gc; | 9827 NoGCScope no_gc; |
9996 result ^= raw; | 9828 result ^= raw; |
9997 result.SetLength(len); | 9829 result.SetLength(len); |
9998 result.SetExternalData(external_data); | 9830 result.SetExternalData(external_data); |
9999 } | 9831 } |
10000 AddFinalizer(result, external_data, ExternalByteArrayFinalize<ElementT>); | 9832 AddFinalizer(result, external_data, ExternalByteArrayFinalize<ElementT>); |
10001 return result.raw(); | 9833 return result.raw(); |
10002 } | 9834 } |
10003 | 9835 |
10004 | 9836 |
(...skipping 15 matching lines...) Expand all Loading... | |
10020 // ByteArray is an abstract class. | 9852 // ByteArray is an abstract class. |
10021 UNREACHABLE(); | 9853 UNREACHABLE(); |
10022 return "ByteArray"; | 9854 return "ByteArray"; |
10023 } | 9855 } |
10024 | 9856 |
10025 | 9857 |
10026 template<typename HandleT, typename RawT> | 9858 template<typename HandleT, typename RawT> |
10027 RawT* ByteArray::NewImpl(const Class& cls, intptr_t len, Heap::Space space) { | 9859 RawT* ByteArray::NewImpl(const Class& cls, intptr_t len, Heap::Space space) { |
10028 HandleT& result = HandleT::Handle(); | 9860 HandleT& result = HandleT::Handle(); |
10029 { | 9861 { |
10030 RawObject* raw = Object::Allocate(cls, HandleT::InstanceSize(len), space); | 9862 RawObject* raw = Object::Allocate(cls.id(), |
9863 HandleT::InstanceSize(len), | |
9864 space); | |
10031 NoGCScope no_gc; | 9865 NoGCScope no_gc; |
10032 result ^= raw; | 9866 result ^= raw; |
10033 result.SetLength(len); | 9867 result.SetLength(len); |
10034 if (len > 0) { | 9868 if (len > 0) { |
10035 memset(result.ByteAddr(0), 0, result.ByteLength()); | 9869 memset(result.ByteAddr(0), 0, result.ByteLength()); |
10036 } | 9870 } |
10037 } | 9871 } |
10038 return result.raw(); | 9872 return result.raw(); |
10039 } | 9873 } |
10040 | 9874 |
10041 | 9875 |
10042 template<typename HandleT, typename RawT, typename ElementT> | 9876 template<typename HandleT, typename RawT, typename ElementT> |
10043 RawT* ByteArray::NewImpl(const Class& cls, | 9877 RawT* ByteArray::NewImpl(const Class& cls, |
10044 const ElementT* data, | 9878 const ElementT* data, |
10045 intptr_t len, | 9879 intptr_t len, |
10046 Heap::Space space) { | 9880 Heap::Space space) { |
10047 HandleT& result = HandleT::Handle(); | 9881 HandleT& result = HandleT::Handle(); |
10048 { | 9882 { |
10049 RawObject* raw = Object::Allocate(cls, HandleT::InstanceSize(len), space); | 9883 RawObject* raw = Object::Allocate(cls.id(), |
9884 HandleT::InstanceSize(len), | |
9885 space); | |
10050 NoGCScope no_gc; | 9886 NoGCScope no_gc; |
10051 result ^= raw; | 9887 result ^= raw; |
10052 result.SetLength(len); | 9888 result.SetLength(len); |
10053 if (len > 0) { | 9889 if (len > 0) { |
10054 memmove(result.ByteAddr(0), data, result.ByteLength()); | 9890 memmove(result.ByteAddr(0), data, result.ByteLength()); |
10055 } | 9891 } |
10056 } | 9892 } |
10057 return result.raw(); | 9893 return result.raw(); |
10058 } | 9894 } |
10059 | 9895 |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10471 | 10307 |
10472 RawClosure* Closure::New(const Function& function, | 10308 RawClosure* Closure::New(const Function& function, |
10473 const Context& context, | 10309 const Context& context, |
10474 Heap::Space space) { | 10310 Heap::Space space) { |
10475 Isolate* isolate = Isolate::Current(); | 10311 Isolate* isolate = Isolate::Current(); |
10476 ASSERT(context.isolate() == isolate); | 10312 ASSERT(context.isolate() == isolate); |
10477 | 10313 |
10478 const Class& cls = Class::Handle(function.signature_class()); | 10314 const Class& cls = Class::Handle(function.signature_class()); |
10479 Closure& result = Closure::Handle(); | 10315 Closure& result = Closure::Handle(); |
10480 { | 10316 { |
10481 RawObject* raw = Object::Allocate(cls, Closure::InstanceSize(), space); | 10317 RawObject* raw = Object::Allocate(cls.id(), Closure::InstanceSize(), space); |
10482 NoGCScope no_gc; | 10318 NoGCScope no_gc; |
10483 result ^= raw; | 10319 result ^= raw; |
10484 } | 10320 } |
10485 result.set_function(function); | 10321 result.set_function(function); |
10486 result.set_context(context); | 10322 result.set_context(context); |
10487 return result.raw(); | 10323 return result.raw(); |
10488 } | 10324 } |
10489 | 10325 |
10490 | 10326 |
10491 void Closure::set_context(const Context& value) const { | 10327 void Closure::set_context(const Context& value) const { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10569 function_array.SetAt((index + i), function); | 10405 function_array.SetAt((index + i), function); |
10570 code_array.SetAt((index + i), code); | 10406 code_array.SetAt((index + i), code); |
10571 pc_offset = Smi::New(frame_pcs[i] - code.EntryPoint()); | 10407 pc_offset = Smi::New(frame_pcs[i] - code.EntryPoint()); |
10572 pc_offset_array.SetAt((index + i), pc_offset); | 10408 pc_offset_array.SetAt((index + i), pc_offset); |
10573 } | 10409 } |
10574 } | 10410 } |
10575 | 10411 |
10576 | 10412 |
10577 RawStacktrace* Stacktrace::New(const GrowableArray<uword>& stack_frame_pcs, | 10413 RawStacktrace* Stacktrace::New(const GrowableArray<uword>& stack_frame_pcs, |
10578 Heap::Space space) { | 10414 Heap::Space space) { |
10579 const Class& cls = Class::Handle( | 10415 ASSERT(Isolate::Current()->object_store()->stacktrace_class() != |
10580 Isolate::Current()->object_store()->stacktrace_class()); | 10416 Class::null()); |
10581 Stacktrace& result = Stacktrace::Handle(); | 10417 Stacktrace& result = Stacktrace::Handle(); |
10582 { | 10418 { |
10583 RawObject* raw = Object::Allocate(cls, | 10419 RawObject* raw = Object::Allocate(Stacktrace::kInstanceKind, |
10584 Stacktrace::InstanceSize(), | 10420 Stacktrace::InstanceSize(), |
10585 space); | 10421 space); |
10586 NoGCScope no_gc; | 10422 NoGCScope no_gc; |
10587 result ^= raw; | 10423 result ^= raw; |
10588 } | 10424 } |
10589 intptr_t length = stack_frame_pcs.length(); | 10425 intptr_t length = stack_frame_pcs.length(); |
10590 // Create arrays for the function, code and pc_offset triplet for each frame. | 10426 // Create arrays for the function, code and pc_offset triplet for each frame. |
10591 const Array& function_array = Array::Handle(Array::New(length)); | 10427 const Array& function_array = Array::Handle(Array::New(length)); |
10592 const Array& code_array = Array::Handle(Array::New(length)); | 10428 const Array& code_array = Array::Handle(Array::New(length)); |
10593 const Array& pc_offset_array = Array::Handle(Array::New(length)); | 10429 const Array& pc_offset_array = Array::Handle(Array::New(length)); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10696 StorePointer(&raw_ptr()->pattern_, pattern.raw()); | 10532 StorePointer(&raw_ptr()->pattern_, pattern.raw()); |
10697 } | 10533 } |
10698 | 10534 |
10699 | 10535 |
10700 void JSRegExp::set_num_bracket_expressions(intptr_t value) const { | 10536 void JSRegExp::set_num_bracket_expressions(intptr_t value) const { |
10701 raw_ptr()->num_bracket_expressions_ = Smi::New(value); | 10537 raw_ptr()->num_bracket_expressions_ = Smi::New(value); |
10702 } | 10538 } |
10703 | 10539 |
10704 | 10540 |
10705 RawJSRegExp* JSRegExp::New(intptr_t len, Heap::Space space) { | 10541 RawJSRegExp* JSRegExp::New(intptr_t len, Heap::Space space) { |
10706 const Class& cls = Class::Handle( | 10542 ASSERT(Isolate::Current()->object_store()->jsregexp_class() != |
10707 Isolate::Current()->object_store()->jsregexp_class()); | 10543 Class::null()); |
10708 JSRegExp& result = JSRegExp::Handle(); | 10544 JSRegExp& result = JSRegExp::Handle(); |
10709 { | 10545 { |
10710 RawObject* raw = Object::Allocate(cls, | 10546 RawObject* raw = Object::Allocate(JSRegExp::kInstanceKind, |
10711 JSRegExp::InstanceSize(len), | 10547 JSRegExp::InstanceSize(len), |
10712 space); | 10548 space); |
10713 NoGCScope no_gc; | 10549 NoGCScope no_gc; |
10714 result ^= raw; | 10550 result ^= raw; |
10715 result.set_type(kUnitialized); | 10551 result.set_type(kUnitialized); |
10716 result.set_flags(0); | 10552 result.set_flags(0); |
10717 result.SetLength(len); | 10553 result.SetLength(len); |
10718 } | 10554 } |
10719 return result.raw(); | 10555 return result.raw(); |
10720 } | 10556 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10780 const String& str = String::Handle(pattern()); | 10616 const String& str = String::Handle(pattern()); |
10781 const char* format = "JSRegExp: pattern=%s flags=%s"; | 10617 const char* format = "JSRegExp: pattern=%s flags=%s"; |
10782 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 10618 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
10783 char* chars = reinterpret_cast<char*>( | 10619 char* chars = reinterpret_cast<char*>( |
10784 Isolate::Current()->current_zone()->Allocate(len + 1)); | 10620 Isolate::Current()->current_zone()->Allocate(len + 1)); |
10785 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 10621 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
10786 return chars; | 10622 return chars; |
10787 } | 10623 } |
10788 | 10624 |
10789 } // namespace dart | 10625 } // namespace dart |
OLD | NEW |