| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
| 8 #include "vm/assert.h" | 8 #include "vm/assert.h" |
| 9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
| 10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 | 390 |
| 391 cls = Class::New<TwoByteString>(); | 391 cls = Class::New<TwoByteString>(); |
| 392 object_store->set_two_byte_string_class(cls); | 392 object_store->set_two_byte_string_class(cls); |
| 393 | 393 |
| 394 cls = Class::New<FourByteString>(); | 394 cls = Class::New<FourByteString>(); |
| 395 object_store->set_four_byte_string_class(cls); | 395 object_store->set_four_byte_string_class(cls); |
| 396 | 396 |
| 397 cls = Class::New<Bool>(); | 397 cls = Class::New<Bool>(); |
| 398 object_store->set_bool_class(cls); | 398 object_store->set_bool_class(cls); |
| 399 | 399 |
| 400 cls = Class::New<ExternalArray>(); |
| 401 object_store->set_external_array_class(cls); |
| 402 |
| 400 cls = Class::New<UnhandledException>(); | 403 cls = Class::New<UnhandledException>(); |
| 401 object_store->set_unhandled_exception_class(cls); | 404 object_store->set_unhandled_exception_class(cls); |
| 402 | 405 |
| 403 cls = Class::New<Stacktrace>(); | 406 cls = Class::New<Stacktrace>(); |
| 404 object_store->set_stacktrace_class(cls); | 407 object_store->set_stacktrace_class(cls); |
| 405 // Set the super type so that the 'toString' method is implemented. | 408 // Set the super type so that the 'toString' method is implemented. |
| 406 type = object_store->object_type(); | 409 type = object_store->object_type(); |
| 407 cls.set_super_type(type); | 410 cls.set_super_type(type); |
| 408 | 411 |
| 409 cls = Class::New<JSRegExp>(); | 412 cls = Class::New<JSRegExp>(); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 cls = Class::New<Array>(); | 622 cls = Class::New<Array>(); |
| 620 object_store->set_array_class(cls); | 623 object_store->set_array_class(cls); |
| 621 | 624 |
| 622 Array& empty_array = Array::Handle(); | 625 Array& empty_array = Array::Handle(); |
| 623 empty_array = Array::New(0); | 626 empty_array = Array::New(0); |
| 624 object_store->set_empty_array(empty_array); | 627 object_store->set_empty_array(empty_array); |
| 625 | 628 |
| 626 cls = Class::New<ImmutableArray>(); | 629 cls = Class::New<ImmutableArray>(); |
| 627 object_store->set_immutable_array_class(cls); | 630 object_store->set_immutable_array_class(cls); |
| 628 | 631 |
| 632 cls = Class::New<ExternalArray>(); |
| 633 object_store->set_external_array_class(cls); |
| 634 |
| 629 cls = Class::New<Instance>(); | 635 cls = Class::New<Instance>(); |
| 630 object_store->set_object_class(cls); | 636 object_store->set_object_class(cls); |
| 631 | 637 |
| 632 cls = Class::New<Smi>(); | 638 cls = Class::New<Smi>(); |
| 633 object_store->set_smi_class(cls); | 639 object_store->set_smi_class(cls); |
| 634 | 640 |
| 635 cls = Class::New<Mint>(); | 641 cls = Class::New<Mint>(); |
| 636 object_store->set_mint_class(cls); | 642 object_store->set_mint_class(cls); |
| 637 | 643 |
| 638 cls = Class::New<Double>(); | 644 cls = Class::New<Double>(); |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 return object_store->four_byte_string_class(); | 1108 return object_store->four_byte_string_class(); |
| 1103 case kBool: | 1109 case kBool: |
| 1104 ASSERT(object_store->bool_class() != Class::null()); | 1110 ASSERT(object_store->bool_class() != Class::null()); |
| 1105 return object_store->bool_class(); | 1111 return object_store->bool_class(); |
| 1106 case kArray: | 1112 case kArray: |
| 1107 ASSERT(object_store->array_class() != Class::null()); | 1113 ASSERT(object_store->array_class() != Class::null()); |
| 1108 return object_store->array_class(); | 1114 return object_store->array_class(); |
| 1109 case kImmutableArray: | 1115 case kImmutableArray: |
| 1110 ASSERT(object_store->immutable_array_class() != Class::null()); | 1116 ASSERT(object_store->immutable_array_class() != Class::null()); |
| 1111 return object_store->immutable_array_class(); | 1117 return object_store->immutable_array_class(); |
| 1118 case kExternalArray: |
| 1119 ASSERT(object_store->external_array_class() != Class::null()); |
| 1120 return object_store->external_array_class(); |
| 1112 case kStacktrace: | 1121 case kStacktrace: |
| 1113 ASSERT(object_store->stacktrace_class() != Class::null()); | 1122 ASSERT(object_store->stacktrace_class() != Class::null()); |
| 1114 return object_store->stacktrace_class(); | 1123 return object_store->stacktrace_class(); |
| 1115 case kJSRegExp: | 1124 case kJSRegExp: |
| 1116 ASSERT(object_store->jsregexp_class() != Class::null()); | 1125 ASSERT(object_store->jsregexp_class() != Class::null()); |
| 1117 return object_store->jsregexp_class(); | 1126 return object_store->jsregexp_class(); |
| 1118 case kClosure: | 1127 case kClosure: |
| 1119 return Class::New<Closure>(); | 1128 return Class::New<Closure>(); |
| 1120 case kInstance: | 1129 case kInstance: |
| 1121 return Class::New<Instance>(); | 1130 return Class::New<Instance>(); |
| (...skipping 5374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6496 RawArray* Array::Empty() { | 6505 RawArray* Array::Empty() { |
| 6497 return Isolate::Current()->object_store()->empty_array(); | 6506 return Isolate::Current()->object_store()->empty_array(); |
| 6498 } | 6507 } |
| 6499 | 6508 |
| 6500 | 6509 |
| 6501 const char* ImmutableArray::ToCString() const { | 6510 const char* ImmutableArray::ToCString() const { |
| 6502 return "ImmutableArray"; | 6511 return "ImmutableArray"; |
| 6503 } | 6512 } |
| 6504 | 6513 |
| 6505 | 6514 |
| 6515 RawExternalArray* ExternalArray::New(uint8_t* data, |
| 6516 intptr_t len, |
| 6517 Heap::Space space) { |
| 6518 Isolate* isolate = Isolate::Current(); |
| 6519 const Class& external_array_class = |
| 6520 Class::Handle(isolate->object_store()->external_array_class()); |
| 6521 ExternalArray& result = ExternalArray::Handle(); |
| 6522 { |
| 6523 RawObject* raw = Object::Allocate(external_array_class, |
| 6524 ExternalArray::InstanceSize(), |
| 6525 space); |
| 6526 NoGCScope no_gc; |
| 6527 result ^= raw; |
| 6528 result.SetLength(len); |
| 6529 result.SetData(data); |
| 6530 } |
| 6531 return result.raw(); |
| 6532 } |
| 6533 |
| 6534 |
| 6535 bool ExternalArray::Equals(const Instance& other) const { |
| 6536 if (this->raw() == other.raw()) { |
| 6537 // Both handles point to the same raw instance. |
| 6538 return true; |
| 6539 } |
| 6540 |
| 6541 if (!other.IsExternalArray() || other.IsNull()) { |
| 6542 return false; |
| 6543 } |
| 6544 |
| 6545 ExternalArray& other_array = ExternalArray::Handle(); |
| 6546 other_array ^= other.raw(); |
| 6547 |
| 6548 intptr_t len = this->Length(); |
| 6549 if (len != other_array.Length()) { |
| 6550 return false; |
| 6551 } |
| 6552 |
| 6553 return !memcmp(this->Addr<uint8_t>(0), other_array.Addr<uint8_t>(0), len); |
| 6554 } |
| 6555 |
| 6556 |
| 6557 const char* ExternalArray::ToCString() const { |
| 6558 return "ExternalArray"; |
| 6559 } |
| 6560 |
| 6561 |
| 6506 RawClosure* Closure::New(const Function& function, | 6562 RawClosure* Closure::New(const Function& function, |
| 6507 const Context& context, | 6563 const Context& context, |
| 6508 Heap::Space space) { | 6564 Heap::Space space) { |
| 6509 Isolate* isolate = Isolate::Current(); | 6565 Isolate* isolate = Isolate::Current(); |
| 6510 ASSERT(context.isolate() == isolate); | 6566 ASSERT(context.isolate() == isolate); |
| 6511 | 6567 |
| 6512 const Class& cls = Class::Handle(function.signature_class()); | 6568 const Class& cls = Class::Handle(function.signature_class()); |
| 6513 Closure& result = Closure::Handle(); | 6569 Closure& result = Closure::Handle(); |
| 6514 { | 6570 { |
| 6515 RawObject* raw = Object::Allocate(cls, Closure::InstanceSize(), space); | 6571 RawObject* raw = Object::Allocate(cls, Closure::InstanceSize(), space); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6805 const String& str = String::Handle(pattern()); | 6861 const String& str = String::Handle(pattern()); |
| 6806 const char* format = "JSRegExp: pattern=%s flags=%s"; | 6862 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 6807 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 6863 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 6808 char* chars = reinterpret_cast<char*>( | 6864 char* chars = reinterpret_cast<char*>( |
| 6809 Isolate::Current()->current_zone()->Allocate(len + 1)); | 6865 Isolate::Current()->current_zone()->Allocate(len + 1)); |
| 6810 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 6866 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 6811 return chars; | 6867 return chars; |
| 6812 } | 6868 } |
| 6813 | 6869 |
| 6814 } // namespace dart | 6870 } // namespace dart |
| OLD | NEW |