| 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 5264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5275 NoGCScope no_gc; | 5275 NoGCScope no_gc; |
| 5276 result ^= raw; | 5276 result ^= raw; |
| 5277 uword addr = reinterpret_cast<uword>(result.raw_ptr()); | 5277 uword addr = reinterpret_cast<uword>(result.raw_ptr()); |
| 5278 // Initialize fields. | 5278 // Initialize fields. |
| 5279 intptr_t offset = sizeof(RawObject); | 5279 intptr_t offset = sizeof(RawObject); |
| 5280 // Initialize all native fields to NULL. | 5280 // Initialize all native fields to NULL. |
| 5281 for (intptr_t i = 0; i < cls.num_native_fields(); i++) { | 5281 for (intptr_t i = 0; i < cls.num_native_fields(); i++) { |
| 5282 *reinterpret_cast<uword*>(addr + offset) = 0; | 5282 *reinterpret_cast<uword*>(addr + offset) = 0; |
| 5283 offset += kWordSize; | 5283 offset += kWordSize; |
| 5284 } | 5284 } |
| 5285 // Initialize all dart fields to null. | |
| 5286 while (offset < instance_size) { | |
| 5287 *reinterpret_cast<RawObject**>(addr + offset) = Object::null(); | |
| 5288 offset += kWordSize; | |
| 5289 } | |
| 5290 } | 5285 } |
| 5291 return result.raw(); | 5286 return result.raw(); |
| 5292 } | 5287 } |
| 5293 | 5288 |
| 5294 | 5289 |
| 5295 bool Instance::IsValidFieldOffset(int offset) const { | 5290 bool Instance::IsValidFieldOffset(int offset) const { |
| 5296 const Class& cls = Class::Handle(clazz()); | 5291 const Class& cls = Class::Handle(clazz()); |
| 5297 return (offset >= 0 && offset <= (cls.instance_size() - kWordSize)); | 5292 return (offset >= 0 && offset <= (cls.instance_size() - kWordSize)); |
| 5298 } | 5293 } |
| 5299 | 5294 |
| (...skipping 1810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7110 cls = isolate->object_store()->array_class(); | 7105 cls = isolate->object_store()->array_class(); |
| 7111 } | 7106 } |
| 7112 Array& result = Array::Handle(); | 7107 Array& result = Array::Handle(); |
| 7113 { | 7108 { |
| 7114 RawObject* raw = Object::Allocate(cls, | 7109 RawObject* raw = Object::Allocate(cls, |
| 7115 Array::InstanceSize(len), | 7110 Array::InstanceSize(len), |
| 7116 space); | 7111 space); |
| 7117 NoGCScope no_gc; | 7112 NoGCScope no_gc; |
| 7118 result ^= raw; | 7113 result ^= raw; |
| 7119 result.SetLength(len); | 7114 result.SetLength(len); |
| 7120 for (intptr_t i = 0; i < len; i++) { | |
| 7121 *result.ObjectAddr(i) = Object::null(); | |
| 7122 } | |
| 7123 } | 7115 } |
| 7124 return result.raw(); | 7116 return result.raw(); |
| 7125 } | 7117 } |
| 7126 | 7118 |
| 7127 | 7119 |
| 7128 void Array::MakeImmutable() const { | 7120 void Array::MakeImmutable() const { |
| 7129 Isolate* isolate = Isolate::Current(); | 7121 Isolate* isolate = Isolate::Current(); |
| 7130 raw()->ptr()->class_ = isolate->object_store()->immutable_array_class(); | 7122 raw()->ptr()->class_ = isolate->object_store()->immutable_array_class(); |
| 7131 } | 7123 } |
| 7132 | 7124 |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7509 const String& str = String::Handle(pattern()); | 7501 const String& str = String::Handle(pattern()); |
| 7510 const char* format = "JSRegExp: pattern=%s flags=%s"; | 7502 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 7511 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 7503 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 7512 char* chars = reinterpret_cast<char*>( | 7504 char* chars = reinterpret_cast<char*>( |
| 7513 Isolate::Current()->current_zone()->Allocate(len + 1)); | 7505 Isolate::Current()->current_zone()->Allocate(len + 1)); |
| 7514 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 7506 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 7515 return chars; | 7507 return chars; |
| 7516 } | 7508 } |
| 7517 | 7509 |
| 7518 } // namespace dart | 7510 } // namespace dart |
| OLD | NEW |