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

Side by Side Diff: vm/object.cc

Issue 10783035: Create frequently used symbols in the vm isolate (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « vm/object.h ('k') | vm/object_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/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 DEFINE_FLAG(bool, show_internal_names, false, 38 DEFINE_FLAG(bool, show_internal_names, false,
38 "Show names of internal classes (e.g. \"OneByteString\") in error messages " 39 "Show names of internal classes (e.g. \"OneByteString\") in error messages "
39 "instead of showing the corresponding interface names (e.g. \"String\")"); 40 "instead of showing the corresponding interface names (e.g. \"String\")");
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 // TODO(iposva): NoGCScope needs to be added here. 248 // TODO(iposva): NoGCScope needs to be added here.
248 ASSERT(class_class() == null_); 249 ASSERT(class_class() == null_);
249 // Initialize the static vtable values. 250 // Initialize the static vtable values.
250 { 251 {
251 Object fake_object; 252 Object fake_object;
252 Smi fake_smi; 253 Smi fake_smi;
253 Object::handle_vtable_ = fake_object.vtable(); 254 Object::handle_vtable_ = fake_object.vtable();
254 Smi::handle_vtable_ = fake_smi.vtable(); 255 Smi::handle_vtable_ = fake_smi.vtable();
255 } 256 }
256 257
257 Heap* heap = Isolate::Current()->heap(); 258 Isolate* isolate = Isolate::Current();
259 Heap* heap = isolate->heap();
258 // Allocate and initialize the null instance, except its class_ field. 260 // Allocate and initialize the null instance, except its class_ field.
259 // 'null_' must be the first object allocated as it is used in allocation to 261 // 'null_' must be the first object allocated as it is used in allocation to
260 // clear the object. 262 // clear the object.
261 { 263 {
262 uword address = heap->Allocate(Instance::InstanceSize(), Heap::kOld); 264 uword address = heap->Allocate(Instance::InstanceSize(), Heap::kOld);
263 null_ = reinterpret_cast<RawInstance*>(address + kHeapObjectTag); 265 null_ = reinterpret_cast<RawInstance*>(address + kHeapObjectTag);
264 // The call below is using 'null_' to initialize itself. 266 // The call below is using 'null_' to initialize itself.
265 InitializeObject(address, kNullClassId, Instance::InstanceSize()); 267 InitializeObject(address, kNullClassId, Instance::InstanceSize());
266 } 268 }
267 269
268 // Initialize object_store empty array to null_ in order to be able to check 270 // Initialize object_store empty array to null_ in order to be able to check
269 // if the empty array was allocated (RAW_NULL is not available). 271 // if the empty array was allocated (RAW_NULL is not available).
270 Isolate::Current()->object_store()->set_empty_array(Array::Handle()); 272 isolate->object_store()->set_empty_array(Array::Handle());
271 273
272 Class& cls = Class::Handle(); 274 Class& cls = Class::Handle();
273 275
274 // Allocate and initialize the class class. 276 // Allocate and initialize the class class.
275 { 277 {
276 intptr_t size = Class::InstanceSize(); 278 intptr_t size = Class::InstanceSize();
277 uword address = heap->Allocate(size, Heap::kOld); 279 uword address = heap->Allocate(size, Heap::kOld);
278 class_class_ = reinterpret_cast<RawClass*>(address + kHeapObjectTag); 280 class_class_ = reinterpret_cast<RawClass*>(address + kHeapObjectTag);
279 InitializeObject(address, Class::kInstanceKind, size); 281 InitializeObject(address, Class::kInstanceKind, size);
280 282
281 Class fake; 283 Class fake;
282 // Initialization from Class::New<Class>. 284 // Initialization from Class::New<Class>.
283 // Directly set raw_ to break a circular dependency: SetRaw will attempt 285 // Directly set raw_ to break a circular dependency: SetRaw will attempt
284 // to lookup class class in the class table where it is not registered yet. 286 // to lookup class class in the class table where it is not registered yet.
285 cls.raw_ = class_class_; 287 cls.raw_ = class_class_;
286 cls.set_handle_vtable(fake.vtable()); 288 cls.set_handle_vtable(fake.vtable());
287 cls.set_instance_size(Class::InstanceSize()); 289 cls.set_instance_size(Class::InstanceSize());
288 cls.set_next_field_offset(Class::InstanceSize()); 290 cls.set_next_field_offset(Class::InstanceSize());
289 cls.set_instance_kind(Class::kInstanceKind); 291 cls.set_instance_kind(Class::kInstanceKind);
290 cls.set_id(Class::kInstanceKind); 292 cls.set_id(Class::kInstanceKind);
291 cls.raw_ptr()->is_const_ = false; 293 cls.raw_ptr()->is_const_ = false;
292 cls.raw_ptr()->is_interface_ = false; 294 cls.raw_ptr()->is_interface_ = false;
293 cls.set_is_finalized(); 295 cls.set_is_finalized();
294 cls.raw_ptr()->type_arguments_instance_field_offset_ = 296 cls.raw_ptr()->type_arguments_instance_field_offset_ =
295 Class::kNoTypeArguments; 297 Class::kNoTypeArguments;
296 cls.raw_ptr()->num_native_fields_ = 0; 298 cls.raw_ptr()->num_native_fields_ = 0;
297 cls.InitEmptyFields(); 299 cls.InitEmptyFields();
298 Isolate::Current()->class_table()->Register(cls); 300 isolate->class_table()->Register(cls);
299 } 301 }
300 302
301 // Allocate and initialize the null class. 303 // Allocate and initialize the null class.
302 cls = Class::New<Instance>(kNullClassId); 304 cls = Class::New<Instance>(kNullClassId);
303 cls.set_is_finalized(); 305 cls.set_is_finalized();
304 null_class_ = cls.raw(); 306 null_class_ = cls.raw();
305 307
306 // Allocate and initialize the free list element class. 308 // Allocate and initialize the free list element class.
307 cls = Class::New<FreeListElement::FakeInstance>(kFreeListElement); 309 cls = Class::New<FreeListElement::FakeInstance>(kFreeListElement);
308 cls.set_is_finalized(); 310 cls.set_is_finalized();
309 311
310 // Allocate and initialize the sentinel values of Null class. 312 // Allocate and initialize the sentinel values of Null class.
311 { 313 {
312 cls = null_class_;
313 Instance& sentinel = Instance::Handle(); 314 Instance& sentinel = Instance::Handle();
314 sentinel ^= Object::Allocate(cls, Instance::InstanceSize(), Heap::kOld); 315 sentinel ^=
316 Object::Allocate(kNullClassId, Instance::InstanceSize(), Heap::kOld);
315 sentinel_ = sentinel.raw(); 317 sentinel_ = sentinel.raw();
316 318
317 Instance& transition_sentinel = Instance::Handle(); 319 Instance& transition_sentinel = Instance::Handle();
318 transition_sentinel ^= 320 transition_sentinel ^=
319 Object::Allocate(cls, Instance::InstanceSize(), Heap::kOld); 321 Object::Allocate(kNullClassId, Instance::InstanceSize(), Heap::kOld);
320 transition_sentinel_ = transition_sentinel.raw(); 322 transition_sentinel_ = transition_sentinel.raw();
321 } 323 }
322 324
323 // The interface "Dynamic" is not a VM internal class. It is the type class of 325 // The interface "Dynamic" is not a VM internal class. It is the type class of
324 // the "unknown type". For efficiency, we allocate it in the VM isolate. 326 // the "unknown type". For efficiency, we allocate it in the VM isolate.
325 // Therefore, it cannot have a heap allocated name (the name is hard coded, 327 // Therefore, it cannot have a heap allocated name (the name is hard coded,
326 // see GetSingletonClassIndex) and its array fields cannot be set to the empty 328 // see GetSingletonClassIndex) and its array fields cannot be set to the empty
327 // array, but remain null. 329 // array, but remain null.
328 // 330 //
329 // TODO(turnidge): Once the empty array is allocated in the vm 331 // TODO(turnidge): Once the empty array is allocated in the vm
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 cls = Class::New<LanguageError>(); 412 cls = Class::New<LanguageError>();
411 language_error_class_ = cls.raw(); 413 language_error_class_ = cls.raw();
412 414
413 cls = Class::New<UnhandledException>(); 415 cls = Class::New<UnhandledException>();
414 unhandled_exception_class_ = cls.raw(); 416 unhandled_exception_class_ = cls.raw();
415 417
416 cls = Class::New<UnwindError>(); 418 cls = Class::New<UnwindError>();
417 unwind_error_class_ = cls.raw(); 419 unwind_error_class_ = cls.raw();
418 420
419 ASSERT(class_class() != null_); 421 ASSERT(class_class() != null_);
422
423 // Pre-allocate the Array and OneByteString class in the vm isolate so that
424 // we can create a symbol table and populate it with some frequently used
425 // strings as symbols.
426 cls = Class::New<Array>();
427 isolate->object_store()->set_array_class(cls);
428 cls = Class::New<OneByteString>();
429 isolate->object_store()->set_one_byte_string_class(cls);
420 } 430 }
421 431
422 432
423 RawClass* Object::CreateAndRegisterInterface(const char* cname, 433 RawClass* Object::CreateAndRegisterInterface(const char* cname,
424 const Script& script, 434 const Script& script,
425 const Library& lib) { 435 const Library& lib) {
426 const String& name = String::Handle(String::NewSymbol(cname)); 436 const String& name = String::Handle(Symbols::New(cname));
427 const Class& cls = Class::Handle( 437 const Class& cls = Class::Handle(
428 Class::NewInterface(name, script, Scanner::kDummyTokenIndex)); 438 Class::NewInterface(name, script, Scanner::kDummyTokenIndex));
429 lib.AddClass(cls); 439 lib.AddClass(cls);
430 return cls.raw(); 440 return cls.raw();
431 } 441 }
432 442
433 443
434 void Object::RegisterClass(const Class& cls, 444 void Object::RegisterClass(const Class& cls,
435 const char* cname, 445 const char* cname,
436 const Script& script, 446 const Script& script,
437 const Library& lib) { 447 const Library& lib) {
438 const String& name = String::Handle(String::NewSymbol(cname)); 448 const String& name = String::Handle(Symbols::New(cname));
439 cls.set_name(name); 449 cls.set_name(name);
440 cls.set_script(script); 450 cls.set_script(script);
441 lib.AddClass(cls); 451 lib.AddClass(cls);
442 } 452 }
443 453
444 454
445 void Object::RegisterPrivateClass(const Class& cls, 455 void Object::RegisterPrivateClass(const Class& cls,
446 const char* public_class_name, 456 const char* public_class_name,
447 const Script& script, 457 const Script& script,
448 const Library& lib) { 458 const Library& lib) {
449 String& str = String::Handle(); 459 String& str = String::Handle();
450 str = String::NewSymbol(public_class_name); 460 str = Symbols::New(public_class_name);
451 str = lib.PrivateName(str); 461 str = lib.PrivateName(str);
452 cls.set_name(str); 462 cls.set_name(str);
453 cls.set_script(script); 463 cls.set_script(script);
454 lib.AddClass(cls); 464 lib.AddClass(cls);
455 } 465 }
456 466
457 467
458 RawError* Object::Init(Isolate* isolate) { 468 RawError* Object::Init(Isolate* isolate) {
459 TIMERSCOPE(time_bootstrap); 469 TIMERSCOPE(time_bootstrap);
460 ObjectStore* object_store = isolate->object_store(); 470 ObjectStore* object_store = isolate->object_store();
(...skipping 21 matching lines...) Expand all
482 // has been created. 492 // has been created.
483 cls.InitEmptyFields(); 493 cls.InitEmptyFields();
484 494
485 // Set up the growable object array class (Has to be done after the array 495 // Set up the growable object array class (Has to be done after the array
486 // class is setup as one of its field is an array object). 496 // class is setup as one of its field is an array object).
487 cls = Class::New<GrowableObjectArray>(); 497 cls = Class::New<GrowableObjectArray>();
488 object_store->set_growable_object_array_class(cls); 498 object_store->set_growable_object_array_class(cls);
489 cls.set_type_arguments_instance_field_offset( 499 cls.set_type_arguments_instance_field_offset(
490 GrowableObjectArray::type_arguments_offset()); 500 GrowableObjectArray::type_arguments_offset());
491 501
492 // Setup the symbol table used within the String class.
493 const int kInitialSymbolTableSize = 16;
494 array = Array::New(kInitialSymbolTableSize + 1);
495 // Last element contains the count of used slots.
496 array.SetAt(kInitialSymbolTableSize, Smi::Handle(Smi::New(0)));
497 object_store->set_symbol_table(array);
498
499 // canonical_type_arguments_ are NULL terminated. 502 // canonical_type_arguments_ are NULL terminated.
500 array = Array::New(4); 503 array = Array::New(4);
501 object_store->set_canonical_type_arguments(array); 504 object_store->set_canonical_type_arguments(array);
502 505
503 // Pre-allocate the OneByteString class needed by the symbol table. 506 // Pre-allocate the OneByteString class needed by the symbol table.
504 cls = Class::New<OneByteString>(); 507 cls = Class::New<OneByteString>();
505 object_store->set_one_byte_string_class(cls); 508 object_store->set_one_byte_string_class(cls);
506 509
510 // Setup the symbol table for the symbols created in the isolate.
511 Symbols::SetupSymbolTable(isolate);
512
507 // Set up the libraries array before initializing the core library. 513 // Set up the libraries array before initializing the core library.
508 const GrowableObjectArray& libraries = 514 const GrowableObjectArray& libraries =
509 GrowableObjectArray::Handle(GrowableObjectArray::New(Heap::kOld)); 515 GrowableObjectArray::Handle(GrowableObjectArray::New(Heap::kOld));
510 object_store->set_libraries(libraries); 516 object_store->set_libraries(libraries);
511 517
512 // Basic infrastructure has been setup, initialize the class dictionary. 518 // Basic infrastructure has been setup, initialize the class dictionary.
513 Library::InitCoreLibrary(isolate); 519 Library::InitCoreLibrary(isolate);
514 Library& core_lib = Library::Handle(Library::CoreLibrary()); 520 Library& core_lib = Library::Handle(Library::CoreLibrary());
515 ASSERT(!core_lib.IsNull()); 521 ASSERT(!core_lib.IsNull());
516 Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary()); 522 Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary());
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 pending_classes.Add(cls, Heap::kOld); 620 pending_classes.Add(cls, Heap::kOld);
615 621
616 // Initialize the base interfaces used by the core VM classes. 622 // Initialize the base interfaces used by the core VM classes.
617 const Script& script = Script::Handle(Bootstrap::LoadScript()); 623 const Script& script = Script::Handle(Bootstrap::LoadScript());
618 624
619 // Allocate and initialize the Object class and type. The Object 625 // Allocate and initialize the Object class and type. The Object
620 // class and ByteArray subclasses are the only pre-allocated, 626 // class and ByteArray subclasses are the only pre-allocated,
621 // non-interface classes in the core library. 627 // non-interface classes in the core library.
622 cls = Class::New<Instance>(); 628 cls = Class::New<Instance>();
623 object_store->set_object_class(cls); 629 object_store->set_object_class(cls);
624 cls.set_name(String::Handle(String::NewSymbol("Object"))); 630 cls.set_name(String::Handle(Symbols::New("Object")));
625 cls.set_script(script); 631 cls.set_script(script);
626 cls.set_is_prefinalized(); 632 cls.set_is_prefinalized();
627 core_lib.AddClass(cls); 633 core_lib.AddClass(cls);
628 pending_classes.Add(cls, Heap::kOld); 634 pending_classes.Add(cls, Heap::kOld);
629 type = Type::NewNonParameterizedType(cls); 635 type = Type::NewNonParameterizedType(cls);
630 object_store->set_object_type(type); 636 object_store->set_object_type(type);
631 637
632 cls = Class::New<Int8Array>(); 638 cls = Class::New<Int8Array>();
633 object_store->set_int8_array_class(cls); 639 object_store->set_int8_array_class(cls);
634 RegisterPrivateClass(cls, "_Int8Array", script, core_lib); 640 RegisterPrivateClass(cls, "_Int8Array", script, core_lib);
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 cur += kWordSize; 989 cur += kWordSize;
984 } 990 }
985 uword tags = 0; 991 uword tags = 0;
986 ASSERT(index != kIllegalObjectKind); 992 ASSERT(index != kIllegalObjectKind);
987 tags = RawObject::ClassIdTag::update(index, tags); 993 tags = RawObject::ClassIdTag::update(index, tags);
988 tags = RawObject::SizeTag::update(size, tags); 994 tags = RawObject::SizeTag::update(size, tags);
989 reinterpret_cast<RawObject*>(address)->tags_ = tags; 995 reinterpret_cast<RawObject*>(address)->tags_ = tags;
990 } 996 }
991 997
992 998
993 RawObject* Object::Allocate(const Class& cls, 999 RawObject* Object::Allocate(intptr_t cls_id,
994 intptr_t size, 1000 intptr_t size,
995 Heap::Space space) { 1001 Heap::Space space) {
996 ASSERT(Utils::IsAligned(size, kObjectAlignment)); 1002 ASSERT(Utils::IsAligned(size, kObjectAlignment));
997 Isolate* isolate = Isolate::Current(); 1003 Isolate* isolate = Isolate::Current();
998 Heap* heap = isolate->heap(); 1004 Heap* heap = isolate->heap();
999 1005
1000 uword address = heap->Allocate(size, space); 1006 uword address = heap->Allocate(size, space);
1001 if (address == 0) { 1007 if (address == 0) {
1002 // Use the preallocated out of memory exception to avoid calling 1008 // Use the preallocated out of memory exception to avoid calling
1003 // into dart code or allocating any code. 1009 // into dart code or allocating any code.
1004 const Instance& exception = 1010 const Instance& exception =
1005 Instance::Handle(isolate->object_store()->out_of_memory()); 1011 Instance::Handle(isolate->object_store()->out_of_memory());
1006 Exceptions::Throw(exception); 1012 Exceptions::Throw(exception);
1007 UNREACHABLE(); 1013 UNREACHABLE();
1008 } 1014 }
1009 NoGCScope no_gc; 1015 NoGCScope no_gc;
1010 InitializeObject(address, cls.id(), size); 1016 InitializeObject(address, cls_id, size);
1011 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); 1017 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag);
1012 ASSERT(cls.id() == RawObject::ClassIdTag::decode(raw_obj->ptr()->tags_)); 1018 ASSERT(cls_id == RawObject::ClassIdTag::decode(raw_obj->ptr()->tags_));
1013 return raw_obj; 1019 return raw_obj;
1014 } 1020 }
1015 1021
1016 1022
1017 class StoreBufferObjectPointerVisitor : public ObjectPointerVisitor { 1023 class StoreBufferObjectPointerVisitor : public ObjectPointerVisitor {
1018 public: 1024 public:
1019 explicit StoreBufferObjectPointerVisitor(Isolate* isolate) : 1025 explicit StoreBufferObjectPointerVisitor(Isolate* isolate) :
1020 ObjectPointerVisitor(isolate) { 1026 ObjectPointerVisitor(isolate) {
1021 } 1027 }
1022 void VisitPointers(RawObject** first, RawObject** last) { 1028 void VisitPointers(RawObject** first, RawObject** last) {
1023 for (RawObject** curr = first; curr <= last; ++curr) { 1029 for (RawObject** curr = first; curr <= last; ++curr) {
1024 if ((*curr)->IsNewObject()) { 1030 if ((*curr)->IsNewObject()) {
1025 uword ptr = reinterpret_cast<uword>(curr); 1031 uword ptr = reinterpret_cast<uword>(curr);
1026 isolate()->store_buffer()->AddPointer(ptr); 1032 isolate()->store_buffer()->AddPointer(ptr);
1027 } 1033 }
1028 } 1034 }
1029 } 1035 }
1030 1036
1031 private: 1037 private:
1032 DISALLOW_COPY_AND_ASSIGN(StoreBufferObjectPointerVisitor); 1038 DISALLOW_COPY_AND_ASSIGN(StoreBufferObjectPointerVisitor);
1033 }; 1039 };
1034 1040
1035 1041
1036 RawObject* Object::Clone(const Object& src, Heap::Space space) { 1042 RawObject* Object::Clone(const Object& src, Heap::Space space) {
1037 const Class& cls = Class::Handle(src.clazz()); 1043 const Class& cls = Class::Handle(src.clazz());
1038 intptr_t size = src.raw()->Size(); 1044 intptr_t size = src.raw()->Size();
1039 RawObject* raw_obj = Object::Allocate(cls, size, space); 1045 RawObject* raw_obj = Object::Allocate(cls.id(), size, space);
1040 NoGCScope no_gc; 1046 NoGCScope no_gc;
1041 memmove(raw_obj->ptr(), src.raw()->ptr(), size); 1047 memmove(raw_obj->ptr(), src.raw()->ptr(), size);
1042 if (space == Heap::kOld) { 1048 if (space == Heap::kOld) {
1043 StoreBufferObjectPointerVisitor visitor(Isolate::Current()); 1049 StoreBufferObjectPointerVisitor visitor(Isolate::Current());
1044 raw_obj->VisitPointers(&visitor); 1050 raw_obj->VisitPointers(&visitor);
1045 } 1051 }
1046 return raw_obj; 1052 return raw_obj;
1047 } 1053 }
1048 1054
1049 1055
1050 RawString* Class::Name() const { 1056 RawString* Class::Name() const {
1051 if (raw_ptr()->name_ != String::null()) { 1057 if (raw_ptr()->name_ != String::null()) {
1052 return raw_ptr()->name_; 1058 return raw_ptr()->name_;
1053 } 1059 }
1054 ASSERT(class_class() != Class::null()); // class_class_ should be set up. 1060 ASSERT(class_class() != Class::null()); // class_class_ should be set up.
1055 intptr_t index = GetSingletonClassIndex(raw()); 1061 intptr_t index = GetSingletonClassIndex(raw());
1056 return String::NewSymbol(GetSingletonClassName(index)); 1062 return Symbols::New(GetSingletonClassName(index));
1057 } 1063 }
1058 1064
1059 1065
1060 RawString* Class::UserVisibleName() const { 1066 RawString* Class::UserVisibleName() const {
1061 if (FLAG_show_internal_names) { 1067 if (FLAG_show_internal_names) {
1062 return Name(); 1068 return Name();
1063 } 1069 }
1064 switch (id()) { 1070 switch (id()) {
1065 case kInteger: 1071 case kInteger:
1066 case kSmi: 1072 case kSmi:
1067 case kMint: 1073 case kMint:
1068 case kBigint: 1074 case kBigint:
1069 return String::NewSymbol("int"); 1075 return Symbols::New("int");
1070 case kDouble: 1076 case kDouble:
1071 return String::NewSymbol("double"); 1077 return Symbols::New("double");
1072 case kOneByteString: 1078 case kOneByteString:
1073 case kTwoByteString: 1079 case kTwoByteString:
1074 case kFourByteString: 1080 case kFourByteString:
1075 case kExternalOneByteString: 1081 case kExternalOneByteString:
1076 case kExternalTwoByteString: 1082 case kExternalTwoByteString:
1077 case kExternalFourByteString: 1083 case kExternalFourByteString:
1078 return String::NewSymbol("String"); 1084 return Symbols::New("String");
1079 case kBool: 1085 case kBool:
1080 return String::NewSymbol("bool"); 1086 return Symbols::New("bool");
1081 case kArray: 1087 case kArray:
1082 case kImmutableArray: 1088 case kImmutableArray:
1083 case kGrowableObjectArray: 1089 case kGrowableObjectArray:
1084 return String::NewSymbol("List"); 1090 return Symbols::New("List");
1085 case kInt8Array: 1091 case kInt8Array:
1086 case kExternalInt8Array: 1092 case kExternalInt8Array:
1087 return String::NewSymbol("Int8List"); 1093 return Symbols::New("Int8List");
1088 case kUint8Array: 1094 case kUint8Array:
1089 case kExternalUint8Array: 1095 case kExternalUint8Array:
1090 return String::NewSymbol("Uint8List"); 1096 return Symbols::New("Uint8List");
1091 case kInt16Array: 1097 case kInt16Array:
1092 case kExternalInt16Array: 1098 case kExternalInt16Array:
1093 return String::NewSymbol("Int16List"); 1099 return Symbols::New("Int16List");
1094 case kUint16Array: 1100 case kUint16Array:
1095 case kExternalUint16Array: 1101 case kExternalUint16Array:
1096 return String::NewSymbol("Uint16List"); 1102 return Symbols::New("Uint16List");
1097 case kInt32Array: 1103 case kInt32Array:
1098 case kExternalInt32Array: 1104 case kExternalInt32Array:
1099 return String::NewSymbol("Int32List"); 1105 return Symbols::New("Int32List");
1100 case kUint32Array: 1106 case kUint32Array:
1101 case kExternalUint32Array: 1107 case kExternalUint32Array:
1102 return String::NewSymbol("Uint32List"); 1108 return Symbols::New("Uint32List");
1103 case kInt64Array: 1109 case kInt64Array:
1104 case kExternalInt64Array: 1110 case kExternalInt64Array:
1105 return String::NewSymbol("Int64List"); 1111 return Symbols::New("Int64List");
1106 case kUint64Array: 1112 case kUint64Array:
1107 case kExternalUint64Array: 1113 case kExternalUint64Array:
1108 return String::NewSymbol("Uint64List"); 1114 return Symbols::New("Uint64List");
1109 case kFloat32Array: 1115 case kFloat32Array:
1110 case kExternalFloat32Array: 1116 case kExternalFloat32Array:
1111 return String::NewSymbol("Float32List"); 1117 return Symbols::New("Float32List");
1112 case kFloat64Array: 1118 case kFloat64Array:
1113 case kExternalFloat64Array: 1119 case kExternalFloat64Array:
1114 return String::NewSymbol("Float64List"); 1120 return Symbols::New("Float64List");
1115 default: 1121 default:
1116 return Name(); 1122 return Name();
1117 } 1123 }
1118 UNREACHABLE(); 1124 UNREACHABLE();
1119 } 1125 }
1120 1126
1121 1127
1122 RawType* Class::SignatureType() const { 1128 RawType* Class::SignatureType() const {
1123 ASSERT(IsSignatureClass()); 1129 ASSERT(IsSignatureClass());
1124 const Function& function = Function::Handle(signature_function()); 1130 const Function& function = Function::Handle(signature_function());
(...skipping 29 matching lines...) Expand all
1154 Type::New(*this, signature_type_arguments, token_pos())); 1160 Type::New(*this, signature_type_arguments, token_pos()));
1155 1161
1156 // Return the still unfinalized signature type. 1162 // Return the still unfinalized signature type.
1157 ASSERT(!signature_type.IsFinalized()); 1163 ASSERT(!signature_type.IsFinalized());
1158 return signature_type.raw(); 1164 return signature_type.raw();
1159 } 1165 }
1160 1166
1161 1167
1162 template <class FakeObject> 1168 template <class FakeObject>
1163 RawClass* Class::New() { 1169 RawClass* Class::New() {
1164 Class& class_class = Class::Handle(Object::class_class()); 1170 ASSERT(Object::class_class() != Class::null());
1165 Class& result = Class::Handle(); 1171 Class& result = Class::Handle();
1166 { 1172 {
1167 RawObject* raw = Object::Allocate(class_class, 1173 RawObject* raw = Object::Allocate(Class::kInstanceKind,
1168 Class::InstanceSize(), 1174 Class::InstanceSize(),
1169 Heap::kOld); 1175 Heap::kOld);
1170 NoGCScope no_gc; 1176 NoGCScope no_gc;
1171 result ^= raw; 1177 result ^= raw;
1172 } 1178 }
1173 FakeObject fake; 1179 FakeObject fake;
1174 result.set_handle_vtable(fake.vtable()); 1180 result.set_handle_vtable(fake.vtable());
1175 result.set_instance_size(FakeObject::InstanceSize()); 1181 result.set_instance_size(FakeObject::InstanceSize());
1176 result.set_next_field_offset(FakeObject::InstanceSize()); 1182 result.set_next_field_offset(FakeObject::InstanceSize());
1177 result.set_instance_kind(FakeObject::kInstanceKind); 1183 result.set_instance_kind(FakeObject::kInstanceKind);
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1489 ASSERT(!(field.is_static() && field.is_final()) || 1495 ASSERT(!(field.is_static() && field.is_final()) ||
1490 (field.value() == Object::sentinel())); 1496 (field.value() == Object::sentinel()));
1491 } 1497 }
1492 // The value of static fields is already initialized to null. 1498 // The value of static fields is already initialized to null.
1493 StorePointer(&raw_ptr()->fields_, value.raw()); 1499 StorePointer(&raw_ptr()->fields_, value.raw());
1494 } 1500 }
1495 1501
1496 1502
1497 template <class FakeInstance> 1503 template <class FakeInstance>
1498 RawClass* Class::New(intptr_t index) { 1504 RawClass* Class::New(intptr_t index) {
1499 Class& class_class = Class::Handle(Object::class_class()); 1505 ASSERT(Object::class_class() != Class::null());
1500 Class& result = Class::Handle(); 1506 Class& result = Class::Handle();
1501 { 1507 {
1502 RawObject* raw = Object::Allocate(class_class, 1508 RawObject* raw = Object::Allocate(Class::kInstanceKind,
1503 Class::InstanceSize(), 1509 Class::InstanceSize(),
1504 Heap::kOld); 1510 Heap::kOld);
1505 NoGCScope no_gc; 1511 NoGCScope no_gc;
1506 result ^= raw; 1512 result ^= raw;
1507 } 1513 }
1508 FakeInstance fake; 1514 FakeInstance fake;
1509 ASSERT(fake.IsInstance()); 1515 ASSERT(fake.IsInstance());
1510 result.set_handle_vtable(fake.vtable()); 1516 result.set_handle_vtable(fake.vtable());
1511 result.set_instance_size(FakeInstance::InstanceSize()); 1517 result.set_instance_size(FakeInstance::InstanceSize());
1512 result.set_next_field_offset(FakeInstance::InstanceSize()); 1518 result.set_next_field_offset(FakeInstance::InstanceSize());
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
2216 intptr_t token_pos) { 2222 intptr_t token_pos) {
2217 const UnresolvedClass& type = UnresolvedClass::Handle(UnresolvedClass::New()); 2223 const UnresolvedClass& type = UnresolvedClass::Handle(UnresolvedClass::New());
2218 type.set_library_prefix(library_prefix); 2224 type.set_library_prefix(library_prefix);
2219 type.set_ident(ident); 2225 type.set_ident(ident);
2220 type.set_token_pos(token_pos); 2226 type.set_token_pos(token_pos);
2221 return type.raw(); 2227 return type.raw();
2222 } 2228 }
2223 2229
2224 2230
2225 RawUnresolvedClass* UnresolvedClass::New() { 2231 RawUnresolvedClass* UnresolvedClass::New() {
2226 const Class& unresolved_class_class = 2232 ASSERT(Object::unresolved_class_class() != Class::null());
2227 Class::Handle(Object::unresolved_class_class()); 2233 RawObject* raw = Object::Allocate(UnresolvedClass::kInstanceKind,
2228 RawObject* raw = Object::Allocate(unresolved_class_class,
2229 UnresolvedClass::InstanceSize(), 2234 UnresolvedClass::InstanceSize(),
2230 Heap::kOld); 2235 Heap::kOld);
2231 return reinterpret_cast<RawUnresolvedClass*>(raw); 2236 return reinterpret_cast<RawUnresolvedClass*>(raw);
2232 } 2237 }
2233 2238
2234 2239
2235 void UnresolvedClass::set_token_pos(intptr_t token_pos) const { 2240 void UnresolvedClass::set_token_pos(intptr_t token_pos) const {
2236 ASSERT(token_pos >= 0); 2241 ASSERT(token_pos >= 0);
2237 raw_ptr()->token_pos_ = token_pos; 2242 raw_ptr()->token_pos_ = token_pos;
2238 } 2243 }
(...skipping 14 matching lines...) Expand all
2253 StorePointer(&raw_ptr()->factory_signature_class_, value.raw()); 2258 StorePointer(&raw_ptr()->factory_signature_class_, value.raw());
2254 } 2259 }
2255 2260
2256 2261
2257 RawString* UnresolvedClass::Name() const { 2262 RawString* UnresolvedClass::Name() const {
2258 if (library_prefix() != LibraryPrefix::null()) { 2263 if (library_prefix() != LibraryPrefix::null()) {
2259 const LibraryPrefix& lib_prefix = LibraryPrefix::Handle(library_prefix()); 2264 const LibraryPrefix& lib_prefix = LibraryPrefix::Handle(library_prefix());
2260 String& name = String::Handle(); 2265 String& name = String::Handle();
2261 String& str = String::Handle(); 2266 String& str = String::Handle();
2262 name = lib_prefix.name(); // Qualifier. 2267 name = lib_prefix.name(); // Qualifier.
2263 str = String::New("."); 2268 str = Symbols::Dot();
2264 name = String::Concat(name, str); 2269 name = String::Concat(name, str);
2265 str = ident(); 2270 str = ident();
2266 name = String::Concat(name, str); 2271 name = String::Concat(name, str);
2267 return name.raw(); 2272 return name.raw();
2268 } else { 2273 } else {
2269 return ident(); 2274 return ident();
2270 } 2275 }
2271 } 2276 }
2272 2277
2273 2278
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
2454 } else { 2459 } else {
2455 const String& args_name = String::Handle( 2460 const String& args_name = String::Handle(
2456 args.SubvectorName(first_type_param_index, 2461 args.SubvectorName(first_type_param_index,
2457 num_type_params, 2462 num_type_params,
2458 name_visibility)); 2463 name_visibility));
2459 type_name = String::Concat(class_name, args_name); 2464 type_name = String::Concat(class_name, args_name);
2460 } 2465 }
2461 // The name is only used for type checking and debugging purposes. 2466 // The name is only used for type checking and debugging purposes.
2462 // Unless profiling data shows otherwise, it is not worth caching the name in 2467 // Unless profiling data shows otherwise, it is not worth caching the name in
2463 // the type. 2468 // the type.
2464 return String::NewSymbol(type_name); 2469 return Symbols::New(type_name);
2465 } 2470 }
2466 2471
2467 2472
2468 RawString* AbstractType::ClassName() const { 2473 RawString* AbstractType::ClassName() const {
2469 if (HasResolvedTypeClass()) { 2474 if (HasResolvedTypeClass()) {
2470 return Class::Handle(type_class()).Name(); 2475 return Class::Handle(type_class()).Name();
2471 } else { 2476 } else {
2472 return UnresolvedClass::Handle(unresolved_class()).Name(); 2477 return UnresolvedClass::Handle(unresolved_class()).Name();
2473 } 2478 }
2474 } 2479 }
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
2866 StorePointer(&raw_ptr()->type_class_, value.raw()); 2871 StorePointer(&raw_ptr()->type_class_, value.raw());
2867 } 2872 }
2868 2873
2869 2874
2870 void Type::set_arguments(const AbstractTypeArguments& value) const { 2875 void Type::set_arguments(const AbstractTypeArguments& value) const {
2871 StorePointer(&raw_ptr()->arguments_, value.raw()); 2876 StorePointer(&raw_ptr()->arguments_, value.raw());
2872 } 2877 }
2873 2878
2874 2879
2875 RawType* Type::New(Heap::Space space) { 2880 RawType* Type::New(Heap::Space space) {
2876 const Class& type_class = Class::Handle(Object::type_class()); 2881 ASSERT(Object::type_class() != Class::null());
2877 RawObject* raw = Object::Allocate(type_class, 2882 RawObject* raw = Object::Allocate(Type::kInstanceKind,
2878 Type::InstanceSize(), 2883 Type::InstanceSize(),
2879 space); 2884 space);
2880 return reinterpret_cast<RawType*>(raw); 2885 return reinterpret_cast<RawType*>(raw);
2881 } 2886 }
2882 2887
2883 2888
2884 RawType* Type::New(const Object& clazz, 2889 RawType* Type::New(const Object& clazz,
2885 const AbstractTypeArguments& arguments, 2890 const AbstractTypeArguments& arguments,
2886 intptr_t token_pos, 2891 intptr_t token_pos,
2887 Heap::Space space) { 2892 Heap::Space space) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
3027 const AbstractTypeArguments& instantiator_type_arguments) const { 3032 const AbstractTypeArguments& instantiator_type_arguments) const {
3028 ASSERT(IsFinalized()); 3033 ASSERT(IsFinalized());
3029 if (instantiator_type_arguments.IsNull()) { 3034 if (instantiator_type_arguments.IsNull()) {
3030 return Type::DynamicType(); 3035 return Type::DynamicType();
3031 } 3036 }
3032 return instantiator_type_arguments.TypeAt(index()); 3037 return instantiator_type_arguments.TypeAt(index());
3033 } 3038 }
3034 3039
3035 3040
3036 RawTypeParameter* TypeParameter::New() { 3041 RawTypeParameter* TypeParameter::New() {
3037 const Class& type_parameter_class = 3042 ASSERT(Object::type_parameter_class() != Class::null());
3038 Class::Handle(Object::type_parameter_class()); 3043 RawObject* raw = Object::Allocate(TypeParameter::kInstanceKind,
3039 RawObject* raw = Object::Allocate(type_parameter_class,
3040 TypeParameter::InstanceSize(), 3044 TypeParameter::InstanceSize(),
3041 Heap::kOld); 3045 Heap::kOld);
3042 return reinterpret_cast<RawTypeParameter*>(raw); 3046 return reinterpret_cast<RawTypeParameter*>(raw);
3043 } 3047 }
3044 3048
3045 3049
3046 RawTypeParameter* TypeParameter::New(const Class& parameterized_class, 3050 RawTypeParameter* TypeParameter::New(const Class& parameterized_class,
3047 intptr_t index, 3051 intptr_t index,
3048 const String& name, 3052 const String& name,
3049 const AbstractType& bound, 3053 const AbstractType& bound,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
3128 3132
3129 RawString* AbstractTypeArguments::SubvectorName( 3133 RawString* AbstractTypeArguments::SubvectorName(
3130 intptr_t from_index, 3134 intptr_t from_index,
3131 intptr_t len, 3135 intptr_t len,
3132 NameVisibility name_visibility) const { 3136 NameVisibility name_visibility) const {
3133 ASSERT(from_index + len <= Length()); 3137 ASSERT(from_index + len <= Length());
3134 String& name = String::Handle(); 3138 String& name = String::Handle();
3135 const intptr_t num_strings = 2*len + 1; // "<""T"", ""T"">". 3139 const intptr_t num_strings = 2*len + 1; // "<""T"", ""T"">".
3136 const Array& strings = Array::Handle(Array::New(num_strings)); 3140 const Array& strings = Array::Handle(Array::New(num_strings));
3137 intptr_t s = 0; 3141 intptr_t s = 0;
3138 strings.SetAt(s++, String::Handle(String::NewSymbol("<"))); 3142 strings.SetAt(s++, String::Handle(Symbols::New("<")));
3139 const String& kCommaSpace = String::Handle(String::NewSymbol(", ")); 3143 const String& kCommaSpace = String::Handle(Symbols::New(", "));
3140 AbstractType& type = AbstractType::Handle(); 3144 AbstractType& type = AbstractType::Handle();
3141 for (intptr_t i = 0; i < len; i++) { 3145 for (intptr_t i = 0; i < len; i++) {
3142 type = TypeAt(from_index + i); 3146 type = TypeAt(from_index + i);
3143 name = type.BuildName(name_visibility); 3147 name = type.BuildName(name_visibility);
3144 strings.SetAt(s++, name); 3148 strings.SetAt(s++, name);
3145 if (i < len - 1) { 3149 if (i < len - 1) {
3146 strings.SetAt(s++, kCommaSpace); 3150 strings.SetAt(s++, kCommaSpace);
3147 } 3151 }
3148 } 3152 }
3149 strings.SetAt(s++, String::Handle(String::NewSymbol(">"))); 3153 strings.SetAt(s++, String::Handle(Symbols::New(">")));
3150 ASSERT(s == num_strings); 3154 ASSERT(s == num_strings);
3151 name = String::ConcatAll(strings); 3155 name = String::ConcatAll(strings);
3152 return String::NewSymbol(name); 3156 return Symbols::New(name);
3153 } 3157 }
3154 3158
3155 3159
3156 bool AbstractTypeArguments::Equals(const AbstractTypeArguments& other) const { 3160 bool AbstractTypeArguments::Equals(const AbstractTypeArguments& other) const {
3157 ASSERT(!IsNull()); // Use AbstractTypeArguments::AreEqual(). 3161 ASSERT(!IsNull()); // Use AbstractTypeArguments::AreEqual().
3158 if (this->raw() == other.raw()) { 3162 if (this->raw() == other.raw()) {
3159 return true; 3163 return true;
3160 } 3164 }
3161 if (other.IsNull()) { 3165 if (other.IsNull()) {
3162 return false; 3166 return false;
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
3453 } 3457 }
3454 3458
3455 3459
3456 RawTypeArguments* TypeArguments::New(intptr_t len, Heap::Space space) { 3460 RawTypeArguments* TypeArguments::New(intptr_t len, Heap::Space space) {
3457 if ((len < 0) || (len > kMaxTypes)) { 3461 if ((len < 0) || (len > kMaxTypes)) {
3458 // TODO(iposva): Should we throw an illegal parameter exception? 3462 // TODO(iposva): Should we throw an illegal parameter exception?
3459 UNIMPLEMENTED(); 3463 UNIMPLEMENTED();
3460 return null(); 3464 return null();
3461 } 3465 }
3462 3466
3463 const Class& type_arguments_class =
3464 Class::Handle(Object::type_arguments_class());
3465 TypeArguments& result = TypeArguments::Handle(); 3467 TypeArguments& result = TypeArguments::Handle();
3466 { 3468 {
3467 RawObject* raw = Object::Allocate(type_arguments_class, 3469 RawObject* raw = Object::Allocate(TypeArguments::kInstanceKind,
3468 TypeArguments::InstanceSize(len), 3470 TypeArguments::InstanceSize(len),
3469 space); 3471 space);
3470 NoGCScope no_gc; 3472 NoGCScope no_gc;
3471 result ^= raw; 3473 result ^= raw;
3472 // Length must be set before we start storing into the array. 3474 // Length must be set before we start storing into the array.
3473 result.SetLength(len); 3475 result.SetLength(len);
3474 } 3476 }
3475 return result.raw(); 3477 return result.raw();
3476 } 3478 }
3477 3479
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
3577 } 3579 }
3578 3580
3579 3581
3580 void InstantiatedTypeArguments::set_instantiator_type_arguments( 3582 void InstantiatedTypeArguments::set_instantiator_type_arguments(
3581 const AbstractTypeArguments& value) const { 3583 const AbstractTypeArguments& value) const {
3582 StorePointer(&raw_ptr()->instantiator_type_arguments_, value.raw()); 3584 StorePointer(&raw_ptr()->instantiator_type_arguments_, value.raw());
3583 } 3585 }
3584 3586
3585 3587
3586 RawInstantiatedTypeArguments* InstantiatedTypeArguments::New() { 3588 RawInstantiatedTypeArguments* InstantiatedTypeArguments::New() {
3587 const Class& instantiated_type_arguments_class = 3589 ASSERT(Object::instantiated_type_arguments_class() != Class::null());
3588 Class::Handle(Object::instantiated_type_arguments_class()); 3590 RawObject* raw = Object::Allocate(InstantiatedTypeArguments::kInstanceKind,
3589 RawObject* raw = Object::Allocate(instantiated_type_arguments_class,
3590 InstantiatedTypeArguments::InstanceSize(), 3591 InstantiatedTypeArguments::InstanceSize(),
3591 Heap::kNew); 3592 Heap::kNew);
3592 return reinterpret_cast<RawInstantiatedTypeArguments*>(raw); 3593 return reinterpret_cast<RawInstantiatedTypeArguments*>(raw);
3593 } 3594 }
3594 3595
3595 3596
3596 RawInstantiatedTypeArguments* InstantiatedTypeArguments::New( 3597 RawInstantiatedTypeArguments* InstantiatedTypeArguments::New(
3597 const AbstractTypeArguments& uninstantiated_type_arguments, 3598 const AbstractTypeArguments& uninstantiated_type_arguments,
3598 const AbstractTypeArguments& instantiator_type_arguments) { 3599 const AbstractTypeArguments& instantiator_type_arguments) {
3599 const InstantiatedTypeArguments& result = 3600 const InstantiatedTypeArguments& result =
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
4081 bool Function::IsImplicitClosureFunction() const { 4082 bool Function::IsImplicitClosureFunction() const {
4082 if (!IsClosureFunction()) { 4083 if (!IsClosureFunction()) {
4083 return false; 4084 return false;
4084 } 4085 }
4085 const Function& parent = Function::Handle(parent_function()); 4086 const Function& parent = Function::Handle(parent_function());
4086 return parent.raw_ptr()->implicit_closure_function_ == raw(); 4087 return parent.raw_ptr()->implicit_closure_function_ == raw();
4087 } 4088 }
4088 4089
4089 4090
4090 RawFunction* Function::New() { 4091 RawFunction* Function::New() {
4091 const Class& function_class = Class::Handle(Object::function_class()); 4092 ASSERT(Object::function_class() != Class::null());
4092 RawObject* raw = Object::Allocate(function_class, 4093 RawObject* raw = Object::Allocate(Function::kInstanceKind,
4093 Function::InstanceSize(), 4094 Function::InstanceSize(),
4094 Heap::kOld); 4095 Heap::kOld);
4095 return reinterpret_cast<RawFunction*>(raw); 4096 return reinterpret_cast<RawFunction*>(raw);
4096 } 4097 }
4097 4098
4098 4099
4099 RawFunction* Function::New(const String& name, 4100 RawFunction* Function::New(const String& name,
4100 RawFunction::Kind kind, 4101 RawFunction::Kind kind,
4101 bool is_static, 4102 bool is_static,
4102 bool is_const, 4103 bool is_const,
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
4213 return closure_function.raw(); 4214 return closure_function.raw();
4214 } 4215 }
4215 4216
4216 4217
4217 RawString* Function::BuildSignature( 4218 RawString* Function::BuildSignature(
4218 bool instantiate, 4219 bool instantiate,
4219 NameVisibility name_visibility, 4220 NameVisibility name_visibility,
4220 const AbstractTypeArguments& instantiator) const { 4221 const AbstractTypeArguments& instantiator) const {
4221 const GrowableObjectArray& pieces = 4222 const GrowableObjectArray& pieces =
4222 GrowableObjectArray::Handle(GrowableObjectArray::New()); 4223 GrowableObjectArray::Handle(GrowableObjectArray::New());
4223 const String& kCommaSpace = String::Handle(String::NewSymbol(", ")); 4224 const String& kCommaSpace = String::Handle(Symbols::New(", "));
4224 const String& kColonSpace = String::Handle(String::NewSymbol(": ")); 4225 const String& kColonSpace = String::Handle(Symbols::New(": "));
4225 const String& kLParen = String::Handle(String::NewSymbol("(")); 4226 const String& kLParen = String::Handle(Symbols::New("("));
4226 const String& kRParen = String::Handle(String::NewSymbol(") => ")); 4227 const String& kRParen = String::Handle(Symbols::New(") => "));
4227 const String& kLBracket = String::Handle(String::NewSymbol("[")); 4228 const String& kLBracket = String::Handle(Symbols::New("["));
4228 const String& kRBracket = String::Handle(String::NewSymbol("]")); 4229 const String& kRBracket = String::Handle(Symbols::New("]"));
4229 String& name = String::Handle(); 4230 String& name = String::Handle();
4230 if (!instantiate && !is_static()) { 4231 if (!instantiate && !is_static()) {
4231 // Prefix the signature with its type parameters, if any (e.g. "<K, V>"). 4232 // Prefix the signature with its type parameters, if any (e.g. "<K, V>").
4232 // The signature of static functions cannot be type parameterized. 4233 // The signature of static functions cannot be type parameterized.
4233 const String& kSpaceExtendsSpace = 4234 const String& kSpaceExtendsSpace =
4234 String::Handle(String::NewSymbol(" extends ")); 4235 String::Handle(Symbols::New(" extends "));
4235 const String& kLAngleBracket = String::Handle(String::NewSymbol("<")); 4236 const String& kLAngleBracket = String::Handle(Symbols::New("<"));
4236 const String& kRAngleBracket = String::Handle(String::NewSymbol(">")); 4237 const String& kRAngleBracket = String::Handle(Symbols::New(">"));
4237 const Class& function_class = Class::Handle(owner()); 4238 const Class& function_class = Class::Handle(owner());
4238 ASSERT(!function_class.IsNull()); 4239 ASSERT(!function_class.IsNull());
4239 const TypeArguments& type_parameters = TypeArguments::Handle( 4240 const TypeArguments& type_parameters = TypeArguments::Handle(
4240 function_class.type_parameters()); 4241 function_class.type_parameters());
4241 if (!type_parameters.IsNull()) { 4242 if (!type_parameters.IsNull()) {
4242 intptr_t num_type_parameters = type_parameters.Length(); 4243 intptr_t num_type_parameters = type_parameters.Length();
4243 pieces.Add(kLAngleBracket); 4244 pieces.Add(kLAngleBracket);
4244 TypeParameter& type_parameter = TypeParameter::Handle(); 4245 TypeParameter& type_parameter = TypeParameter::Handle();
4245 AbstractType& bound = AbstractType::Handle(); 4246 AbstractType& bound = AbstractType::Handle();
4246 for (intptr_t i = 0; i < num_type_parameters; i++) { 4247 for (intptr_t i = 0; i < num_type_parameters; i++) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
4298 pieces.Add(kRBracket); 4299 pieces.Add(kRBracket);
4299 } 4300 }
4300 pieces.Add(kRParen); 4301 pieces.Add(kRParen);
4301 AbstractType& res_type = AbstractType::Handle(result_type()); 4302 AbstractType& res_type = AbstractType::Handle(result_type());
4302 if (instantiate && !res_type.IsInstantiated()) { 4303 if (instantiate && !res_type.IsInstantiated()) {
4303 res_type = res_type.InstantiateFrom(instantiator); 4304 res_type = res_type.InstantiateFrom(instantiator);
4304 } 4305 }
4305 name = res_type.BuildName(name_visibility); 4306 name = res_type.BuildName(name_visibility);
4306 pieces.Add(name); 4307 pieces.Add(name);
4307 const Array& strings = Array::Handle(Array::MakeArray(pieces)); 4308 const Array& strings = Array::Handle(Array::MakeArray(pieces));
4308 return String::NewSymbol(String::Handle(String::ConcatAll(strings))); 4309 return Symbols::New(String::Handle(String::ConcatAll(strings)));
4309 } 4310 }
4310 4311
4311 4312
4312 bool Function::HasInstantiatedSignature() const { 4313 bool Function::HasInstantiatedSignature() const {
4313 AbstractType& type = AbstractType::Handle(result_type()); 4314 AbstractType& type = AbstractType::Handle(result_type());
4314 if (!type.IsInstantiated()) { 4315 if (!type.IsInstantiated()) {
4315 return false; 4316 return false;
4316 } 4317 }
4317 const intptr_t num_parameters = NumberOfParameters(); 4318 const intptr_t num_parameters = NumberOfParameters();
4318 for (intptr_t i = 0; i < num_parameters; i++) { 4319 for (intptr_t i = 0; i < num_parameters; i++) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
4376 String& str = String::Handle(); 4377 String& str = String::Handle();
4377 str = String::New(kGetterPrefix); 4378 str = String::New(kGetterPrefix);
4378 str = String::Concat(str, field_name); 4379 str = String::Concat(str, field_name);
4379 return str.raw(); 4380 return str.raw();
4380 } 4381 }
4381 4382
4382 4383
4383 RawString* Field::GetterSymbol(const String& field_name) { 4384 RawString* Field::GetterSymbol(const String& field_name) {
4384 String& str = String::Handle(); 4385 String& str = String::Handle();
4385 str = Field::GetterName(field_name); 4386 str = Field::GetterName(field_name);
4386 return String::NewSymbol(str); 4387 return Symbols::New(str);
4387 } 4388 }
4388 4389
4389 4390
4390 RawString* Field::SetterName(const String& field_name) { 4391 RawString* Field::SetterName(const String& field_name) {
4391 String& str = String::Handle(); 4392 String& str = String::Handle();
4392 str = String::New(kSetterPrefix); 4393 str = String::New(kSetterPrefix);
4393 str = String::Concat(str, field_name); 4394 str = String::Concat(str, field_name);
4394 return str.raw(); 4395 return str.raw();
4395 } 4396 }
4396 4397
4397 4398
4398 RawString* Field::SetterSymbol(const String& field_name) { 4399 RawString* Field::SetterSymbol(const String& field_name) {
4399 String& str = String::Handle(); 4400 String& str = String::Handle();
4400 str = Field::SetterName(field_name); 4401 str = Field::SetterName(field_name);
4401 return String::NewSymbol(str); 4402 return Symbols::New(str);
4402 } 4403 }
4403 4404
4404 4405
4405 RawString* Field::NameFromGetter(const String& getter_name) { 4406 RawString* Field::NameFromGetter(const String& getter_name) {
4406 String& str = String::Handle(); 4407 String& str = String::Handle();
4407 str = String::SubString(getter_name, strlen(kGetterPrefix)); 4408 str = String::SubString(getter_name, strlen(kGetterPrefix));
4408 return str.raw(); 4409 return str.raw();
4409 } 4410 }
4410 4411
4411 4412
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
4444 } 4445 }
4445 4446
4446 4447
4447 void Field::set_type(const AbstractType& value) const { 4448 void Field::set_type(const AbstractType& value) const {
4448 ASSERT(!value.IsNull()); 4449 ASSERT(!value.IsNull());
4449 StorePointer(&raw_ptr()->type_, value.raw()); 4450 StorePointer(&raw_ptr()->type_, value.raw());
4450 } 4451 }
4451 4452
4452 4453
4453 RawField* Field::New() { 4454 RawField* Field::New() {
4454 const Class& field_class = Class::Handle(Object::field_class()); 4455 ASSERT(Object::field_class() != Class::null());
4455 RawObject* raw = Object::Allocate(field_class, 4456 RawObject* raw = Object::Allocate(Field::kInstanceKind,
4456 Field::InstanceSize(), 4457 Field::InstanceSize(),
4457 Heap::kOld); 4458 Heap::kOld);
4458 return reinterpret_cast<RawField*>(raw); 4459 return reinterpret_cast<RawField*>(raw);
4459 } 4460 }
4460 4461
4461 4462
4462 RawField* Field::New(const String& name, 4463 RawField* Field::New(const String& name,
4463 bool is_static, 4464 bool is_static,
4464 bool is_final, 4465 bool is_final,
4465 intptr_t token_pos) { 4466 intptr_t token_pos) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
4499 StorePointer(&raw_ptr()->literal_, literal.raw()); 4500 StorePointer(&raw_ptr()->literal_, literal.raw());
4500 } 4501 }
4501 4502
4502 4503
4503 void LiteralToken::set_value(const Object& value) const { 4504 void LiteralToken::set_value(const Object& value) const {
4504 StorePointer(&raw_ptr()->value_, value.raw()); 4505 StorePointer(&raw_ptr()->value_, value.raw());
4505 } 4506 }
4506 4507
4507 4508
4508 RawLiteralToken* LiteralToken::New() { 4509 RawLiteralToken* LiteralToken::New() {
4509 const Class& cls = Class::Handle(Object::literal_token_class()); 4510 ASSERT(Object::literal_token_class() != Class::null());
4510 RawObject* raw = Object::Allocate(cls, 4511 RawObject* raw = Object::Allocate(LiteralToken::kInstanceKind,
4511 LiteralToken::InstanceSize(), 4512 LiteralToken::InstanceSize(),
4512 Heap::kOld); 4513 Heap::kOld);
4513 return reinterpret_cast<RawLiteralToken*>(raw); 4514 return reinterpret_cast<RawLiteralToken*>(raw);
4514 } 4515 }
4515 4516
4516 4517
4517 RawLiteralToken* LiteralToken::New(Token::Kind kind, const String& literal) { 4518 RawLiteralToken* LiteralToken::New(Token::Kind kind, const String& literal) {
4518 const LiteralToken& result = LiteralToken::Handle(LiteralToken::New()); 4519 const LiteralToken& result = LiteralToken::Handle(LiteralToken::New());
4519 result.set_kind(kind); 4520 result.set_kind(kind);
4520 result.set_literal(literal); 4521 result.set_literal(literal);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
4619 while (index < src_pos && kind != Token::kEOS) { 4620 while (index < src_pos && kind != Token::kEOS) {
4620 iterator.Advance(); 4621 iterator.Advance();
4621 kind = iterator.CurrentTokenKind(); 4622 kind = iterator.CurrentTokenKind();
4622 index += 1; 4623 index += 1;
4623 } 4624 }
4624 return iterator.CurrentPosition(); 4625 return iterator.CurrentPosition();
4625 } 4626 }
4626 4627
4627 4628
4628 RawTokenStream* TokenStream::New(intptr_t len) { 4629 RawTokenStream* TokenStream::New(intptr_t len) {
4629 const Class& token_stream_class = Class::Handle(Object::token_stream_class()); 4630 ASSERT(Object::token_stream_class() != Class::null());
4630 TokenStream& result = TokenStream::Handle(); 4631 TokenStream& result = TokenStream::Handle();
4631 { 4632 {
4632 RawObject* raw = Object::Allocate(token_stream_class, 4633 RawObject* raw = Object::Allocate(TokenStream::kInstanceKind,
4633 TokenStream::InstanceSize(len), 4634 TokenStream::InstanceSize(len),
4634 Heap::kOld); 4635 Heap::kOld);
4635 NoGCScope no_gc; 4636 NoGCScope no_gc;
4636 result ^= raw; 4637 result ^= raw;
4637 result.SetLength(len); 4638 result.SetLength(len);
4638 } 4639 }
4639 return result.raw(); 4640 return result.raw();
4640 } 4641 }
4641 4642
4642 4643
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
4921 Isolate* isolate = Isolate::Current(); 4922 Isolate* isolate = Isolate::Current();
4922 ObjectStore* object_store = isolate->object_store(); 4923 ObjectStore* object_store = isolate->object_store();
4923 String& str = String::Handle(isolate, String::null()); 4924 String& str = String::Handle(isolate, String::null());
4924 const Array& symbols = Array::Handle(isolate, 4925 const Array& symbols = Array::Handle(isolate,
4925 object_store->keyword_symbols()); 4926 object_store->keyword_symbols());
4926 ASSERT(!symbols.IsNull()); 4927 ASSERT(!symbols.IsNull());
4927 str ^= symbols.At(kind - Token::kFirstKeyword); 4928 str ^= symbols.At(kind - Token::kFirstKeyword);
4928 ASSERT(!str.IsNull()); 4929 ASSERT(!str.IsNull());
4929 return str.raw(); 4930 return str.raw();
4930 } 4931 }
4931 return String::NewSymbol(Token::Str(kind)); 4932 return Symbols::New(Token::Str(kind));
4932 } else { 4933 } else {
4933 ASSERT(obj.IsLiteralToken()); // Must be a literal token. 4934 ASSERT(obj.IsLiteralToken()); // Must be a literal token.
4934 const LiteralToken& literal_token = LiteralToken::Cast(obj); 4935 const LiteralToken& literal_token = LiteralToken::Cast(obj);
4935 return literal_token.literal(); 4936 return literal_token.literal();
4936 } 4937 }
4937 } 4938 }
4938 4939
4939 4940
4940 intptr_t TokenStream::Iterator::ReadToken() { 4941 intptr_t TokenStream::Iterator::ReadToken() {
4941 uint8_t b = ReadByte(); 4942 uint8_t b = ReadByte();
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
5059 current_line++; 5060 current_line++;
5060 } else if (src.CharAt(ix) == '\r') { 5061 } else if (src.CharAt(ix) == '\r') {
5061 if ((ix + 1 != src.Length()) && (src.CharAt(ix + 1) != '\n')) { 5062 if ((ix + 1 != src.Length()) && (src.CharAt(ix + 1) != '\n')) {
5062 current_line++; 5063 current_line++;
5063 } 5064 }
5064 } else { 5065 } else {
5065 last_char = ix; 5066 last_char = ix;
5066 } 5067 }
5067 } 5068 }
5068 // Guarantee that returned string is never NULL. 5069 // Guarantee that returned string is never NULL.
5069 String& line = String::Handle(String::NewSymbol("")); 5070 String& line = String::Handle(Symbols::New(""));
5070 if (line_start >= 0) { 5071 if (line_start >= 0) {
5071 line = String::SubString(src, line_start, last_char - line_start + 1); 5072 line = String::SubString(src, line_start, last_char - line_start + 1);
5072 } 5073 }
5073 return line.raw(); 5074 return line.raw();
5074 } 5075 }
5075 5076
5076 5077
5077 RawString* Script::GetSnippet(intptr_t from_line, 5078 RawString* Script::GetSnippet(intptr_t from_line,
5078 intptr_t from_column, 5079 intptr_t from_column,
5079 intptr_t to_line, 5080 intptr_t to_line,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
5116 String& snippet = String::Handle(); 5117 String& snippet = String::Handle();
5117 if ((snippet_start != -1) && (snippet_end != -1)) { 5118 if ((snippet_start != -1) && (snippet_end != -1)) {
5118 snippet = 5119 snippet =
5119 String::SubString(src, snippet_start, snippet_end - snippet_start); 5120 String::SubString(src, snippet_start, snippet_end - snippet_start);
5120 } 5121 }
5121 return snippet.raw(); 5122 return snippet.raw();
5122 } 5123 }
5123 5124
5124 5125
5125 RawScript* Script::New() { 5126 RawScript* Script::New() {
5126 const Class& script_class = Class::Handle(Object::script_class()); 5127 ASSERT(Object::script_class() != Class::null());
5127 RawObject* raw = Object::Allocate(script_class, 5128 RawObject* raw = Object::Allocate(Script::kInstanceKind,
5128 Script::InstanceSize(), 5129 Script::InstanceSize(),
5129 Heap::kOld); 5130 Heap::kOld);
5130 return reinterpret_cast<RawScript*>(raw); 5131 return reinterpret_cast<RawScript*>(raw);
5131 } 5132 }
5132 5133
5133 5134
5134 RawScript* Script::New(const String& url, 5135 RawScript* Script::New(const String& url,
5135 const String& source, 5136 const String& source,
5136 RawScript::Kind kind) { 5137 RawScript::Kind kind) {
5137 const Script& result = Script::Handle(Script::New()); 5138 const Script& result = Script::Handle(Script::New());
5138 result.set_url(String::Handle(String::NewSymbol(url))); 5139 result.set_url(String::Handle(Symbols::New(url)));
5139 result.set_source(source); 5140 result.set_source(source);
5140 result.set_kind(kind); 5141 result.set_kind(kind);
5141 return result.raw(); 5142 return result.raw();
5142 } 5143 }
5143 5144
5144 5145
5145 const char* Script::ToCString() const { 5146 const char* Script::ToCString() const {
5146 return "Script"; 5147 return "Script";
5147 } 5148 }
5148 5149
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
5924 5925
5925 void Library::InitImportedIntoList() const { 5926 void Library::InitImportedIntoList() const {
5926 const Array& imported_into = 5927 const Array& imported_into =
5927 Array::Handle(Array::New(kInitialImportedIntoCapacity, Heap::kOld)); 5928 Array::Handle(Array::New(kInitialImportedIntoCapacity, Heap::kOld));
5928 StorePointer(&raw_ptr()->imported_into_, imported_into.raw()); 5929 StorePointer(&raw_ptr()->imported_into_, imported_into.raw());
5929 raw_ptr()->num_imported_into_ = 0; 5930 raw_ptr()->num_imported_into_ = 0;
5930 } 5931 }
5931 5932
5932 5933
5933 RawLibrary* Library::New() { 5934 RawLibrary* Library::New() {
5934 const Class& library_class = Class::Handle(Object::library_class()); 5935 ASSERT(Object::library_class() != Class::null());
5935 RawObject* raw = Object::Allocate(library_class, 5936 RawObject* raw = Object::Allocate(Library::kInstanceKind,
5936 Library::InstanceSize(), 5937 Library::InstanceSize(),
5937 Heap::kOld); 5938 Heap::kOld);
5938 return reinterpret_cast<RawLibrary*>(raw); 5939 return reinterpret_cast<RawLibrary*>(raw);
5939 } 5940 }
5940 5941
5941 5942
5942 RawLibrary* Library::NewLibraryHelper(const String& url, 5943 RawLibrary* Library::NewLibraryHelper(const String& url,
5943 bool import_core_lib) { 5944 bool import_core_lib) {
5944 const Library& result = Library::Handle(Library::New()); 5945 const Library& result = Library::Handle(Library::New());
5945 result.StorePointer(&result.raw_ptr()->name_, url.raw()); 5946 result.StorePointer(&result.raw_ptr()->name_, url.raw());
(...skipping 20 matching lines...) Expand all
5966 return result.raw(); 5967 return result.raw();
5967 } 5968 }
5968 5969
5969 5970
5970 RawLibrary* Library::New(const String& url) { 5971 RawLibrary* Library::New(const String& url) {
5971 return NewLibraryHelper(url, true); 5972 return NewLibraryHelper(url, true);
5972 } 5973 }
5973 5974
5974 5975
5975 void Library::InitCoreLibrary(Isolate* isolate) { 5976 void Library::InitCoreLibrary(Isolate* isolate) {
5976 const String& core_lib_url = String::Handle(String::NewSymbol("dart:core")); 5977 const String& core_lib_url = String::Handle(Symbols::New("dart:core"));
5977 const Library& core_lib = 5978 const Library& core_lib =
5978 Library::Handle(Library::NewLibraryHelper(core_lib_url, false)); 5979 Library::Handle(Library::NewLibraryHelper(core_lib_url, false));
5979 core_lib.Register(); 5980 core_lib.Register();
5980 isolate->object_store()->set_core_library(core_lib); 5981 isolate->object_store()->set_core_library(core_lib);
5981 const String& core_impl_lib_url = 5982 const String& core_impl_lib_url =
5982 String::Handle(String::NewSymbol("dart:coreimpl")); 5983 String::Handle(Symbols::New("dart:coreimpl"));
5983 const Library& core_impl_lib = 5984 const Library& core_impl_lib =
5984 Library::Handle(Library::NewLibraryHelper(core_impl_lib_url, false)); 5985 Library::Handle(Library::NewLibraryHelper(core_impl_lib_url, false));
5985 isolate->object_store()->set_core_impl_library(core_impl_lib); 5986 isolate->object_store()->set_core_impl_library(core_impl_lib);
5986 core_impl_lib.Register(); 5987 core_impl_lib.Register();
5987 core_lib.AddImport(core_impl_lib); 5988 core_lib.AddImport(core_impl_lib);
5988 core_impl_lib.AddImport(core_lib); 5989 core_impl_lib.AddImport(core_lib);
5989 isolate->object_store()->set_root_library(Library::Handle()); 5990 isolate->object_store()->set_root_library(Library::Handle());
5990 } 5991 }
5991 5992
5992 5993
5993 void Library::InitMathLibrary(Isolate* isolate) { 5994 void Library::InitMathLibrary(Isolate* isolate) {
5994 const String& url = String::Handle(String::NewSymbol("dart:math")); 5995 const String& url = String::Handle(Symbols::New("dart:math"));
5995 const Library& lib = Library::Handle(Library::New(url)); 5996 const Library& lib = Library::Handle(Library::New(url));
5996 lib.Register(); 5997 lib.Register();
5997 const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary()); 5998 const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary());
5998 lib.AddImport(core_impl_lib); 5999 lib.AddImport(core_impl_lib);
5999 isolate->object_store()->set_math_library(lib); 6000 isolate->object_store()->set_math_library(lib);
6000 } 6001 }
6001 6002
6002 6003
6003 void Library::InitIsolateLibrary(Isolate* isolate) { 6004 void Library::InitIsolateLibrary(Isolate* isolate) {
6004 const String& url = String::Handle(String::NewSymbol("dart:isolate")); 6005 const String& url = String::Handle(Symbols::New("dart:isolate"));
6005 const Library& lib = Library::Handle(Library::New(url)); 6006 const Library& lib = Library::Handle(Library::New(url));
6006 lib.Register(); 6007 lib.Register();
6007 isolate->object_store()->set_isolate_library(lib); 6008 isolate->object_store()->set_isolate_library(lib);
6008 } 6009 }
6009 6010
6010 6011
6011 void Library::InitMirrorsLibrary(Isolate* isolate) { 6012 void Library::InitMirrorsLibrary(Isolate* isolate) {
6012 const String& url = String::Handle(String::NewSymbol("dart:mirrors")); 6013 const String& url = String::Handle(Symbols::New("dart:mirrors"));
6013 const Library& lib = Library::Handle(Library::New(url)); 6014 const Library& lib = Library::Handle(Library::New(url));
6014 lib.Register(); 6015 lib.Register();
6015 const Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); 6016 const Library& isolate_lib = Library::Handle(Library::IsolateLibrary());
6016 lib.AddImport(isolate_lib); 6017 lib.AddImport(isolate_lib);
6017 const Library& wrappers_lib = 6018 const Library& wrappers_lib =
6018 Library::Handle(Library::NativeWrappersLibrary()); 6019 Library::Handle(Library::NativeWrappersLibrary());
6019 lib.AddImport(wrappers_lib); 6020 lib.AddImport(wrappers_lib);
6020 isolate->object_store()->set_mirrors_library(lib); 6021 isolate->object_store()->set_mirrors_library(lib);
6021 } 6022 }
6022 6023
6023 6024
6024 void Library::InitNativeWrappersLibrary(Isolate* isolate) { 6025 void Library::InitNativeWrappersLibrary(Isolate* isolate) {
6025 static const int kNumNativeWrappersClasses = 4; 6026 static const int kNumNativeWrappersClasses = 4;
6026 ASSERT(kNumNativeWrappersClasses > 0 && kNumNativeWrappersClasses < 10); 6027 ASSERT(kNumNativeWrappersClasses > 0 && kNumNativeWrappersClasses < 10);
6027 const String& native_flds_lib_url = String::Handle( 6028 const String& native_flds_lib_url = String::Handle(
6028 String::NewSymbol("dart:nativewrappers")); 6029 Symbols::New("dart:nativewrappers"));
6029 Library& native_flds_lib = Library::Handle( 6030 Library& native_flds_lib = Library::Handle(
6030 Library::NewLibraryHelper(native_flds_lib_url, false)); 6031 Library::NewLibraryHelper(native_flds_lib_url, false));
6031 native_flds_lib.Register(); 6032 native_flds_lib.Register();
6032 isolate->object_store()->set_native_wrappers_library(native_flds_lib); 6033 isolate->object_store()->set_native_wrappers_library(native_flds_lib);
6033 static const char* const kNativeWrappersClass = "NativeFieldWrapperClass"; 6034 static const char* const kNativeWrappersClass = "NativeFieldWrapperClass";
6034 static const int kNameLength = 25; 6035 static const int kNameLength = 25;
6035 ASSERT(kNameLength == (strlen(kNativeWrappersClass) + 1 + 1)); 6036 ASSERT(kNameLength == (strlen(kNativeWrappersClass) + 1 + 1));
6036 char name_buffer[kNameLength]; 6037 char name_buffer[kNameLength];
6037 String& cls_name = String::Handle(); 6038 String& cls_name = String::Handle();
6038 for (int fld_cnt = 1; fld_cnt <= kNumNativeWrappersClasses; fld_cnt++) { 6039 for (int fld_cnt = 1; fld_cnt <= kNumNativeWrappersClasses; fld_cnt++) {
6039 OS::SNPrint(name_buffer, 6040 OS::SNPrint(name_buffer,
6040 kNameLength, 6041 kNameLength,
6041 "%s%d", 6042 "%s%d",
6042 kNativeWrappersClass, 6043 kNativeWrappersClass,
6043 fld_cnt); 6044 fld_cnt);
6044 cls_name = String::NewSymbol(name_buffer); 6045 cls_name = Symbols::New(name_buffer);
6045 Class::NewNativeWrapper(&native_flds_lib, cls_name, fld_cnt); 6046 Class::NewNativeWrapper(&native_flds_lib, cls_name, fld_cnt);
6046 } 6047 }
6047 } 6048 }
6048 6049
6049 6050
6050 RawLibrary* Library::LookupLibrary(const String &url) { 6051 RawLibrary* Library::LookupLibrary(const String &url) {
6051 Isolate* isolate = Isolate::Current(); 6052 Isolate* isolate = Isolate::Current();
6052 Library& lib = Library::Handle(isolate, Library::null()); 6053 Library& lib = Library::Handle(isolate, Library::null());
6053 String& lib_url = String::Handle(isolate, String::null()); 6054 String& lib_url = String::Handle(isolate, String::null());
6054 GrowableObjectArray& libs = GrowableObjectArray::Handle( 6055 GrowableObjectArray& libs = GrowableObjectArray::Handle(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
6101 return false; 6102 return false;
6102 } 6103 }
6103 6104
6104 6105
6105 RawString* Library::PrivateName(const String& name) const { 6106 RawString* Library::PrivateName(const String& name) const {
6106 ASSERT(ShouldBePrivate(name)); 6107 ASSERT(ShouldBePrivate(name));
6107 // ASSERT(strchr(name, '@') == NULL); 6108 // ASSERT(strchr(name, '@') == NULL);
6108 String& str = String::Handle(); 6109 String& str = String::Handle();
6109 str ^= name.raw(); 6110 str ^= name.raw();
6110 str = String::Concat(str, String::Handle(this->private_key())); 6111 str = String::Concat(str, String::Handle(this->private_key()));
6111 str = String::NewSymbol(str); 6112 str = Symbols::New(str);
6112 return str.raw(); 6113 return str.raw();
6113 } 6114 }
6114 6115
6115 6116
6116 RawLibrary* Library::GetLibrary(intptr_t index) { 6117 RawLibrary* Library::GetLibrary(intptr_t index) {
6117 Isolate* isolate = Isolate::Current(); 6118 Isolate* isolate = Isolate::Current();
6118 const GrowableObjectArray& libs = 6119 const GrowableObjectArray& libs =
6119 GrowableObjectArray::Handle(isolate->object_store()->libraries()); 6120 GrowableObjectArray::Handle(isolate->object_store()->libraries());
6120 ASSERT(!libs.IsNull()); 6121 ASSERT(!libs.IsNull());
6121 if ((0 <= index) && (index < libs.Length())) { 6122 if ((0 <= index) && (index < libs.Length())) {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
6239 resolved_class = lib.LookupLocalClass(class_name); 6240 resolved_class = lib.LookupLocalClass(class_name);
6240 if (!resolved_class.IsNull()) { 6241 if (!resolved_class.IsNull()) {
6241 return resolved_class.raw(); 6242 return resolved_class.raw();
6242 } 6243 }
6243 } 6244 }
6244 return Class::null(); 6245 return Class::null();
6245 } 6246 }
6246 6247
6247 6248
6248 RawLibraryPrefix* LibraryPrefix::New() { 6249 RawLibraryPrefix* LibraryPrefix::New() {
6249 const Class& library_prefix_class = 6250 ASSERT(Object::library_prefix_class() != Class::null());
6250 Class::Handle(Object::library_prefix_class()); 6251 RawObject* raw = Object::Allocate(LibraryPrefix::kInstanceKind,
6251 RawObject* raw = Object::Allocate(library_prefix_class,
6252 LibraryPrefix::InstanceSize(), 6252 LibraryPrefix::InstanceSize(),
6253 Heap::kOld); 6253 Heap::kOld);
6254 return reinterpret_cast<RawLibraryPrefix*>(raw); 6254 return reinterpret_cast<RawLibraryPrefix*>(raw);
6255 } 6255 }
6256 6256
6257 6257
6258 RawLibraryPrefix* LibraryPrefix::New(const String& name, const Library& lib) { 6258 RawLibraryPrefix* LibraryPrefix::New(const String& name, const Library& lib) {
6259 const LibraryPrefix& result = LibraryPrefix::Handle(LibraryPrefix::New()); 6259 const LibraryPrefix& result = LibraryPrefix::Handle(LibraryPrefix::New());
6260 result.set_name(name); 6260 result.set_name(name);
6261 result.set_num_libs(0); 6261 result.set_num_libs(0);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
6366 if (!error.IsNull()) { 6366 if (!error.IsNull()) {
6367 return error.raw(); 6367 return error.raw();
6368 } 6368 }
6369 } 6369 }
6370 } 6370 }
6371 return error.raw(); 6371 return error.raw();
6372 } 6372 }
6373 6373
6374 6374
6375 RawInstructions* Instructions::New(intptr_t size) { 6375 RawInstructions* Instructions::New(intptr_t size) {
6376 const Class& instructions_class = Class::Handle(Object::instructions_class()); 6376 ASSERT(Object::instructions_class() != Class::null());
6377 Instructions& result = Instructions::Handle(); 6377 Instructions& result = Instructions::Handle();
6378 { 6378 {
6379 uword aligned_size = Instructions::InstanceSize(size); 6379 uword aligned_size = Instructions::InstanceSize(size);
6380 RawObject* raw = Object::Allocate(instructions_class, 6380 RawObject* raw = Object::Allocate(Instructions::kInstanceKind,
6381 aligned_size, 6381 aligned_size,
6382 Heap::kCode); 6382 Heap::kCode);
6383 NoGCScope no_gc; 6383 NoGCScope no_gc;
6384 // TODO(iposva): Remove premarking once old and code spaces are merged. 6384 // TODO(iposva): Remove premarking once old and code spaces are merged.
6385 raw->SetMarkBit(); 6385 raw->SetMarkBit();
6386 result ^= raw; 6386 result ^= raw;
6387 result.set_size(size); 6387 result.set_size(size);
6388 } 6388 }
6389 return result.raw(); 6389 return result.raw();
6390 } 6390 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
6451 return *(EntryAddr(index, kTryIndexEntry)); 6451 return *(EntryAddr(index, kTryIndexEntry));
6452 } 6452 }
6453 6453
6454 6454
6455 void PcDescriptors::SetTryIndex(intptr_t index, intptr_t value) const { 6455 void PcDescriptors::SetTryIndex(intptr_t index, intptr_t value) const {
6456 *(EntryAddr(index, kTryIndexEntry)) = value; 6456 *(EntryAddr(index, kTryIndexEntry)) = value;
6457 } 6457 }
6458 6458
6459 6459
6460 RawPcDescriptors* PcDescriptors::New(intptr_t num_descriptors) { 6460 RawPcDescriptors* PcDescriptors::New(intptr_t num_descriptors) {
6461 const Class& cls = Class::Handle(Object::pc_descriptors_class()); 6461 ASSERT(Object::pc_descriptors_class() != Class::null());
6462 PcDescriptors& result = PcDescriptors::Handle(); 6462 PcDescriptors& result = PcDescriptors::Handle();
6463 { 6463 {
6464 uword size = PcDescriptors::InstanceSize(num_descriptors); 6464 uword size = PcDescriptors::InstanceSize(num_descriptors);
6465 RawObject* raw = Object::Allocate(cls, size, Heap::kOld); 6465 RawObject* raw = Object::Allocate(PcDescriptors::kInstanceKind,
6466 size,
6467 Heap::kOld);
6466 NoGCScope no_gc; 6468 NoGCScope no_gc;
6467 result ^= raw; 6469 result ^= raw;
6468 result.SetLength(num_descriptors); 6470 result.SetLength(num_descriptors);
6469 } 6471 }
6470 return result.raw(); 6472 return result.raw();
6471 } 6473 }
6472 6474
6473 6475
6474 const char* PcDescriptors::KindAsStr(intptr_t index) const { 6476 const char* PcDescriptors::KindAsStr(intptr_t index) const {
6475 switch (DescriptorKind(index)) { 6477 switch (DescriptorKind(index)) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
6572 uint8_t* byte_addr = &(raw_ptr()->data_[byte_offset]); 6574 uint8_t* byte_addr = &(raw_ptr()->data_[byte_offset]);
6573 if (value) { 6575 if (value) {
6574 *byte_addr |= byte_mask; 6576 *byte_addr |= byte_mask;
6575 } else { 6577 } else {
6576 *byte_addr &= ~byte_mask; 6578 *byte_addr &= ~byte_mask;
6577 } 6579 }
6578 } 6580 }
6579 6581
6580 6582
6581 RawStackmap* Stackmap::New(uword pc_offset, BitmapBuilder* bmap) { 6583 RawStackmap* Stackmap::New(uword pc_offset, BitmapBuilder* bmap) {
6582 const Class& cls = Class::Handle(Object::stackmap_class()); 6584 ASSERT(Object::stackmap_class() != Class::null());
6583 ASSERT(!cls.IsNull());
6584 ASSERT(bmap != NULL); 6585 ASSERT(bmap != NULL);
6585 Stackmap& result = Stackmap::Handle(); 6586 Stackmap& result = Stackmap::Handle();
6586 intptr_t size = bmap->SizeInBytes(); 6587 intptr_t size = bmap->SizeInBytes();
6587 { 6588 {
6588 // Stackmap data objects are associated with a code object, allocate them 6589 // Stackmap data objects are associated with a code object, allocate them
6589 // in old generation. 6590 // in old generation.
6590 RawObject* raw = 6591 RawObject* raw = Object::Allocate(Stackmap::kInstanceKind,
6591 Object::Allocate(cls, Stackmap::InstanceSize(size), Heap::kOld); 6592 Stackmap::InstanceSize(size),
6593 Heap::kOld);
6592 NoGCScope no_gc; 6594 NoGCScope no_gc;
6593 result ^= raw; 6595 result ^= raw;
6594 result.set_bitmap_size_in_bytes(size); 6596 result.set_bitmap_size_in_bytes(size);
6595 } 6597 }
6596 result.SetPC(pc_offset); 6598 result.SetPC(pc_offset);
6597 intptr_t bound = bmap->SizeInBits(); 6599 intptr_t bound = bmap->SizeInBits();
6598 for (intptr_t i = 0; i < bound; i++) { 6600 for (intptr_t i = 0; i < bound; i++) {
6599 result.SetBit(i, bmap->Get(i)); 6601 result.SetBit(i, bmap->Get(i));
6600 } 6602 }
6601 result.SetMinBitOffset(bmap->Minimum()); 6603 result.SetMinBitOffset(bmap->Minimum());
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
6661 } 6663 }
6662 6664
6663 6665
6664 const char* LocalVarDescriptors::ToCString() const { 6666 const char* LocalVarDescriptors::ToCString() const {
6665 UNIMPLEMENTED(); 6667 UNIMPLEMENTED();
6666 return "LocalVarDescriptors"; 6668 return "LocalVarDescriptors";
6667 } 6669 }
6668 6670
6669 6671
6670 RawLocalVarDescriptors* LocalVarDescriptors::New(intptr_t num_variables) { 6672 RawLocalVarDescriptors* LocalVarDescriptors::New(intptr_t num_variables) {
6671 const Class& cls = Class::Handle(Object::var_descriptors_class()); 6673 ASSERT(Object::var_descriptors_class() != Class::null());
6672 LocalVarDescriptors& result = LocalVarDescriptors::Handle(); 6674 LocalVarDescriptors& result = LocalVarDescriptors::Handle();
6673 { 6675 {
6674 uword size = LocalVarDescriptors::InstanceSize(num_variables); 6676 uword size = LocalVarDescriptors::InstanceSize(num_variables);
6675 RawObject* raw = Object::Allocate(cls, size, Heap::kOld); 6677 RawObject* raw = Object::Allocate(LocalVarDescriptors::kInstanceKind,
6678 size,
6679 Heap::kOld);
6676 NoGCScope no_gc; 6680 NoGCScope no_gc;
6677 result ^= raw; 6681 result ^= raw;
6678 result.raw_ptr()->length_ = num_variables; 6682 result.raw_ptr()->length_ = num_variables;
6679 } 6683 }
6680 const Array& names = Array::Handle(Array::New(num_variables, Heap::kOld)); 6684 const Array& names = Array::Handle(Array::New(num_variables, Heap::kOld));
6681 result.raw_ptr()->names_ = names.raw(); 6685 result.raw_ptr()->names_ = names.raw();
6682 return result.raw(); 6686 return result.raw();
6683 } 6687 }
6684 6688
6685 6689
(...skipping 29 matching lines...) Expand all
6715 } 6719 }
6716 6720
6717 6721
6718 void ExceptionHandlers::SetHandlerPC(intptr_t index, 6722 void ExceptionHandlers::SetHandlerPC(intptr_t index,
6719 intptr_t value) const { 6723 intptr_t value) const {
6720 *(EntryAddr(index, kHandlerPcEntry)) = value; 6724 *(EntryAddr(index, kHandlerPcEntry)) = value;
6721 } 6725 }
6722 6726
6723 6727
6724 RawExceptionHandlers* ExceptionHandlers::New(intptr_t num_handlers) { 6728 RawExceptionHandlers* ExceptionHandlers::New(intptr_t num_handlers) {
6725 const Class& cls = Class::Handle(Object::exception_handlers_class()); 6729 ASSERT(Object::exception_handlers_class() != Class::null());
6726 ExceptionHandlers& result = ExceptionHandlers::Handle(); 6730 ExceptionHandlers& result = ExceptionHandlers::Handle();
6727 { 6731 {
6728 uword size = ExceptionHandlers::InstanceSize(num_handlers); 6732 uword size = ExceptionHandlers::InstanceSize(num_handlers);
6729 RawObject* raw = Object::Allocate(cls, size, Heap::kOld); 6733 RawObject* raw = Object::Allocate(ExceptionHandlers::kInstanceKind,
6734 size,
6735 Heap::kOld);
6730 NoGCScope no_gc; 6736 NoGCScope no_gc;
6731 result ^= raw; 6737 result ^= raw;
6732 result.SetLength(num_handlers); 6738 result.SetLength(num_handlers);
6733 } 6739 }
6734 return result.raw(); 6740 return result.raw();
6735 } 6741 }
6736 6742
6737 6743
6738 const char* ExceptionHandlers::ToCString() const { 6744 const char* ExceptionHandlers::ToCString() const {
6739 if (Length() == 0) { 6745 if (Length() == 0) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
6818 return *comments; 6824 return *comments;
6819 } 6825 }
6820 6826
6821 6827
6822 void Code::set_comments(const Code::Comments& comments) const { 6828 void Code::set_comments(const Code::Comments& comments) const {
6823 StorePointer(&raw_ptr()->comments_, comments.comments_.raw()); 6829 StorePointer(&raw_ptr()->comments_, comments.comments_.raw());
6824 } 6830 }
6825 6831
6826 6832
6827 RawCode* Code::New(int pointer_offsets_length) { 6833 RawCode* Code::New(int pointer_offsets_length) {
6828 const Class& cls = Class::Handle(Object::code_class()); 6834 ASSERT(Object::code_class() != Class::null());
6829 Code& result = Code::Handle(); 6835 Code& result = Code::Handle();
6830 { 6836 {
6831 uword size = Code::InstanceSize(pointer_offsets_length); 6837 uword size = Code::InstanceSize(pointer_offsets_length);
6832 RawObject* raw = Object::Allocate(cls, size, Heap::kOld); 6838 RawObject* raw = Object::Allocate(Code::kInstanceKind, size, Heap::kOld);
6833 NoGCScope no_gc; 6839 NoGCScope no_gc;
6834 result ^= raw; 6840 result ^= raw;
6835 result.set_pointer_offsets_length(pointer_offsets_length); 6841 result.set_pointer_offsets_length(pointer_offsets_length);
6836 result.set_is_optimized(false); 6842 result.set_is_optimized(false);
6837 result.set_comments(Comments::New(0)); 6843 result.set_comments(Comments::New(0));
6838 } 6844 }
6839 return result.raw(); 6845 return result.raw();
6840 } 6846 }
6841 6847
6842 6848
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
7046 break; 7052 break;
7047 } 7053 }
7048 previous_map = map->raw(); 7054 previous_map = map->raw();
7049 } 7055 }
7050 return map->raw(); 7056 return map->raw();
7051 } 7057 }
7052 7058
7053 7059
7054 RawContext* Context::New(intptr_t num_variables, Heap::Space space) { 7060 RawContext* Context::New(intptr_t num_variables, Heap::Space space) {
7055 ASSERT(num_variables >= 0); 7061 ASSERT(num_variables >= 0);
7062 ASSERT(Object::context_class() != Class::null());
7056 7063
7057 const Class& context_class = Class::Handle(Object::context_class());
7058 Context& result = Context::Handle(); 7064 Context& result = Context::Handle();
7059 { 7065 {
7060 RawObject* raw = Object::Allocate(context_class, 7066 RawObject* raw = Object::Allocate(Context::kInstanceKind,
7061 Context::InstanceSize(num_variables), 7067 Context::InstanceSize(num_variables),
7062 space); 7068 space);
7063 NoGCScope no_gc; 7069 NoGCScope no_gc;
7064 result ^= raw; 7070 result ^= raw;
7065 result.set_num_variables(num_variables); 7071 result.set_num_variables(num_variables);
7066 } 7072 }
7067 result.set_isolate(Isolate::Current()); 7073 result.set_isolate(Isolate::Current());
7068 return result.raw(); 7074 return result.raw();
7069 } 7075 }
7070 7076
7071 7077
7072 const char* Context::ToCString() const { 7078 const char* Context::ToCString() const {
7073 return "Context"; 7079 return "Context";
7074 } 7080 }
7075 7081
7076 7082
7077 RawContextScope* ContextScope::New(intptr_t num_variables) { 7083 RawContextScope* ContextScope::New(intptr_t num_variables) {
7078 const Class& context_scope_class = 7084 ASSERT(Object::context_scope_class() != Class::null());
7079 Class::Handle(Object::context_scope_class());
7080 intptr_t size = ContextScope::InstanceSize(num_variables); 7085 intptr_t size = ContextScope::InstanceSize(num_variables);
7081 ContextScope& result = ContextScope::Handle(); 7086 ContextScope& result = ContextScope::Handle();
7082 { 7087 {
7083 RawObject* raw = Object::Allocate(context_scope_class, size, Heap::kOld); 7088 RawObject* raw = Object::Allocate(ContextScope::kInstanceKind,
7089 size,
7090 Heap::kOld);
7084 NoGCScope no_gc; 7091 NoGCScope no_gc;
7085 result ^= raw; 7092 result ^= raw;
7086 result.set_num_variables(num_variables); 7093 result.set_num_variables(num_variables);
7087 } 7094 }
7088 return result.raw(); 7095 return result.raw();
7089 } 7096 }
7090 7097
7091 7098
7092 intptr_t ContextScope::TokenIndexAt(intptr_t scope_index) const { 7099 intptr_t ContextScope::TokenIndexAt(intptr_t scope_index) const {
7093 return Smi::Value(VariableDescAddr(scope_index)->token_pos); 7100 return Smi::Value(VariableDescAddr(scope_index)->token_pos);
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
7344 } 7351 }
7345 } 7352 }
7346 return result.raw(); 7353 return result.raw();
7347 } 7354 }
7348 7355
7349 7356
7350 RawICData* ICData::New(const Function& function, 7357 RawICData* ICData::New(const Function& function,
7351 const String& target_name, 7358 const String& target_name,
7352 intptr_t id, 7359 intptr_t id,
7353 intptr_t num_args_tested) { 7360 intptr_t num_args_tested) {
7361 ASSERT(Object::icdata_class() != Class::null());
7354 ASSERT(num_args_tested > 0); 7362 ASSERT(num_args_tested > 0);
7355 const Class& cls = Class::Handle(Object::icdata_class());
7356 ASSERT(!cls.IsNull());
7357 ICData& result = ICData::Handle(); 7363 ICData& result = ICData::Handle();
7358 { 7364 {
7359 // IC data objects are long living objects, allocate them in old generation. 7365 // IC data objects are long living objects, allocate them in old generation.
7360 RawObject* raw = Object::Allocate(cls, ICData::InstanceSize(), Heap::kOld); 7366 RawObject* raw = Object::Allocate(ICData::kInstanceKind,
7367 ICData::InstanceSize(),
7368 Heap::kOld);
7361 NoGCScope no_gc; 7369 NoGCScope no_gc;
7362 result ^= raw; 7370 result ^= raw;
7363 } 7371 }
7364 result.set_function(function); 7372 result.set_function(function);
7365 result.set_target_name(target_name); 7373 result.set_target_name(target_name);
7366 result.set_id(id); 7374 result.set_id(id);
7367 result.set_num_args_tested(num_args_tested); 7375 result.set_num_args_tested(num_args_tested);
7368 // Number of array elements in one test entry (num_args_tested + 1) 7376 // Number of array elements in one test entry (num_args_tested + 1)
7369 intptr_t len = result.TestEntryLength(); 7377 intptr_t len = result.TestEntryLength();
7370 // IC data array must be null terminated (sentinel entry). 7378 // IC data array must be null terminated (sentinel entry).
7371 const Array& ic_data = Array::Handle(Array::New(len, Heap::kOld)); 7379 const Array& ic_data = Array::Handle(Array::New(len, Heap::kOld));
7372 result.set_ic_data(ic_data); 7380 result.set_ic_data(ic_data);
7373 return result.raw(); 7381 return result.raw();
7374 } 7382 }
7375 7383
7376 7384
7377 RawSubtypeTestCache* SubtypeTestCache::New() { 7385 RawSubtypeTestCache* SubtypeTestCache::New() {
7378 const Class& cls = Class::Handle(Object::subtypetestcache_class()); 7386 ASSERT(Object::subtypetestcache_class() != Class::null());
7379 ASSERT(!cls.IsNull());
7380 SubtypeTestCache& result = SubtypeTestCache::Handle(); 7387 SubtypeTestCache& result = SubtypeTestCache::Handle();
7381 { 7388 {
7382 // SubtypeTestCache objects are long living objects, allocate them in the 7389 // SubtypeTestCache objects are long living objects, allocate them in the
7383 // old generation. 7390 // old generation.
7384 RawObject* raw = 7391 RawObject* raw = Object::Allocate(SubtypeTestCache::kInstanceKind,
7385 Object::Allocate(cls, SubtypeTestCache::InstanceSize(), Heap::kOld); 7392 SubtypeTestCache::InstanceSize(),
7393 Heap::kOld);
7386 NoGCScope no_gc; 7394 NoGCScope no_gc;
7387 result ^= raw; 7395 result ^= raw;
7388 } 7396 }
7389 const Array& cache = Array::Handle(Array::New(kTestEntryLength)); 7397 const Array& cache = Array::Handle(Array::New(kTestEntryLength));
7390 result.set_cache(cache); 7398 result.set_cache(cache);
7391 return result.raw(); 7399 return result.raw();
7392 } 7400 }
7393 7401
7394 7402
7395 void SubtypeTestCache::set_cache(const Array& value) const { 7403 void SubtypeTestCache::set_cache(const Array& value) const {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
7453 7461
7454 7462
7455 const char* Error::ToCString() const { 7463 const char* Error::ToCString() const {
7456 // Error is an abstract class. We should never reach here. 7464 // Error is an abstract class. We should never reach here.
7457 UNREACHABLE(); 7465 UNREACHABLE();
7458 return "Error"; 7466 return "Error";
7459 } 7467 }
7460 7468
7461 7469
7462 RawApiError* ApiError::New(const String& message, Heap::Space space) { 7470 RawApiError* ApiError::New(const String& message, Heap::Space space) {
7463 const Class& cls = Class::Handle(Object::api_error_class()); 7471 ASSERT(Object::api_error_class() != Class::null());
7464 ApiError& result = ApiError::Handle(); 7472 ApiError& result = ApiError::Handle();
7465 { 7473 {
7466 RawObject* raw = Object::Allocate(cls, 7474 RawObject* raw = Object::Allocate(ApiError::kInstanceKind,
7467 ApiError::InstanceSize(), 7475 ApiError::InstanceSize(),
7468 space); 7476 space);
7469 NoGCScope no_gc; 7477 NoGCScope no_gc;
7470 result ^= raw; 7478 result ^= raw;
7471 } 7479 }
7472 result.set_message(message); 7480 result.set_message(message);
7473 return result.raw(); 7481 return result.raw();
7474 } 7482 }
7475 7483
7476 7484
7477 void ApiError::set_message(const String& message) const { 7485 void ApiError::set_message(const String& message) const {
7478 StorePointer(&raw_ptr()->message_, message.raw()); 7486 StorePointer(&raw_ptr()->message_, message.raw());
7479 } 7487 }
7480 7488
7481 7489
7482 const char* ApiError::ToErrorCString() const { 7490 const char* ApiError::ToErrorCString() const {
7483 const String& msg_str = String::Handle(message()); 7491 const String& msg_str = String::Handle(message());
7484 return msg_str.ToCString(); 7492 return msg_str.ToCString();
7485 } 7493 }
7486 7494
7487 7495
7488 const char* ApiError::ToCString() const { 7496 const char* ApiError::ToCString() const {
7489 return "ApiError"; 7497 return "ApiError";
7490 } 7498 }
7491 7499
7492 7500
7493 RawLanguageError* LanguageError::New(const String& message, Heap::Space space) { 7501 RawLanguageError* LanguageError::New(const String& message, Heap::Space space) {
7494 const Class& cls = Class::Handle(Object::language_error_class()); 7502 ASSERT(Object::language_error_class() != Class::null());
7495 LanguageError& result = LanguageError::Handle(); 7503 LanguageError& result = LanguageError::Handle();
7496 { 7504 {
7497 RawObject* raw = Object::Allocate(cls, 7505 RawObject* raw = Object::Allocate(LanguageError::kInstanceKind,
7498 LanguageError::InstanceSize(), 7506 LanguageError::InstanceSize(),
7499 space); 7507 space);
7500 NoGCScope no_gc; 7508 NoGCScope no_gc;
7501 result ^= raw; 7509 result ^= raw;
7502 } 7510 }
7503 result.set_message(message); 7511 result.set_message(message);
7504 return result.raw(); 7512 return result.raw();
7505 } 7513 }
7506 7514
7507 7515
7508 void LanguageError::set_message(const String& message) const { 7516 void LanguageError::set_message(const String& message) const {
7509 StorePointer(&raw_ptr()->message_, message.raw()); 7517 StorePointer(&raw_ptr()->message_, message.raw());
7510 } 7518 }
7511 7519
7512 7520
7513 const char* LanguageError::ToErrorCString() const { 7521 const char* LanguageError::ToErrorCString() const {
7514 const String& msg_str = String::Handle(message()); 7522 const String& msg_str = String::Handle(message());
7515 return msg_str.ToCString(); 7523 return msg_str.ToCString();
7516 } 7524 }
7517 7525
7518 7526
7519 const char* LanguageError::ToCString() const { 7527 const char* LanguageError::ToCString() const {
7520 return "LanguageError"; 7528 return "LanguageError";
7521 } 7529 }
7522 7530
7523 7531
7524 RawUnhandledException* UnhandledException::New(const Instance& exception, 7532 RawUnhandledException* UnhandledException::New(const Instance& exception,
7525 const Instance& stacktrace, 7533 const Instance& stacktrace,
7526 Heap::Space space) { 7534 Heap::Space space) {
7527 const Class& cls = Class::Handle(Object::unhandled_exception_class()); 7535 ASSERT(Object::unhandled_exception_class() != Class::null());
7528 UnhandledException& result = UnhandledException::Handle(); 7536 UnhandledException& result = UnhandledException::Handle();
7529 { 7537 {
7530 RawObject* raw = Object::Allocate(cls, 7538 RawObject* raw = Object::Allocate(UnhandledException::kInstanceKind,
7531 UnhandledException::InstanceSize(), 7539 UnhandledException::InstanceSize(),
7532 space); 7540 space);
7533 NoGCScope no_gc; 7541 NoGCScope no_gc;
7534 result ^= raw; 7542 result ^= raw;
7535 } 7543 }
7536 result.set_exception(exception); 7544 result.set_exception(exception);
7537 result.set_stacktrace(stacktrace); 7545 result.set_stacktrace(stacktrace);
7538 return result.raw(); 7546 return result.raw();
7539 } 7547 }
7540 7548
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
7578 return chars; 7586 return chars;
7579 } 7587 }
7580 7588
7581 7589
7582 const char* UnhandledException::ToCString() const { 7590 const char* UnhandledException::ToCString() const {
7583 return "UnhandledException"; 7591 return "UnhandledException";
7584 } 7592 }
7585 7593
7586 7594
7587 RawUnwindError* UnwindError::New(const String& message, Heap::Space space) { 7595 RawUnwindError* UnwindError::New(const String& message, Heap::Space space) {
7588 const Class& cls = Class::Handle(Object::unwind_error_class()); 7596 ASSERT(Object::unwind_error_class() != Class::null());
7589 UnwindError& result = UnwindError::Handle(); 7597 UnwindError& result = UnwindError::Handle();
7590 { 7598 {
7591 RawObject* raw = Object::Allocate(cls, 7599 RawObject* raw = Object::Allocate(UnwindError::kInstanceKind,
7592 UnwindError::InstanceSize(), 7600 UnwindError::InstanceSize(),
7593 space); 7601 space);
7594 NoGCScope no_gc; 7602 NoGCScope no_gc;
7595 result ^= raw; 7603 result ^= raw;
7596 } 7604 }
7597 result.set_message(message); 7605 result.set_message(message);
7598 return result.raw(); 7606 return result.raw();
7599 } 7607 }
7600 7608
7601 7609
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
7805 const Class& cls = Class::Handle(clazz()); 7813 const Class& cls = Class::Handle(clazz());
7806 return (index >= 0 && index < cls.num_native_fields()); 7814 return (index >= 0 && index < cls.num_native_fields());
7807 } 7815 }
7808 7816
7809 7817
7810 RawInstance* Instance::New(const Class& cls, Heap::Space space) { 7818 RawInstance* Instance::New(const Class& cls, Heap::Space space) {
7811 Instance& result = Instance::Handle(); 7819 Instance& result = Instance::Handle();
7812 { 7820 {
7813 intptr_t instance_size = cls.instance_size(); 7821 intptr_t instance_size = cls.instance_size();
7814 ASSERT(instance_size > 0); 7822 ASSERT(instance_size > 0);
7815 RawObject* raw = Object::Allocate(cls, instance_size, space); 7823 RawObject* raw = Object::Allocate(cls.id(), instance_size, space);
7816 NoGCScope no_gc; 7824 NoGCScope no_gc;
7817 result ^= raw; 7825 result ^= raw;
7818 uword addr = reinterpret_cast<uword>(result.raw_ptr()); 7826 uword addr = reinterpret_cast<uword>(result.raw_ptr());
7819 // Initialize fields. 7827 // Initialize fields.
7820 intptr_t offset = sizeof(RawObject); 7828 intptr_t offset = sizeof(RawObject);
7821 // Initialize all native fields to NULL. 7829 // Initialize all native fields to NULL.
7822 for (intptr_t i = 0; i < cls.num_native_fields(); i++) { 7830 for (intptr_t i = 0; i < cls.num_native_fields(); i++) {
7823 *reinterpret_cast<uword*>(addr + offset) = 0; 7831 *reinterpret_cast<uword*>(addr + offset) = 0;
7824 offset += kWordSize; 7832 offset += kWordSize;
7825 } 7833 }
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
7995 8003
7996 8004
7997 void Mint::set_value(int64_t value) const { 8005 void Mint::set_value(int64_t value) const {
7998 raw_ptr()->value_ = value; 8006 raw_ptr()->value_ = value;
7999 } 8007 }
8000 8008
8001 8009
8002 RawMint* Mint::New(int64_t val, Heap::Space space) { 8010 RawMint* Mint::New(int64_t val, Heap::Space space) {
8003 // Do not allocate a Mint if Smi would do. 8011 // Do not allocate a Mint if Smi would do.
8004 ASSERT(!Smi::IsValid64(val)); 8012 ASSERT(!Smi::IsValid64(val));
8005 Isolate* isolate = Isolate::Current(); 8013 ASSERT(Isolate::Current()->object_store()->mint_class() != Class::null());
8006 const Class& cls =
8007 Class::Handle(isolate->object_store()->mint_class());
8008 Mint& result = Mint::Handle(); 8014 Mint& result = Mint::Handle();
8009 { 8015 {
8010 RawObject* raw = Object::Allocate(cls, Mint::InstanceSize(), space); 8016 RawObject* raw = Object::Allocate(Mint::kInstanceKind,
8017 Mint::InstanceSize(),
8018 space);
8011 NoGCScope no_gc; 8019 NoGCScope no_gc;
8012 result ^= raw; 8020 result ^= raw;
8013 } 8021 }
8014 result.set_value(val); 8022 result.set_value(val);
8015 return result.raw(); 8023 return result.raw();
8016 } 8024 }
8017 8025
8018 8026
8019 RawMint* Mint::NewCanonical(int64_t value) { 8027 RawMint* Mint::NewCanonical(int64_t value) {
8020 // Do not allocate a Mint if Smi would do. 8028 // Do not allocate a Mint if Smi would do.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
8123 return true; // "===". 8131 return true; // "===".
8124 } 8132 }
8125 if (other.IsNull() || !other.IsDouble()) { 8133 if (other.IsNull() || !other.IsDouble()) {
8126 return false; 8134 return false;
8127 } 8135 }
8128 return EqualsToDouble(Double::Cast(other).value()); 8136 return EqualsToDouble(Double::Cast(other).value());
8129 } 8137 }
8130 8138
8131 8139
8132 RawDouble* Double::New(double d, Heap::Space space) { 8140 RawDouble* Double::New(double d, Heap::Space space) {
8133 Isolate* isolate = Isolate::Current(); 8141 ASSERT(Isolate::Current()->object_store()->double_class() != Class::null());
8134 const Class& cls =
8135 Class::Handle(isolate->object_store()->double_class());
8136 Double& result = Double::Handle(); 8142 Double& result = Double::Handle();
8137 { 8143 {
8138 RawObject* raw = Object::Allocate(cls, Double::InstanceSize(), space); 8144 RawObject* raw = Object::Allocate(Double::kInstanceKind,
8145 Double::InstanceSize(),
8146 space);
8139 NoGCScope no_gc; 8147 NoGCScope no_gc;
8140 result ^= raw; 8148 result ^= raw;
8141 } 8149 }
8142 result.set_value(d); 8150 result.set_value(d);
8143 return result.raw(); 8151 return result.raw();
8144 } 8152 }
8145 8153
8146 8154
8147 static bool IsWhiteSpace(char ch) { 8155 static bool IsWhiteSpace(char ch) {
8148 return ch == '\0' || ch == '\n' || ch == '\r' || ch == ' ' || ch == '\t'; 8156 return ch == '\0' || ch == '\n' || ch == '\r' || ch == ' ' || ch == '\t';
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
8284 } 8292 }
8285 if (this->IsNegative() == other.IsNegative()) { 8293 if (this->IsNegative() == other.IsNegative()) {
8286 return this->IsNegative() ? -1 : 1; 8294 return this->IsNegative() ? -1 : 1;
8287 } 8295 }
8288 return this->IsNegative() ? -1 : 1; 8296 return this->IsNegative() ? -1 : 1;
8289 } 8297 }
8290 8298
8291 8299
8292 RawBigint* Bigint::Allocate(intptr_t length, Heap::Space space) { 8300 RawBigint* Bigint::Allocate(intptr_t length, Heap::Space space) {
8293 ASSERT(length >= 0); 8301 ASSERT(length >= 0);
8294 Isolate* isolate = Isolate::Current(); 8302 ASSERT(Isolate::Current()->object_store()->bigint_class() != Class::null());
8295 const Class& cls = Class::Handle(isolate->object_store()->bigint_class());
8296 Bigint& result = Bigint::Handle(); 8303 Bigint& result = Bigint::Handle();
8297 { 8304 {
8298 RawObject* raw = Object::Allocate(cls, Bigint::InstanceSize(length), space); 8305 RawObject* raw = Object::Allocate(Bigint::kInstanceKind,
8306 Bigint::InstanceSize(length),
8307 space);
8299 NoGCScope no_gc; 8308 NoGCScope no_gc;
8300 result ^= raw; 8309 result ^= raw;
8301 result.raw_ptr()->allocated_length_ = length; // Chunk length allocated. 8310 result.raw_ptr()->allocated_length_ = length; // Chunk length allocated.
8302 result.raw_ptr()->signed_length_ = length; // Chunk length in use. 8311 result.raw_ptr()->signed_length_ = length; // Chunk length in use.
8303 } 8312 }
8304 return result.raw(); 8313 return result.raw();
8305 } 8314 }
8306 8315
8307 8316
8308 static uword ZoneAllocator(intptr_t size) { 8317 static uword ZoneAllocator(intptr_t size) {
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
8514 } 8523 }
8515 } 8524 }
8516 return true; 8525 return true;
8517 } 8526 }
8518 8527
8519 8528
8520 RawInstance* String::Canonicalize() const { 8529 RawInstance* String::Canonicalize() const {
8521 if (IsCanonical()) { 8530 if (IsCanonical()) {
8522 return this->raw(); 8531 return this->raw();
8523 } 8532 }
8524 return NewSymbol(*this); 8533 return Symbols::New(*this);
8525 } 8534 }
8526 8535
8527 8536
8528 RawString* String::New(const char* str, Heap::Space space) { 8537 RawString* String::New(const char* str, Heap::Space space) {
8529 intptr_t width = 0; 8538 intptr_t width = 0;
8530 intptr_t len = Utf8::CodePointCount(str, &width); 8539 intptr_t len = Utf8::CodePointCount(str, &width);
8531 if (width == 1) { 8540 if (width == 1) {
8532 const OneByteString& onestr 8541 const OneByteString& onestr
8533 = OneByteString::Handle(OneByteString::New(len, space)); 8542 = OneByteString::Handle(OneByteString::New(len, space));
8534 if (len > 0) { 8543 if (len > 0) {
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
8795 if (str.IsTwoByteString()) { 8804 if (str.IsTwoByteString()) {
8796 const TwoByteString& twostr = TwoByteString::Cast(str); 8805 const TwoByteString& twostr = TwoByteString::Cast(str);
8797 return twostr.EscapeDoubleQuotes(); 8806 return twostr.EscapeDoubleQuotes();
8798 } 8807 }
8799 ASSERT(str.IsFourByteString()); 8808 ASSERT(str.IsFourByteString());
8800 const FourByteString& fourstr = FourByteString::Cast(str); 8809 const FourByteString& fourstr = FourByteString::Cast(str);
8801 return fourstr.EscapeDoubleQuotes(); 8810 return fourstr.EscapeDoubleQuotes();
8802 } 8811 }
8803 8812
8804 8813
8805 static void GrowSymbolTable(const Array& symbol_table, intptr_t table_size) {
8806 // TODO(iposva): Avoid exponential growth.
8807 intptr_t new_table_size = table_size * 2;
8808 Array& new_symbol_table = Array::Handle(Array::New(new_table_size + 1));
8809 // Copy all elements from the original symbol table to the newly allocated
8810 // array.
8811 String& element = String::Handle();
8812 Object& new_element = Object::Handle();
8813 for (intptr_t i = 0; i < table_size; i++) {
8814 element ^= symbol_table.At(i);
8815 if (!element.IsNull()) {
8816 intptr_t hash = element.Hash();
8817 intptr_t index = hash % new_table_size;
8818 new_element = new_symbol_table.At(index);
8819 while (!new_element.IsNull()) {
8820 index = (index + 1) % new_table_size; // Move to next element.
8821 new_element = new_symbol_table.At(index);
8822 }
8823 new_symbol_table.SetAt(index, element);
8824 }
8825 }
8826 // Copy used count.
8827 new_element = symbol_table.At(table_size);
8828 new_symbol_table.SetAt(new_table_size, new_element);
8829 // Remember the new symbol table now.
8830 Isolate::Current()->object_store()->set_symbol_table(new_symbol_table);
8831 }
8832
8833
8834 static void InsertIntoSymbolTable(const Array& symbol_table,
8835 const String& symbol,
8836 intptr_t index,
8837 intptr_t table_size) {
8838 symbol.SetCanonical(); // Mark object as being canonical.
8839 symbol_table.SetAt(index, symbol); // Remember the new symbol.
8840 Smi& used = Smi::Handle();
8841 used ^= symbol_table.At(table_size);
8842 intptr_t used_elements = used.Value() + 1; // One more element added.
8843 used = Smi::New(used_elements);
8844 symbol_table.SetAt(table_size, used); // Update used count.
8845
8846 // Rehash if symbol_table is 75% full.
8847 if (used_elements > ((table_size / 4) * 3)) {
8848 GrowSymbolTable(symbol_table, table_size);
8849 }
8850 }
8851
8852
8853 RawString* String::NewSymbol(const char* str) {
8854 intptr_t width = 0;
8855 intptr_t len = Utf8::CodePointCount(str, &width);
8856 intptr_t size = len * width;
8857 Zone* zone = Isolate::Current()->current_zone();
8858 if (len == 0) {
8859 return String::NewSymbol(reinterpret_cast<uint8_t*>(NULL), 0);
8860 } else if (width == 1) {
8861 uint8_t* characters = reinterpret_cast<uint8_t*>(zone->Allocate(size));
8862 Utf8::Decode(str, characters, len);
8863 return NewSymbol(characters, len);
8864 } else if (width == 2) {
8865 uint16_t* characters = reinterpret_cast<uint16_t*>(zone->Allocate(size));
8866 Utf8::Decode(str, characters, len);
8867 return NewSymbol(characters, len);
8868 }
8869 ASSERT(width == 4);
8870 uint32_t* characters = reinterpret_cast<uint32_t*>(zone->Allocate(size));
8871 Utf8::Decode(str, characters, len);
8872 return NewSymbol(characters, len);
8873 }
8874
8875
8876 template<typename T>
8877 RawString* String::NewSymbol(const T* characters, intptr_t len) {
8878 Isolate* isolate = Isolate::Current();
8879
8880 // Calculate the String hash for this sequence of characters.
8881 intptr_t hash = Hash(characters, len);
8882
8883 const Array& symbol_table =
8884 Array::Handle(isolate, isolate->object_store()->symbol_table());
8885 // Last element of the array is the number of used elements.
8886 intptr_t table_size = symbol_table.Length() - 1;
8887 intptr_t index = hash % table_size;
8888
8889 String& symbol = String::Handle(isolate, String::null());
8890 symbol ^= symbol_table.At(index);
8891 while (!symbol.IsNull() && !symbol.Equals(characters, len)) {
8892 index = (index + 1) % table_size; // Move to next element.
8893 symbol ^= symbol_table.At(index);
8894 }
8895 // Since we leave enough room in the table to guarantee, that we find an
8896 // empty spot, index is the insertion point if symbol is null.
8897 if (symbol.IsNull()) {
8898 // Allocate new result string.
8899 symbol = String::New(characters, len, Heap::kOld);
8900 symbol.SetHash(hash); // Remember the calculated hash value.
8901 InsertIntoSymbolTable(symbol_table, symbol, index, table_size);
8902 }
8903 ASSERT(symbol.IsSymbol());
8904 return symbol.raw();
8905 }
8906
8907 template RawString* String::NewSymbol(const uint8_t* characters, intptr_t len);
8908 template RawString* String::NewSymbol(const uint16_t* characters, intptr_t len);
8909 template RawString* String::NewSymbol(const uint32_t* characters, intptr_t len);
8910
8911
8912 RawString* String::NewSymbol(const String& str) {
8913 if (str.IsSymbol()) {
8914 return str.raw();
8915 }
8916 return NewSymbol(str, 0, str.Length());
8917 }
8918
8919
8920 RawString* String::NewSymbol(const String& str,
8921 intptr_t begin_index,
8922 intptr_t len) {
8923 ASSERT(begin_index >= 0);
8924 ASSERT(len >= 0);
8925 ASSERT((begin_index + len) <= str.Length());
8926 Isolate* isolate = Isolate::Current();
8927
8928 // Calculate the String hash for this sequence of characters.
8929 intptr_t hash = String::Hash(str, begin_index, len);
8930
8931 const Array& symbol_table =
8932 Array::Handle(isolate, isolate->object_store()->symbol_table());
8933 // Last element of the array is the number of used elements.
8934 intptr_t table_size = symbol_table.Length() - 1;
8935 intptr_t index = hash % table_size;
8936
8937 String& symbol = String::Handle(isolate, String::null());
8938 symbol ^= symbol_table.At(index);
8939 while (!symbol.IsNull() && !symbol.Equals(str, begin_index, len)) {
8940 index = (index + 1) % table_size; // Move to next element.
8941 symbol ^= symbol_table.At(index);
8942 }
8943 // Since we leave enough room in the table to guarantee, that we find an
8944 // empty spot, index is the insertion point if symbol is null.
8945 if (symbol.IsNull()) {
8946 if (str.IsOld() && begin_index == 0 && len == str.Length()) {
8947 // Reuse the incoming str as the symbol value.
8948 symbol = str.raw();
8949 } else {
8950 // Allocate a copy in old space.
8951 symbol = String::SubString(str, begin_index, len, Heap::kOld);
8952 }
8953 symbol.SetHash(hash);
8954 InsertIntoSymbolTable(symbol_table, symbol, index, table_size);
8955 }
8956 ASSERT(symbol.IsSymbol());
8957 return symbol.raw();
8958 }
8959
8960
8961 RawString* String::NewFormatted(const char* format, ...) { 8814 RawString* String::NewFormatted(const char* format, ...) {
8962 va_list args; 8815 va_list args;
8963 va_start(args, format); 8816 va_start(args, format);
8964 intptr_t len = OS::VSNPrint(NULL, 0, format, args); 8817 intptr_t len = OS::VSNPrint(NULL, 0, format, args);
8965 va_end(args); 8818 va_end(args);
8966 8819
8967 Zone* zone = Isolate::Current()->current_zone(); 8820 Zone* zone = Isolate::Current()->current_zone();
8968 char* buffer = reinterpret_cast<char*>(zone->Allocate(len + 1)); 8821 char* buffer = reinterpret_cast<char*>(zone->Allocate(len + 1));
8969 va_list args2; 8822 va_list args2;
8970 va_start(args2, format); 8823 va_start(args2, format);
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
9196 } 9049 }
9197 9050
9198 // We have reached the end of mangled_name string. 9051 // We have reached the end of mangled_name string.
9199 ASSERT(pos == len); 9052 ASSERT(pos == len);
9200 return (name_pos == name_len); 9053 return (name_pos == name_len);
9201 } 9054 }
9202 9055
9203 9056
9204 RawOneByteString* OneByteString::New(intptr_t len, 9057 RawOneByteString* OneByteString::New(intptr_t len,
9205 Heap::Space space) { 9058 Heap::Space space) {
9206 Isolate* isolate = Isolate::Current(); 9059 ASSERT(Isolate::Current() == Dart::vm_isolate() ||
9207 9060 Isolate::Current()->object_store()->one_byte_string_class() !=
9208 const Class& cls = 9061 Class::null());
9209 Class::Handle(isolate->object_store()->one_byte_string_class());
9210 OneByteString& result = OneByteString::Handle(); 9062 OneByteString& result = OneByteString::Handle();
9211 { 9063 {
9212 RawObject* raw = Object::Allocate(cls, 9064 RawObject* raw = Object::Allocate(OneByteString::kInstanceKind,
9213 OneByteString::InstanceSize(len), 9065 OneByteString::InstanceSize(len),
9214 space); 9066 space);
9215 NoGCScope no_gc; 9067 NoGCScope no_gc;
9216 result ^= raw; 9068 result ^= raw;
9217 result.SetLength(len); 9069 result.SetLength(len);
9218 result.SetHash(0); 9070 result.SetHash(0);
9219 } 9071 }
9220 return result.raw(); 9072 return result.raw();
9221 } 9073 }
9222 9074
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
9337 } 9189 }
9338 } 9190 }
9339 return dststr.raw(); 9191 return dststr.raw();
9340 } 9192 }
9341 return TwoByteString::null(); 9193 return TwoByteString::null();
9342 } 9194 }
9343 9195
9344 9196
9345 RawTwoByteString* TwoByteString::New(intptr_t len, 9197 RawTwoByteString* TwoByteString::New(intptr_t len,
9346 Heap::Space space) { 9198 Heap::Space space) {
9347 Isolate* isolate = Isolate::Current(); 9199 ASSERT(Isolate::Current()->object_store()->two_byte_string_class());
9348
9349 const Class& cls =
9350 Class::Handle(isolate->object_store()->two_byte_string_class());
9351 TwoByteString& result = TwoByteString::Handle(); 9200 TwoByteString& result = TwoByteString::Handle();
9352 { 9201 {
9353 RawObject* raw = Object::Allocate(cls, 9202 RawObject* raw = Object::Allocate(TwoByteString::kInstanceKind,
9354 TwoByteString::InstanceSize(len), 9203 TwoByteString::InstanceSize(len),
9355 space); 9204 space);
9356 NoGCScope no_gc; 9205 NoGCScope no_gc;
9357 result ^= raw; 9206 result ^= raw;
9358 result.SetLength(len); 9207 result.SetLength(len);
9359 result.SetHash(0); 9208 result.SetHash(0);
9360 } 9209 }
9361 return result.raw(); 9210 return result.raw();
9362 } 9211 }
9363 9212
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
9468 } 9317 }
9469 } 9318 }
9470 return dststr.raw(); 9319 return dststr.raw();
9471 } 9320 }
9472 return FourByteString::null(); 9321 return FourByteString::null();
9473 } 9322 }
9474 9323
9475 9324
9476 RawFourByteString* FourByteString::New(intptr_t len, 9325 RawFourByteString* FourByteString::New(intptr_t len,
9477 Heap::Space space) { 9326 Heap::Space space) {
9478 Isolate* isolate = Isolate::Current(); 9327 ASSERT(Isolate::Current()->object_store()->four_byte_string_class() !=
9479 9328 Class::null());
9480 const Class& cls =
9481 Class::Handle(isolate->object_store()->four_byte_string_class());
9482 FourByteString& result = FourByteString::Handle(); 9329 FourByteString& result = FourByteString::Handle();
9483 { 9330 {
9484 RawObject* raw = Object::Allocate(cls, 9331 RawObject* raw = Object::Allocate(FourByteString::kInstanceKind,
9485 FourByteString::InstanceSize(len), 9332 FourByteString::InstanceSize(len),
9486 space); 9333 space);
9487 NoGCScope no_gc; 9334 NoGCScope no_gc;
9488 result ^= raw; 9335 result ^= raw;
9489 result.SetLength(len); 9336 result.SetLength(len);
9490 result.SetHash(0); 9337 result.SetHash(0);
9491 } 9338 }
9492 return result.raw(); 9339 return result.raw();
9493 } 9340 }
9494 9341
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
9577 weak_ref->set_callback(callback); 9424 weak_ref->set_callback(callback);
9578 } 9425 }
9579 9426
9580 9427
9581 RawExternalOneByteString* ExternalOneByteString::New( 9428 RawExternalOneByteString* ExternalOneByteString::New(
9582 const uint8_t* data, 9429 const uint8_t* data,
9583 intptr_t len, 9430 intptr_t len,
9584 void* peer, 9431 void* peer,
9585 Dart_PeerFinalizer callback, 9432 Dart_PeerFinalizer callback,
9586 Heap::Space space) { 9433 Heap::Space space) {
9587 Isolate* isolate = Isolate::Current(); 9434 ASSERT(Isolate::Current()->object_store()->external_one_byte_string_class() !=
9588 9435 Class::null());
9589 const Class& cls =
9590 Class::Handle(isolate->object_store()->external_one_byte_string_class());
9591 ExternalOneByteString& result = ExternalOneByteString::Handle(); 9436 ExternalOneByteString& result = ExternalOneByteString::Handle();
9592 ExternalStringData<uint8_t>* external_data = 9437 ExternalStringData<uint8_t>* external_data =
9593 new ExternalStringData<uint8_t>(data, peer, callback); 9438 new ExternalStringData<uint8_t>(data, peer, callback);
9594 { 9439 {
9595 RawObject* raw = Object::Allocate(cls, 9440 RawObject* raw = Object::Allocate(ExternalOneByteString::kInstanceKind,
9596 ExternalOneByteString::InstanceSize(), 9441 ExternalOneByteString::InstanceSize(),
9597 space); 9442 space);
9598 NoGCScope no_gc; 9443 NoGCScope no_gc;
9599 result ^= raw; 9444 result ^= raw;
9600 result.SetLength(len); 9445 result.SetLength(len);
9601 result.SetHash(0); 9446 result.SetHash(0);
9602 result.SetExternalData(external_data); 9447 result.SetExternalData(external_data);
9603 } 9448 }
9604 AddFinalizer(result, external_data, ExternalOneByteString::Finalize); 9449 AddFinalizer(result, external_data, ExternalOneByteString::Finalize);
9605 return result.raw(); 9450 return result.raw();
(...skipping 20 matching lines...) Expand all
9626 return String::ToCString(); 9471 return String::ToCString();
9627 } 9472 }
9628 9473
9629 9474
9630 RawExternalTwoByteString* ExternalTwoByteString::New( 9475 RawExternalTwoByteString* ExternalTwoByteString::New(
9631 const uint16_t* data, 9476 const uint16_t* data,
9632 intptr_t len, 9477 intptr_t len,
9633 void* peer, 9478 void* peer,
9634 Dart_PeerFinalizer callback, 9479 Dart_PeerFinalizer callback,
9635 Heap::Space space) { 9480 Heap::Space space) {
9636 Isolate* isolate = Isolate::Current(); 9481 ASSERT(Isolate::Current()->object_store()->external_two_byte_string_class() !=
9637 9482 Class::null());
9638 const Class& cls =
9639 Class::Handle(isolate->object_store()->external_two_byte_string_class());
9640 ExternalTwoByteString& result = ExternalTwoByteString::Handle(); 9483 ExternalTwoByteString& result = ExternalTwoByteString::Handle();
9641 ExternalStringData<uint16_t>* external_data = 9484 ExternalStringData<uint16_t>* external_data =
9642 new ExternalStringData<uint16_t>(data, peer, callback); 9485 new ExternalStringData<uint16_t>(data, peer, callback);
9643 { 9486 {
9644 RawObject* raw = Object::Allocate(cls, 9487 RawObject* raw = Object::Allocate(ExternalTwoByteString::kInstanceKind,
9645 ExternalTwoByteString::InstanceSize(), 9488 ExternalTwoByteString::InstanceSize(),
9646 space); 9489 space);
9647 NoGCScope no_gc; 9490 NoGCScope no_gc;
9648 result ^= raw; 9491 result ^= raw;
9649 result.SetLength(len); 9492 result.SetLength(len);
9650 result.SetHash(0); 9493 result.SetHash(0);
9651 result.SetExternalData(external_data); 9494 result.SetExternalData(external_data);
9652 } 9495 }
9653 AddFinalizer(result, external_data, ExternalTwoByteString::Finalize); 9496 AddFinalizer(result, external_data, ExternalTwoByteString::Finalize);
9654 return result.raw(); 9497 return result.raw();
(...skipping 10 matching lines...) Expand all
9665 return String::ToCString(); 9508 return String::ToCString();
9666 } 9509 }
9667 9510
9668 9511
9669 RawExternalFourByteString* ExternalFourByteString::New( 9512 RawExternalFourByteString* ExternalFourByteString::New(
9670 const uint32_t* data, 9513 const uint32_t* data,
9671 intptr_t len, 9514 intptr_t len,
9672 void* peer, 9515 void* peer,
9673 Dart_PeerFinalizer callback, 9516 Dart_PeerFinalizer callback,
9674 Heap::Space space) { 9517 Heap::Space space) {
9675 Isolate* isolate = Isolate::Current(); 9518 ASSERT(Isolate::Current()->object_store()->
9676 9519 external_four_byte_string_class() != Class::null());
9677 const Class& cls =
9678 Class::Handle(isolate->object_store()->external_four_byte_string_class());
9679 ExternalFourByteString& result = ExternalFourByteString::Handle(); 9520 ExternalFourByteString& result = ExternalFourByteString::Handle();
9680 ExternalStringData<uint32_t>* external_data = 9521 ExternalStringData<uint32_t>* external_data =
9681 new ExternalStringData<uint32_t>(data, peer, callback); 9522 new ExternalStringData<uint32_t>(data, peer, callback);
9682 { 9523 {
9683 RawObject* raw = Object::Allocate(cls, 9524 RawObject* raw = Object::Allocate(ExternalFourByteString::kInstanceKind,
9684 ExternalFourByteString::InstanceSize(), 9525 ExternalFourByteString::InstanceSize(),
9685 space); 9526 space);
9686 NoGCScope no_gc; 9527 NoGCScope no_gc;
9687 result ^= raw; 9528 result ^= raw;
9688 result.SetLength(len); 9529 result.SetLength(len);
9689 result.SetHash(0); 9530 result.SetHash(0);
9690 result.SetExternalData(external_data); 9531 result.SetExternalData(external_data);
9691 } 9532 }
9692 AddFinalizer(result, external_data, ExternalFourByteString::Finalize); 9533 AddFinalizer(result, external_data, ExternalFourByteString::Finalize);
9693 return result.raw(); 9534 return result.raw();
(...skipping 15 matching lines...) Expand all
9709 return Isolate::Current()->object_store()->true_value(); 9550 return Isolate::Current()->object_store()->true_value();
9710 } 9551 }
9711 9552
9712 9553
9713 RawBool* Bool::False() { 9554 RawBool* Bool::False() {
9714 return Isolate::Current()->object_store()->false_value(); 9555 return Isolate::Current()->object_store()->false_value();
9715 } 9556 }
9716 9557
9717 9558
9718 RawBool* Bool::New(bool value) { 9559 RawBool* Bool::New(bool value) {
9719 Isolate* isolate = Isolate::Current(); 9560 ASSERT(Isolate::Current()->object_store()->bool_class() != Class::null());
9720
9721 const Class& cls = Class::Handle(isolate->object_store()->bool_class());
9722 Bool& result = Bool::Handle(); 9561 Bool& result = Bool::Handle();
9723 { 9562 {
9724 // Since the two boolean instances are singletons we allocate them straight 9563 // Since the two boolean instances are singletons we allocate them straight
9725 // in the old generation. 9564 // in the old generation.
9726 RawObject* raw = Object::Allocate(cls, Bool::InstanceSize(), Heap::kOld); 9565 RawObject* raw = Object::Allocate(Bool::kInstanceKind,
9566 Bool::InstanceSize(),
9567 Heap::kOld);
9727 NoGCScope no_gc; 9568 NoGCScope no_gc;
9728 result ^= raw; 9569 result ^= raw;
9729 } 9570 }
9730 result.set_value(value); 9571 result.set_value(value);
9731 return result.raw(); 9572 return result.raw();
9732 } 9573 }
9733 9574
9734 9575
9735 const char* Bool::ToCString() const { 9576 const char* Bool::ToCString() const {
9736 return value() ? "true" : "false"; 9577 return value() ? "true" : "false";
(...skipping 28 matching lines...) Expand all
9765 if (this->At(i) != other_arr.At(i)) { 9606 if (this->At(i) != other_arr.At(i)) {
9766 return false; 9607 return false;
9767 } 9608 }
9768 } 9609 }
9769 return true; 9610 return true;
9770 } 9611 }
9771 9612
9772 9613
9773 RawArray* Array::New(intptr_t len, Heap::Space space) { 9614 RawArray* Array::New(intptr_t len, Heap::Space space) {
9774 ObjectStore* object_store = Isolate::Current()->object_store(); 9615 ObjectStore* object_store = Isolate::Current()->object_store();
9616 ASSERT(object_store->array_class() != Class::null());
9775 Class& cls = Class::Handle(object_store->array_class()); 9617 Class& cls = Class::Handle(object_store->array_class());
9776 return New(cls, len, space); 9618 return New(cls, len, space);
9777 } 9619 }
9778 9620
9779 9621
9780 RawArray* Array::New(const Class& cls, intptr_t len, Heap::Space space) { 9622 RawArray* Array::New(const Class& cls, intptr_t len, Heap::Space space) {
9781 if ((len < 0) || (len > kMaxArrayElements)) { 9623 if ((len < 0) || (len > kMaxArrayElements)) {
9782 // TODO(srdjan): Verify that illegal argument is the right thing to throw. 9624 // TODO(srdjan): Verify that illegal argument is the right thing to throw.
9783 GrowableArray<const Object*> args; 9625 GrowableArray<const Object*> args;
9784 args.Add(&Smi::Handle(Smi::New(len))); 9626 args.Add(&Smi::Handle(Smi::New(len)));
9785 Exceptions::ThrowByType(Exceptions::kIllegalArgument, args); 9627 Exceptions::ThrowByType(Exceptions::kIllegalArgument, args);
9786 } 9628 }
9787 Array& result = Array::Handle(); 9629 Array& result = Array::Handle();
9788 { 9630 {
9789 RawObject* raw = Object::Allocate(cls, 9631 RawObject* raw = Object::Allocate(cls.id(),
9790 Array::InstanceSize(len), 9632 Array::InstanceSize(len),
9791 space); 9633 space);
9792 NoGCScope no_gc; 9634 NoGCScope no_gc;
9793 result ^= raw; 9635 result ^= raw;
9794 result.SetLength(len); 9636 result.SetLength(len);
9795 } 9637 }
9796 return result.raw(); 9638 return result.raw();
9797 } 9639 }
9798 9640
9799 9641
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
9892 raw->ptr()->tags_ = tags; 9734 raw->ptr()->tags_ = tags;
9893 } 9735 }
9894 } 9736 }
9895 return array.raw(); 9737 return array.raw();
9896 } 9738 }
9897 9739
9898 9740
9899 RawImmutableArray* ImmutableArray::New(intptr_t len, 9741 RawImmutableArray* ImmutableArray::New(intptr_t len,
9900 Heap::Space space) { 9742 Heap::Space space) {
9901 ObjectStore* object_store = Isolate::Current()->object_store(); 9743 ObjectStore* object_store = Isolate::Current()->object_store();
9744 ASSERT(object_store->immutable_array_class() != Class::null());
9902 Class& cls = Class::Handle(object_store->immutable_array_class()); 9745 Class& cls = Class::Handle(object_store->immutable_array_class());
9903 return reinterpret_cast<RawImmutableArray*>(Array::New(cls, len, space)); 9746 return reinterpret_cast<RawImmutableArray*>(Array::New(cls, len, space));
9904 } 9747 }
9905 9748
9906 9749
9907 const char* ImmutableArray::ToCString() const { 9750 const char* ImmutableArray::ToCString() const {
9908 return "ImmutableArray"; 9751 return "ImmutableArray";
9909 } 9752 }
9910 9753
9911 9754
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
9996 9839
9997 RawGrowableObjectArray* GrowableObjectArray::New(intptr_t capacity, 9840 RawGrowableObjectArray* GrowableObjectArray::New(intptr_t capacity,
9998 Heap::Space space) { 9841 Heap::Space space) {
9999 const Array& data = Array::Handle(Array::New(capacity, space)); 9842 const Array& data = Array::Handle(Array::New(capacity, space));
10000 return New(data, space); 9843 return New(data, space);
10001 } 9844 }
10002 9845
10003 9846
10004 RawGrowableObjectArray* GrowableObjectArray::New(const Array& array, 9847 RawGrowableObjectArray* GrowableObjectArray::New(const Array& array,
10005 Heap::Space space) { 9848 Heap::Space space) {
10006 ObjectStore* object_store = Isolate::Current()->object_store(); 9849 ASSERT(Isolate::Current()->object_store()->growable_object_array_class()
10007 Class& cls = Class::Handle(object_store->growable_object_array_class()); 9850 != Class::null());
10008 GrowableObjectArray& result = GrowableObjectArray::Handle(); 9851 GrowableObjectArray& result = GrowableObjectArray::Handle();
10009 { 9852 {
10010 RawObject* raw = Object::Allocate(cls, 9853 RawObject* raw = Object::Allocate(GrowableObjectArray::kInstanceKind,
10011 GrowableObjectArray::InstanceSize(), 9854 GrowableObjectArray::InstanceSize(),
10012 space); 9855 space);
10013 NoGCScope no_gc; 9856 NoGCScope no_gc;
10014 result ^= raw; 9857 result ^= raw;
10015 result.SetLength(0); 9858 result.SetLength(0);
10016 result.SetData(array); 9859 result.SetData(array);
10017 } 9860 }
10018 return result.raw(); 9861 return result.raw();
10019 } 9862 }
10020 9863
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
10079 RawT* ByteArray::NewExternalImpl(const Class& cls, 9922 RawT* ByteArray::NewExternalImpl(const Class& cls,
10080 ElementT* data, 9923 ElementT* data,
10081 intptr_t len, 9924 intptr_t len,
10082 void* peer, 9925 void* peer,
10083 Dart_PeerFinalizer callback, 9926 Dart_PeerFinalizer callback,
10084 Heap::Space space) { 9927 Heap::Space space) {
10085 HandleT& result = HandleT::Handle(); 9928 HandleT& result = HandleT::Handle();
10086 ExternalByteArrayData<ElementT>* external_data = 9929 ExternalByteArrayData<ElementT>* external_data =
10087 new ExternalByteArrayData<ElementT>(data, peer, callback); 9930 new ExternalByteArrayData<ElementT>(data, peer, callback);
10088 { 9931 {
10089 RawObject* raw = Object::Allocate(cls, HandleT::InstanceSize(), space); 9932 RawObject* raw = Object::Allocate(cls.id(), HandleT::InstanceSize(), space);
10090 NoGCScope no_gc; 9933 NoGCScope no_gc;
10091 result ^= raw; 9934 result ^= raw;
10092 result.SetLength(len); 9935 result.SetLength(len);
10093 result.SetExternalData(external_data); 9936 result.SetExternalData(external_data);
10094 } 9937 }
10095 AddFinalizer(result, external_data, ExternalByteArrayFinalize<ElementT>); 9938 AddFinalizer(result, external_data, ExternalByteArrayFinalize<ElementT>);
10096 return result.raw(); 9939 return result.raw();
10097 } 9940 }
10098 9941
10099 9942
(...skipping 15 matching lines...) Expand all
10115 // ByteArray is an abstract class. 9958 // ByteArray is an abstract class.
10116 UNREACHABLE(); 9959 UNREACHABLE();
10117 return "ByteArray"; 9960 return "ByteArray";
10118 } 9961 }
10119 9962
10120 9963
10121 template<typename HandleT, typename RawT> 9964 template<typename HandleT, typename RawT>
10122 RawT* ByteArray::NewImpl(const Class& cls, intptr_t len, Heap::Space space) { 9965 RawT* ByteArray::NewImpl(const Class& cls, intptr_t len, Heap::Space space) {
10123 HandleT& result = HandleT::Handle(); 9966 HandleT& result = HandleT::Handle();
10124 { 9967 {
10125 RawObject* raw = Object::Allocate(cls, HandleT::InstanceSize(len), space); 9968 RawObject* raw = Object::Allocate(cls.id(),
9969 HandleT::InstanceSize(len),
9970 space);
10126 NoGCScope no_gc; 9971 NoGCScope no_gc;
10127 result ^= raw; 9972 result ^= raw;
10128 result.SetLength(len); 9973 result.SetLength(len);
10129 if (len > 0) { 9974 if (len > 0) {
10130 memset(result.ByteAddr(0), 0, result.ByteLength()); 9975 memset(result.ByteAddr(0), 0, result.ByteLength());
10131 } 9976 }
10132 } 9977 }
10133 return result.raw(); 9978 return result.raw();
10134 } 9979 }
10135 9980
10136 9981
10137 template<typename HandleT, typename RawT, typename ElementT> 9982 template<typename HandleT, typename RawT, typename ElementT>
10138 RawT* ByteArray::NewImpl(const Class& cls, 9983 RawT* ByteArray::NewImpl(const Class& cls,
10139 const ElementT* data, 9984 const ElementT* data,
10140 intptr_t len, 9985 intptr_t len,
10141 Heap::Space space) { 9986 Heap::Space space) {
10142 HandleT& result = HandleT::Handle(); 9987 HandleT& result = HandleT::Handle();
10143 { 9988 {
10144 RawObject* raw = Object::Allocate(cls, HandleT::InstanceSize(len), space); 9989 RawObject* raw = Object::Allocate(cls.id(),
9990 HandleT::InstanceSize(len),
9991 space);
10145 NoGCScope no_gc; 9992 NoGCScope no_gc;
10146 result ^= raw; 9993 result ^= raw;
10147 result.SetLength(len); 9994 result.SetLength(len);
10148 if (len > 0) { 9995 if (len > 0) {
10149 memmove(result.ByteAddr(0), data, result.ByteLength()); 9996 memmove(result.ByteAddr(0), data, result.ByteLength());
10150 } 9997 }
10151 } 9998 }
10152 return result.raw(); 9999 return result.raw();
10153 } 10000 }
10154 10001
10155 10002
10156 RawInt8Array* Int8Array::New(intptr_t len, Heap::Space space) { 10003 RawInt8Array* Int8Array::New(intptr_t len, Heap::Space space) {
10157 Isolate* isolate = Isolate::Current(); 10004 Isolate* isolate = Isolate::Current();
10005 ASSERT(isolate->object_store()->int8_array_class() != Class::null());
10158 const Class& cls = 10006 const Class& cls =
10159 Class::Handle(isolate->object_store()->int8_array_class()); 10007 Class::Handle(isolate->object_store()->int8_array_class());
10160 return NewImpl<Int8Array, RawInt8Array>(cls, len, space); 10008 return NewImpl<Int8Array, RawInt8Array>(cls, len, space);
10161 } 10009 }
10162 10010
10163 10011
10164 RawInt8Array* Int8Array::New(const int8_t* data, 10012 RawInt8Array* Int8Array::New(const int8_t* data,
10165 intptr_t len, 10013 intptr_t len,
10166 Heap::Space space) { 10014 Heap::Space space) {
10167 Isolate* isolate = Isolate::Current(); 10015 Isolate* isolate = Isolate::Current();
10016 ASSERT(isolate->object_store()->int8_array_class() != Class::null());
10168 const Class& cls = 10017 const Class& cls =
10169 Class::Handle(isolate->object_store()->int8_array_class()); 10018 Class::Handle(isolate->object_store()->int8_array_class());
10170 return NewImpl<Int8Array, RawInt8Array>(cls, data, len, space); 10019 return NewImpl<Int8Array, RawInt8Array>(cls, data, len, space);
10171 } 10020 }
10172 10021
10173 10022
10174 const char* Int8Array::ToCString() const { 10023 const char* Int8Array::ToCString() const {
10175 return "_Int8Array"; 10024 return "_Int8Array";
10176 } 10025 }
10177 10026
10178 10027
10179 RawUint8Array* Uint8Array::New(intptr_t len, Heap::Space space) { 10028 RawUint8Array* Uint8Array::New(intptr_t len, Heap::Space space) {
10180 Isolate* isolate = Isolate::Current(); 10029 Isolate* isolate = Isolate::Current();
10030 ASSERT(isolate->object_store()->uint8_array_class() != Class::null());
10181 const Class& cls = 10031 const Class& cls =
10182 Class::Handle(isolate->object_store()->uint8_array_class()); 10032 Class::Handle(isolate->object_store()->uint8_array_class());
10183 return NewImpl<Uint8Array, RawUint8Array>(cls, len, space); 10033 return NewImpl<Uint8Array, RawUint8Array>(cls, len, space);
10184 } 10034 }
10185 10035
10186 10036
10187 RawUint8Array* Uint8Array::New(const uint8_t* data, 10037 RawUint8Array* Uint8Array::New(const uint8_t* data,
10188 intptr_t len, 10038 intptr_t len,
10189 Heap::Space space) { 10039 Heap::Space space) {
10190 Isolate* isolate = Isolate::Current(); 10040 Isolate* isolate = Isolate::Current();
10041 ASSERT(isolate->object_store()->uint8_array_class() != Class::null());
10191 const Class& cls = 10042 const Class& cls =
10192 Class::Handle(isolate->object_store()->uint8_array_class()); 10043 Class::Handle(isolate->object_store()->uint8_array_class());
10193 return NewImpl<Uint8Array, RawUint8Array>(cls, data, len, space); 10044 return NewImpl<Uint8Array, RawUint8Array>(cls, data, len, space);
10194 } 10045 }
10195 10046
10196 10047
10197 const char* Uint8Array::ToCString() const { 10048 const char* Uint8Array::ToCString() const {
10198 return "_Uint8Array"; 10049 return "_Uint8Array";
10199 } 10050 }
10200 10051
10201 10052
10202 RawInt16Array* Int16Array::New(intptr_t len, Heap::Space space) { 10053 RawInt16Array* Int16Array::New(intptr_t len, Heap::Space space) {
10203 Isolate* isolate = Isolate::Current(); 10054 Isolate* isolate = Isolate::Current();
10055 ASSERT(isolate->object_store()->int16_array_class() != Class::null());
10204 const Class& cls = 10056 const Class& cls =
10205 Class::Handle(isolate->object_store()->int16_array_class()); 10057 Class::Handle(isolate->object_store()->int16_array_class());
10206 return NewImpl<Int16Array, RawInt16Array>(cls, len, space); 10058 return NewImpl<Int16Array, RawInt16Array>(cls, len, space);
10207 } 10059 }
10208 10060
10209 10061
10210 RawInt16Array* Int16Array::New(const int16_t* data, 10062 RawInt16Array* Int16Array::New(const int16_t* data,
10211 intptr_t len, 10063 intptr_t len,
10212 Heap::Space space) { 10064 Heap::Space space) {
10213 Isolate* isolate = Isolate::Current(); 10065 Isolate* isolate = Isolate::Current();
10066 ASSERT(isolate->object_store()->int16_array_class() != Class::null());
10214 const Class& cls = 10067 const Class& cls =
10215 Class::Handle(isolate->object_store()->int16_array_class()); 10068 Class::Handle(isolate->object_store()->int16_array_class());
10216 return NewImpl<Int16Array, RawInt16Array>(cls, data, len, space); 10069 return NewImpl<Int16Array, RawInt16Array>(cls, data, len, space);
10217 } 10070 }
10218 10071
10219 10072
10220 const char* Int16Array::ToCString() const { 10073 const char* Int16Array::ToCString() const {
10221 return "_Int16Array"; 10074 return "_Int16Array";
10222 } 10075 }
10223 10076
10224 10077
10225 RawUint16Array* Uint16Array::New(intptr_t len, Heap::Space space) { 10078 RawUint16Array* Uint16Array::New(intptr_t len, Heap::Space space) {
10226 Isolate* isolate = Isolate::Current(); 10079 Isolate* isolate = Isolate::Current();
10080 ASSERT(isolate->object_store()->uint16_array_class() != Class::null());
10227 const Class& cls = 10081 const Class& cls =
10228 Class::Handle(isolate->object_store()->uint16_array_class()); 10082 Class::Handle(isolate->object_store()->uint16_array_class());
10229 return NewImpl<Uint16Array, RawUint16Array>(cls, len, space); 10083 return NewImpl<Uint16Array, RawUint16Array>(cls, len, space);
10230 } 10084 }
10231 10085
10232 10086
10233 RawUint16Array* Uint16Array::New(const uint16_t* data, 10087 RawUint16Array* Uint16Array::New(const uint16_t* data,
10234 intptr_t len, 10088 intptr_t len,
10235 Heap::Space space) { 10089 Heap::Space space) {
10236 Isolate* isolate = Isolate::Current(); 10090 Isolate* isolate = Isolate::Current();
10091 ASSERT(isolate->object_store()->uint16_array_class() != Class::null());
10237 const Class& cls = 10092 const Class& cls =
10238 Class::Handle(isolate->object_store()->uint16_array_class()); 10093 Class::Handle(isolate->object_store()->uint16_array_class());
10239 return NewImpl<Uint16Array, RawUint16Array>(cls, data, len, space); 10094 return NewImpl<Uint16Array, RawUint16Array>(cls, data, len, space);
10240 } 10095 }
10241 10096
10242 10097
10243 const char* Uint16Array::ToCString() const { 10098 const char* Uint16Array::ToCString() const {
10244 return "_Uint16Array"; 10099 return "_Uint16Array";
10245 } 10100 }
10246 10101
10247 10102
10248 RawInt32Array* Int32Array::New(intptr_t len, Heap::Space space) { 10103 RawInt32Array* Int32Array::New(intptr_t len, Heap::Space space) {
10249 Isolate* isolate = Isolate::Current(); 10104 Isolate* isolate = Isolate::Current();
10105 ASSERT(isolate->object_store()->int32_array_class() != Class::null());
10250 const Class& cls = 10106 const Class& cls =
10251 Class::Handle(isolate->object_store()->int32_array_class()); 10107 Class::Handle(isolate->object_store()->int32_array_class());
10252 return NewImpl<Int32Array, RawInt32Array>(cls, len, space); 10108 return NewImpl<Int32Array, RawInt32Array>(cls, len, space);
10253 } 10109 }
10254 10110
10255 10111
10256 RawInt32Array* Int32Array::New(const int32_t* data, 10112 RawInt32Array* Int32Array::New(const int32_t* data,
10257 intptr_t len, 10113 intptr_t len,
10258 Heap::Space space) { 10114 Heap::Space space) {
10259 Isolate* isolate = Isolate::Current(); 10115 Isolate* isolate = Isolate::Current();
10116 ASSERT(isolate->object_store()->int32_array_class() != Class::null());
10260 const Class& cls = 10117 const Class& cls =
10261 Class::Handle(isolate->object_store()->int32_array_class()); 10118 Class::Handle(isolate->object_store()->int32_array_class());
10262 return NewImpl<Int32Array, RawInt32Array>(cls, data, len, space); 10119 return NewImpl<Int32Array, RawInt32Array>(cls, data, len, space);
10263 } 10120 }
10264 10121
10265 10122
10266 const char* Int32Array::ToCString() const { 10123 const char* Int32Array::ToCString() const {
10267 return "_Int32Array"; 10124 return "_Int32Array";
10268 } 10125 }
10269 10126
10270 10127
10271 RawUint32Array* Uint32Array::New(intptr_t len, Heap::Space space) { 10128 RawUint32Array* Uint32Array::New(intptr_t len, Heap::Space space) {
10272 Isolate* isolate = Isolate::Current(); 10129 Isolate* isolate = Isolate::Current();
10130 ASSERT(isolate->object_store()->uint32_array_class() != Class::null());
10273 const Class& cls = 10131 const Class& cls =
10274 Class::Handle(isolate->object_store()->uint32_array_class()); 10132 Class::Handle(isolate->object_store()->uint32_array_class());
10275 return NewImpl<Uint32Array, RawUint32Array>(cls, len, space); 10133 return NewImpl<Uint32Array, RawUint32Array>(cls, len, space);
10276 } 10134 }
10277 10135
10278 10136
10279 RawUint32Array* Uint32Array::New(const uint32_t* data, 10137 RawUint32Array* Uint32Array::New(const uint32_t* data,
10280 intptr_t len, 10138 intptr_t len,
10281 Heap::Space space) { 10139 Heap::Space space) {
10282 Isolate* isolate = Isolate::Current(); 10140 Isolate* isolate = Isolate::Current();
10141 ASSERT(isolate->object_store()->uint32_array_class() != Class::null());
10283 const Class& cls = 10142 const Class& cls =
10284 Class::Handle(isolate->object_store()->uint32_array_class()); 10143 Class::Handle(isolate->object_store()->uint32_array_class());
10285 return NewImpl<Uint32Array, RawUint32Array>(cls, data, len, space); 10144 return NewImpl<Uint32Array, RawUint32Array>(cls, data, len, space);
10286 } 10145 }
10287 10146
10288 10147
10289 const char* Uint32Array::ToCString() const { 10148 const char* Uint32Array::ToCString() const {
10290 return "_Uint32Array"; 10149 return "_Uint32Array";
10291 } 10150 }
10292 10151
10293 10152
10294 RawInt64Array* Int64Array::New(intptr_t len, Heap::Space space) { 10153 RawInt64Array* Int64Array::New(intptr_t len, Heap::Space space) {
10295 Isolate* isolate = Isolate::Current(); 10154 Isolate* isolate = Isolate::Current();
10155 ASSERT(isolate->object_store()->int64_array_class() != Class::null());
10296 const Class& cls = 10156 const Class& cls =
10297 Class::Handle(isolate->object_store()->int64_array_class()); 10157 Class::Handle(isolate->object_store()->int64_array_class());
10298 return NewImpl<Int64Array, RawInt64Array>(cls, len, space); 10158 return NewImpl<Int64Array, RawInt64Array>(cls, len, space);
10299 } 10159 }
10300 10160
10301 10161
10302 RawInt64Array* Int64Array::New(const int64_t* data, 10162 RawInt64Array* Int64Array::New(const int64_t* data,
10303 intptr_t len, 10163 intptr_t len,
10304 Heap::Space space) { 10164 Heap::Space space) {
10305 Isolate* isolate = Isolate::Current(); 10165 Isolate* isolate = Isolate::Current();
10166 ASSERT(isolate->object_store()->int64_array_class() != Class::null());
10306 const Class& cls = 10167 const Class& cls =
10307 Class::Handle(isolate->object_store()->int64_array_class()); 10168 Class::Handle(isolate->object_store()->int64_array_class());
10308 return NewImpl<Int64Array, RawInt64Array>(cls, data, len, space); 10169 return NewImpl<Int64Array, RawInt64Array>(cls, data, len, space);
10309 } 10170 }
10310 10171
10311 10172
10312 const char* Int64Array::ToCString() const { 10173 const char* Int64Array::ToCString() const {
10313 return "_Int64Array"; 10174 return "_Int64Array";
10314 } 10175 }
10315 10176
10316 10177
10317 RawUint64Array* Uint64Array::New(intptr_t len, Heap::Space space) { 10178 RawUint64Array* Uint64Array::New(intptr_t len, Heap::Space space) {
10318 Isolate* isolate = Isolate::Current(); 10179 Isolate* isolate = Isolate::Current();
10180 ASSERT(isolate->object_store()->uint64_array_class() != Class::null());
10319 const Class& cls = 10181 const Class& cls =
10320 Class::Handle(isolate->object_store()->uint64_array_class()); 10182 Class::Handle(isolate->object_store()->uint64_array_class());
10321 return NewImpl<Uint64Array, RawUint64Array>(cls, len, space); 10183 return NewImpl<Uint64Array, RawUint64Array>(cls, len, space);
10322 } 10184 }
10323 10185
10324 10186
10325 RawUint64Array* Uint64Array::New(const uint64_t* data, 10187 RawUint64Array* Uint64Array::New(const uint64_t* data,
10326 intptr_t len, 10188 intptr_t len,
10327 Heap::Space space) { 10189 Heap::Space space) {
10328 Isolate* isolate = Isolate::Current(); 10190 Isolate* isolate = Isolate::Current();
10191 ASSERT(isolate->object_store()->uint64_array_class() != Class::null());
10329 const Class& cls = 10192 const Class& cls =
10330 Class::Handle(isolate->object_store()->uint64_array_class()); 10193 Class::Handle(isolate->object_store()->uint64_array_class());
10331 return NewImpl<Uint64Array, RawUint64Array>(cls, data, len, space); 10194 return NewImpl<Uint64Array, RawUint64Array>(cls, data, len, space);
10332 } 10195 }
10333 10196
10334 10197
10335 const char* Uint64Array::ToCString() const { 10198 const char* Uint64Array::ToCString() const {
10336 return "_Uint64Array"; 10199 return "_Uint64Array";
10337 } 10200 }
10338 10201
10339 10202
10340 RawFloat32Array* Float32Array::New(intptr_t len, Heap::Space space) { 10203 RawFloat32Array* Float32Array::New(intptr_t len, Heap::Space space) {
10341 Isolate* isolate = Isolate::Current(); 10204 Isolate* isolate = Isolate::Current();
10205 ASSERT(isolate->object_store()->float32_array_class() != Class::null());
10342 const Class& cls = 10206 const Class& cls =
10343 Class::Handle(isolate->object_store()->float32_array_class()); 10207 Class::Handle(isolate->object_store()->float32_array_class());
10344 return NewImpl<Float32Array, RawFloat32Array>(cls, len, space); 10208 return NewImpl<Float32Array, RawFloat32Array>(cls, len, space);
10345 } 10209 }
10346 10210
10347 10211
10348 RawFloat32Array* Float32Array::New(const float* data, 10212 RawFloat32Array* Float32Array::New(const float* data,
10349 intptr_t len, 10213 intptr_t len,
10350 Heap::Space space) { 10214 Heap::Space space) {
10351 Isolate* isolate = Isolate::Current(); 10215 Isolate* isolate = Isolate::Current();
10216 ASSERT(isolate->object_store()->float32_array_class() != Class::null());
10352 const Class& cls = 10217 const Class& cls =
10353 Class::Handle(isolate->object_store()->float32_array_class()); 10218 Class::Handle(isolate->object_store()->float32_array_class());
10354 return NewImpl<Float32Array, RawFloat32Array>(cls, data, len, space); 10219 return NewImpl<Float32Array, RawFloat32Array>(cls, data, len, space);
10355 } 10220 }
10356 10221
10357 10222
10358 const char* Float32Array::ToCString() const { 10223 const char* Float32Array::ToCString() const {
10359 return "_Float32Array"; 10224 return "_Float32Array";
10360 } 10225 }
10361 10226
10362 10227
10363 RawFloat64Array* Float64Array::New(intptr_t len, Heap::Space space) { 10228 RawFloat64Array* Float64Array::New(intptr_t len, Heap::Space space) {
10364 Isolate* isolate = Isolate::Current(); 10229 Isolate* isolate = Isolate::Current();
10230 ASSERT(isolate->object_store()->float64_array_class() != Class::null());
10365 const Class& cls = 10231 const Class& cls =
10366 Class::Handle(isolate->object_store()->float64_array_class()); 10232 Class::Handle(isolate->object_store()->float64_array_class());
10367 return NewImpl<Float64Array, RawFloat64Array>(cls, len, space); 10233 return NewImpl<Float64Array, RawFloat64Array>(cls, len, space);
10368 } 10234 }
10369 10235
10370 10236
10371 RawFloat64Array* Float64Array::New(const double* data, 10237 RawFloat64Array* Float64Array::New(const double* data,
10372 intptr_t len, 10238 intptr_t len,
10373 Heap::Space space) { 10239 Heap::Space space) {
10374 Isolate* isolate = Isolate::Current(); 10240 Isolate* isolate = Isolate::Current();
10241 ASSERT(isolate->object_store()->float64_array_class() != Class::null());
10375 const Class& cls = 10242 const Class& cls =
10376 Class::Handle(isolate->object_store()->float64_array_class()); 10243 Class::Handle(isolate->object_store()->float64_array_class());
10377 return NewImpl<Float64Array, RawFloat64Array>(cls, data, len, space); 10244 return NewImpl<Float64Array, RawFloat64Array>(cls, data, len, space);
10378 } 10245 }
10379 10246
10380 10247
10381 const char* Float64Array::ToCString() const { 10248 const char* Float64Array::ToCString() const {
10382 return "_Float64Array"; 10249 return "_Float64Array";
10383 } 10250 }
10384 10251
10385 10252
10386 RawExternalInt8Array* ExternalInt8Array::New(int8_t* data, 10253 RawExternalInt8Array* ExternalInt8Array::New(int8_t* data,
10387 intptr_t len, 10254 intptr_t len,
10388 void* peer, 10255 void* peer,
10389 Dart_PeerFinalizer callback, 10256 Dart_PeerFinalizer callback,
10390 Heap::Space space) { 10257 Heap::Space space) {
10391 Isolate* isolate = Isolate::Current(); 10258 Isolate* isolate = Isolate::Current();
10259 ASSERT(isolate->object_store()->external_int8_array_class() != Class::null());
10392 const Class& cls = 10260 const Class& cls =
10393 Class::Handle(isolate->object_store()->external_int8_array_class()); 10261 Class::Handle(isolate->object_store()->external_int8_array_class());
10394 return NewExternalImpl<ExternalInt8Array, RawExternalInt8Array>( 10262 return NewExternalImpl<ExternalInt8Array, RawExternalInt8Array>(
10395 cls, data, len, peer, callback, space); 10263 cls, data, len, peer, callback, space);
10396 } 10264 }
10397 10265
10398 10266
10399 const char* ExternalInt8Array::ToCString() const { 10267 const char* ExternalInt8Array::ToCString() const {
10400 return "_ExternalInt8Array"; 10268 return "_ExternalInt8Array";
10401 } 10269 }
10402 10270
10403 10271
10404 RawExternalUint8Array* ExternalUint8Array::New(uint8_t* data, 10272 RawExternalUint8Array* ExternalUint8Array::New(uint8_t* data,
10405 intptr_t len, 10273 intptr_t len,
10406 void* peer, 10274 void* peer,
10407 Dart_PeerFinalizer callback, 10275 Dart_PeerFinalizer callback,
10408 Heap::Space space) { 10276 Heap::Space space) {
10409 Isolate* isolate = Isolate::Current(); 10277 Isolate* isolate = Isolate::Current();
10278 ASSERT(isolate->object_store()->external_uint8_array_class() !=
10279 Class::null());
10410 const Class& cls = 10280 const Class& cls =
10411 Class::Handle(isolate->object_store()->external_uint8_array_class()); 10281 Class::Handle(isolate->object_store()->external_uint8_array_class());
10412 return NewExternalImpl<ExternalUint8Array, RawExternalUint8Array>( 10282 return NewExternalImpl<ExternalUint8Array, RawExternalUint8Array>(
10413 cls, data, len, peer, callback, space); 10283 cls, data, len, peer, callback, space);
10414 } 10284 }
10415 10285
10416 10286
10417 const char* ExternalUint8Array::ToCString() const { 10287 const char* ExternalUint8Array::ToCString() const {
10418 return "_ExternalUint8Array"; 10288 return "_ExternalUint8Array";
10419 } 10289 }
10420 10290
10421 10291
10422 RawExternalInt16Array* ExternalInt16Array::New(int16_t* data, 10292 RawExternalInt16Array* ExternalInt16Array::New(int16_t* data,
10423 intptr_t len, 10293 intptr_t len,
10424 void* peer, 10294 void* peer,
10425 Dart_PeerFinalizer callback, 10295 Dart_PeerFinalizer callback,
10426 Heap::Space space) { 10296 Heap::Space space) {
10427 Isolate* isolate = Isolate::Current(); 10297 Isolate* isolate = Isolate::Current();
10298 ASSERT(isolate->object_store()->external_int16_array_class() !=
10299 Class::null());
10428 const Class& cls = 10300 const Class& cls =
10429 Class::Handle(isolate->object_store()->external_int16_array_class()); 10301 Class::Handle(isolate->object_store()->external_int16_array_class());
10430 return NewExternalImpl<ExternalInt16Array, RawExternalInt16Array>( 10302 return NewExternalImpl<ExternalInt16Array, RawExternalInt16Array>(
10431 cls, data, len, peer, callback, space); 10303 cls, data, len, peer, callback, space);
10432 } 10304 }
10433 10305
10434 10306
10435 const char* ExternalInt16Array::ToCString() const { 10307 const char* ExternalInt16Array::ToCString() const {
10436 return "_ExternalInt16Array"; 10308 return "_ExternalInt16Array";
10437 } 10309 }
10438 10310
10439 10311
10440 RawExternalUint16Array* ExternalUint16Array::New(uint16_t* data, 10312 RawExternalUint16Array* ExternalUint16Array::New(uint16_t* data,
10441 intptr_t len, 10313 intptr_t len,
10442 void* peer, 10314 void* peer,
10443 Dart_PeerFinalizer callback, 10315 Dart_PeerFinalizer callback,
10444 Heap::Space space) { 10316 Heap::Space space) {
10445 Isolate* isolate = Isolate::Current(); 10317 Isolate* isolate = Isolate::Current();
10318 ASSERT(isolate->object_store()->external_uint16_array_class() !=
10319 Class::null());
10446 const Class& cls = 10320 const Class& cls =
10447 Class::Handle(isolate->object_store()->external_uint16_array_class()); 10321 Class::Handle(isolate->object_store()->external_uint16_array_class());
10448 return NewExternalImpl<ExternalUint16Array, RawExternalUint16Array>( 10322 return NewExternalImpl<ExternalUint16Array, RawExternalUint16Array>(
10449 cls, data, len, peer, callback, space); 10323 cls, data, len, peer, callback, space);
10450 } 10324 }
10451 10325
10452 10326
10453 const char* ExternalUint16Array::ToCString() const { 10327 const char* ExternalUint16Array::ToCString() const {
10454 return "_ExternalUint16Array"; 10328 return "_ExternalUint16Array";
10455 } 10329 }
10456 10330
10457 10331
10458 RawExternalInt32Array* ExternalInt32Array::New(int32_t* data, 10332 RawExternalInt32Array* ExternalInt32Array::New(int32_t* data,
10459 intptr_t len, 10333 intptr_t len,
10460 void* peer, 10334 void* peer,
10461 Dart_PeerFinalizer callback, 10335 Dart_PeerFinalizer callback,
10462 Heap::Space space) { 10336 Heap::Space space) {
10463 Isolate* isolate = Isolate::Current(); 10337 Isolate* isolate = Isolate::Current();
10338 ASSERT(isolate->object_store()->external_int32_array_class() !=
10339 Class::null());
10464 const Class& cls = 10340 const Class& cls =
10465 Class::Handle(isolate->object_store()->external_int32_array_class()); 10341 Class::Handle(isolate->object_store()->external_int32_array_class());
10466 return NewExternalImpl<ExternalInt32Array, RawExternalInt32Array>( 10342 return NewExternalImpl<ExternalInt32Array, RawExternalInt32Array>(
10467 cls, data, len, peer, callback, space); 10343 cls, data, len, peer, callback, space);
10468 } 10344 }
10469 10345
10470 10346
10471 const char* ExternalInt32Array::ToCString() const { 10347 const char* ExternalInt32Array::ToCString() const {
10472 return "_ExternalInt32Array"; 10348 return "_ExternalInt32Array";
10473 } 10349 }
10474 10350
10475 10351
10476 RawExternalUint32Array* ExternalUint32Array::New(uint32_t* data, 10352 RawExternalUint32Array* ExternalUint32Array::New(uint32_t* data,
10477 intptr_t len, 10353 intptr_t len,
10478 void* peer, 10354 void* peer,
10479 Dart_PeerFinalizer callback, 10355 Dart_PeerFinalizer callback,
10480 Heap::Space space) { 10356 Heap::Space space) {
10481 Isolate* isolate = Isolate::Current(); 10357 Isolate* isolate = Isolate::Current();
10358 ASSERT(isolate->object_store()->external_uint32_array_class() !=
10359 Class::null());
10482 const Class& cls = 10360 const Class& cls =
10483 Class::Handle(isolate->object_store()->external_uint32_array_class()); 10361 Class::Handle(isolate->object_store()->external_uint32_array_class());
10484 return NewExternalImpl<ExternalUint32Array, RawExternalUint32Array>( 10362 return NewExternalImpl<ExternalUint32Array, RawExternalUint32Array>(
10485 cls, data, len, peer, callback, space); 10363 cls, data, len, peer, callback, space);
10486 } 10364 }
10487 10365
10488 10366
10489 const char* ExternalUint32Array::ToCString() const { 10367 const char* ExternalUint32Array::ToCString() const {
10490 return "_ExternalUint32Array"; 10368 return "_ExternalUint32Array";
10491 } 10369 }
10492 10370
10493 10371
10494 RawExternalInt64Array* ExternalInt64Array::New(int64_t* data, 10372 RawExternalInt64Array* ExternalInt64Array::New(int64_t* data,
10495 intptr_t len, 10373 intptr_t len,
10496 void* peer, 10374 void* peer,
10497 Dart_PeerFinalizer callback, 10375 Dart_PeerFinalizer callback,
10498 Heap::Space space) { 10376 Heap::Space space) {
10499 Isolate* isolate = Isolate::Current(); 10377 Isolate* isolate = Isolate::Current();
10378 ASSERT(isolate->object_store()->external_int64_array_class() !=
10379 Class::null());
10500 const Class& cls = 10380 const Class& cls =
10501 Class::Handle(isolate->object_store()->external_int64_array_class()); 10381 Class::Handle(isolate->object_store()->external_int64_array_class());
10502 return NewExternalImpl<ExternalInt64Array, RawExternalInt64Array>( 10382 return NewExternalImpl<ExternalInt64Array, RawExternalInt64Array>(
10503 cls, data, len, peer, callback, space); 10383 cls, data, len, peer, callback, space);
10504 } 10384 }
10505 10385
10506 10386
10507 const char* ExternalInt64Array::ToCString() const { 10387 const char* ExternalInt64Array::ToCString() const {
10508 return "_ExternalInt64Array"; 10388 return "_ExternalInt64Array";
10509 } 10389 }
10510 10390
10511 10391
10512 RawExternalUint64Array* ExternalUint64Array::New(uint64_t* data, 10392 RawExternalUint64Array* ExternalUint64Array::New(uint64_t* data,
10513 intptr_t len, 10393 intptr_t len,
10514 void* peer, 10394 void* peer,
10515 Dart_PeerFinalizer callback, 10395 Dart_PeerFinalizer callback,
10516 Heap::Space space) { 10396 Heap::Space space) {
10517 Isolate* isolate = Isolate::Current(); 10397 Isolate* isolate = Isolate::Current();
10398 ASSERT(isolate->object_store()->external_uint64_array_class() !=
10399 Class::null());
10518 const Class& cls = 10400 const Class& cls =
10519 Class::Handle(isolate->object_store()->external_uint64_array_class()); 10401 Class::Handle(isolate->object_store()->external_uint64_array_class());
10520 return NewExternalImpl<ExternalUint64Array, RawExternalUint64Array>( 10402 return NewExternalImpl<ExternalUint64Array, RawExternalUint64Array>(
10521 cls, data, len, peer, callback, space); 10403 cls, data, len, peer, callback, space);
10522 } 10404 }
10523 10405
10524 10406
10525 const char* ExternalUint64Array::ToCString() const { 10407 const char* ExternalUint64Array::ToCString() const {
10526 return "_ExternalUint64Array"; 10408 return "_ExternalUint64Array";
10527 } 10409 }
10528 10410
10529 10411
10530 RawExternalFloat32Array* ExternalFloat32Array::New(float* data, 10412 RawExternalFloat32Array* ExternalFloat32Array::New(float* data,
10531 intptr_t len, 10413 intptr_t len,
10532 void* peer, 10414 void* peer,
10533 Dart_PeerFinalizer callback, 10415 Dart_PeerFinalizer callback,
10534 Heap::Space space) { 10416 Heap::Space space) {
10535 Isolate* isolate = Isolate::Current(); 10417 Isolate* isolate = Isolate::Current();
10418 ASSERT(isolate->object_store()->external_float32_array_class() !=
10419 Class::null());
10536 const Class& cls = 10420 const Class& cls =
10537 Class::Handle(isolate->object_store()->external_float32_array_class()); 10421 Class::Handle(isolate->object_store()->external_float32_array_class());
10538 return NewExternalImpl<ExternalFloat32Array, RawExternalFloat32Array>( 10422 return NewExternalImpl<ExternalFloat32Array, RawExternalFloat32Array>(
10539 cls, data, len, peer, callback, space); 10423 cls, data, len, peer, callback, space);
10540 } 10424 }
10541 10425
10542 10426
10543 const char* ExternalFloat32Array::ToCString() const { 10427 const char* ExternalFloat32Array::ToCString() const {
10544 return "_ExternalFloat32Array"; 10428 return "_ExternalFloat32Array";
10545 } 10429 }
10546 10430
10547 10431
10548 RawExternalFloat64Array* ExternalFloat64Array::New(double* data, 10432 RawExternalFloat64Array* ExternalFloat64Array::New(double* data,
10549 intptr_t len, 10433 intptr_t len,
10550 void* peer, 10434 void* peer,
10551 Dart_PeerFinalizer callback, 10435 Dart_PeerFinalizer callback,
10552 Heap::Space space) { 10436 Heap::Space space) {
10553 Isolate* isolate = Isolate::Current(); 10437 Isolate* isolate = Isolate::Current();
10438 ASSERT(isolate->object_store()->external_float64_array_class() !=
10439 Class::null());
10554 const Class& cls = 10440 const Class& cls =
10555 Class::Handle(isolate->object_store()->external_float64_array_class()); 10441 Class::Handle(isolate->object_store()->external_float64_array_class());
10556 return NewExternalImpl<ExternalFloat64Array, RawExternalFloat64Array>( 10442 return NewExternalImpl<ExternalFloat64Array, RawExternalFloat64Array>(
10557 cls, data, len, peer, callback, space); 10443 cls, data, len, peer, callback, space);
10558 } 10444 }
10559 10445
10560 10446
10561 const char* ExternalFloat64Array::ToCString() const { 10447 const char* ExternalFloat64Array::ToCString() const {
10562 return "_ExternalFloat64Array"; 10448 return "_ExternalFloat64Array";
10563 } 10449 }
10564 10450
10565 10451
10566 10452
10567 RawClosure* Closure::New(const Function& function, 10453 RawClosure* Closure::New(const Function& function,
10568 const Context& context, 10454 const Context& context,
10569 Heap::Space space) { 10455 Heap::Space space) {
10570 Isolate* isolate = Isolate::Current(); 10456 Isolate* isolate = Isolate::Current();
10571 ASSERT(context.isolate() == isolate); 10457 ASSERT(context.isolate() == isolate);
10572 10458
10573 const Class& cls = Class::Handle(function.signature_class()); 10459 const Class& cls = Class::Handle(function.signature_class());
10574 Closure& result = Closure::Handle(); 10460 Closure& result = Closure::Handle();
10575 { 10461 {
10576 RawObject* raw = Object::Allocate(cls, Closure::InstanceSize(), space); 10462 RawObject* raw = Object::Allocate(cls.id(), Closure::InstanceSize(), space);
10577 NoGCScope no_gc; 10463 NoGCScope no_gc;
10578 result ^= raw; 10464 result ^= raw;
10579 } 10465 }
10580 result.set_function(function); 10466 result.set_function(function);
10581 result.set_context(context); 10467 result.set_context(context);
10582 return result.raw(); 10468 return result.raw();
10583 } 10469 }
10584 10470
10585 10471
10586 void Closure::set_context(const Context& value) const { 10472 void Closure::set_context(const Context& value) const {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
10664 function_array.SetAt((index + i), function); 10550 function_array.SetAt((index + i), function);
10665 code_array.SetAt((index + i), code); 10551 code_array.SetAt((index + i), code);
10666 pc_offset = Smi::New(frame_pcs[i] - code.EntryPoint()); 10552 pc_offset = Smi::New(frame_pcs[i] - code.EntryPoint());
10667 pc_offset_array.SetAt((index + i), pc_offset); 10553 pc_offset_array.SetAt((index + i), pc_offset);
10668 } 10554 }
10669 } 10555 }
10670 10556
10671 10557
10672 RawStacktrace* Stacktrace::New(const GrowableArray<uword>& stack_frame_pcs, 10558 RawStacktrace* Stacktrace::New(const GrowableArray<uword>& stack_frame_pcs,
10673 Heap::Space space) { 10559 Heap::Space space) {
10674 const Class& cls = Class::Handle( 10560 ASSERT(Isolate::Current()->object_store()->stacktrace_class() !=
10675 Isolate::Current()->object_store()->stacktrace_class()); 10561 Class::null());
10676 Stacktrace& result = Stacktrace::Handle(); 10562 Stacktrace& result = Stacktrace::Handle();
10677 { 10563 {
10678 RawObject* raw = Object::Allocate(cls, 10564 RawObject* raw = Object::Allocate(Stacktrace::kInstanceKind,
10679 Stacktrace::InstanceSize(), 10565 Stacktrace::InstanceSize(),
10680 space); 10566 space);
10681 NoGCScope no_gc; 10567 NoGCScope no_gc;
10682 result ^= raw; 10568 result ^= raw;
10683 } 10569 }
10684 intptr_t length = stack_frame_pcs.length(); 10570 intptr_t length = stack_frame_pcs.length();
10685 // Create arrays for the function, code and pc_offset triplet for each frame. 10571 // Create arrays for the function, code and pc_offset triplet for each frame.
10686 const Array& function_array = Array::Handle(Array::New(length)); 10572 const Array& function_array = Array::Handle(Array::New(length));
10687 const Array& code_array = Array::Handle(Array::New(length)); 10573 const Array& code_array = Array::Handle(Array::New(length));
10688 const Array& pc_offset_array = Array::Handle(Array::New(length)); 10574 const Array& pc_offset_array = Array::Handle(Array::New(length));
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
10791 StorePointer(&raw_ptr()->pattern_, pattern.raw()); 10677 StorePointer(&raw_ptr()->pattern_, pattern.raw());
10792 } 10678 }
10793 10679
10794 10680
10795 void JSRegExp::set_num_bracket_expressions(intptr_t value) const { 10681 void JSRegExp::set_num_bracket_expressions(intptr_t value) const {
10796 raw_ptr()->num_bracket_expressions_ = Smi::New(value); 10682 raw_ptr()->num_bracket_expressions_ = Smi::New(value);
10797 } 10683 }
10798 10684
10799 10685
10800 RawJSRegExp* JSRegExp::New(intptr_t len, Heap::Space space) { 10686 RawJSRegExp* JSRegExp::New(intptr_t len, Heap::Space space) {
10801 const Class& cls = Class::Handle( 10687 ASSERT(Isolate::Current()->object_store()->jsregexp_class() !=
10802 Isolate::Current()->object_store()->jsregexp_class()); 10688 Class::null());
10803 JSRegExp& result = JSRegExp::Handle(); 10689 JSRegExp& result = JSRegExp::Handle();
10804 { 10690 {
10805 RawObject* raw = Object::Allocate(cls, 10691 RawObject* raw = Object::Allocate(JSRegExp::kInstanceKind,
10806 JSRegExp::InstanceSize(len), 10692 JSRegExp::InstanceSize(len),
10807 space); 10693 space);
10808 NoGCScope no_gc; 10694 NoGCScope no_gc;
10809 result ^= raw; 10695 result ^= raw;
10810 result.set_type(kUnitialized); 10696 result.set_type(kUnitialized);
10811 result.set_flags(0); 10697 result.set_flags(0);
10812 result.SetLength(len); 10698 result.SetLength(len);
10813 } 10699 }
10814 return result.raw(); 10700 return result.raw();
10815 } 10701 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
10875 const String& str = String::Handle(pattern()); 10761 const String& str = String::Handle(pattern());
10876 const char* format = "JSRegExp: pattern=%s flags=%s"; 10762 const char* format = "JSRegExp: pattern=%s flags=%s";
10877 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 10763 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
10878 char* chars = reinterpret_cast<char*>( 10764 char* chars = reinterpret_cast<char*>(
10879 Isolate::Current()->current_zone()->Allocate(len + 1)); 10765 Isolate::Current()->current_zone()->Allocate(len + 1));
10880 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 10766 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
10881 return chars; 10767 return chars;
10882 } 10768 }
10883 10769
10884 } // namespace dart 10770 } // namespace dart
OLDNEW
« no previous file with comments | « vm/object.h ('k') | vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698