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

Side by Side Diff: vm/object.cc

Issue 9108036: - Remove redundant initialization in Array::New (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 11 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/dart.cc ('k') | vm/timer.h » ('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) 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 5260 matching lines...) Expand 10 before | Expand all | Expand 10 after
5271 result ^= raw; 5271 result ^= raw;
5272 uword addr = reinterpret_cast<uword>(result.raw_ptr()); 5272 uword addr = reinterpret_cast<uword>(result.raw_ptr());
5273 // Initialize fields. 5273 // Initialize fields.
5274 intptr_t offset = sizeof(RawObject); 5274 intptr_t offset = sizeof(RawObject);
5275 // Initialize all native fields to NULL. 5275 // Initialize all native fields to NULL.
5276 for (intptr_t i = 0; i < cls.num_native_fields(); i++) { 5276 for (intptr_t i = 0; i < cls.num_native_fields(); i++) {
5277 *reinterpret_cast<uword*>(addr + offset) = 0; 5277 *reinterpret_cast<uword*>(addr + offset) = 0;
5278 offset += kWordSize; 5278 offset += kWordSize;
5279 } 5279 }
5280 // Initialize all dart fields to null. 5280 // Initialize all dart fields to null.
5281 while (offset < instance_size) { 5281 while (offset < instance_size) {
Ivan Posva 2012/01/06 21:40:05 This could be dropped as well.
siva 2012/01/07 00:01:02 Good point. Done. On 2012/01/06 21:40:05, Ivan Po
5282 *reinterpret_cast<RawObject**>(addr + offset) = Object::null(); 5282 *reinterpret_cast<RawObject**>(addr + offset) = Object::null();
5283 offset += kWordSize; 5283 offset += kWordSize;
5284 } 5284 }
5285 } 5285 }
5286 return result.raw(); 5286 return result.raw();
5287 } 5287 }
5288 5288
5289 5289
5290 bool Instance::IsValidFieldOffset(int offset) const { 5290 bool Instance::IsValidFieldOffset(int offset) const {
5291 const Class& cls = Class::Handle(clazz()); 5291 const Class& cls = Class::Handle(clazz());
(...skipping 1813 matching lines...) Expand 10 before | Expand all | Expand 10 after
7105 cls = isolate->object_store()->array_class(); 7105 cls = isolate->object_store()->array_class();
7106 } 7106 }
7107 Array& result = Array::Handle(); 7107 Array& result = Array::Handle();
7108 { 7108 {
7109 RawObject* raw = Object::Allocate(cls, 7109 RawObject* raw = Object::Allocate(cls,
7110 Array::InstanceSize(len), 7110 Array::InstanceSize(len),
7111 space); 7111 space);
7112 NoGCScope no_gc; 7112 NoGCScope no_gc;
7113 result ^= raw; 7113 result ^= raw;
7114 result.SetLength(len); 7114 result.SetLength(len);
7115 for (intptr_t i = 0; i < len; i++) { 7115 // Object::Allocate has already initialized the allocated area.
Ivan Posva 2012/01/06 21:40:05 Comment can be dropped, no?
siva 2012/01/07 00:01:02 Done.
7116 *result.ObjectAddr(i) = Object::null();
7117 }
7118 } 7116 }
7119 return result.raw(); 7117 return result.raw();
7120 } 7118 }
7121 7119
7122 7120
7123 void Array::MakeImmutable() const { 7121 void Array::MakeImmutable() const {
7124 Isolate* isolate = Isolate::Current(); 7122 Isolate* isolate = Isolate::Current();
7125 raw()->ptr()->class_ = isolate->object_store()->immutable_array_class(); 7123 raw()->ptr()->class_ = isolate->object_store()->immutable_array_class();
7126 } 7124 }
7127 7125
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
7504 const String& str = String::Handle(pattern()); 7502 const String& str = String::Handle(pattern());
7505 const char* format = "JSRegExp: pattern=%s flags=%s"; 7503 const char* format = "JSRegExp: pattern=%s flags=%s";
7506 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 7504 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
7507 char* chars = reinterpret_cast<char*>( 7505 char* chars = reinterpret_cast<char*>(
7508 Isolate::Current()->current_zone()->Allocate(len + 1)); 7506 Isolate::Current()->current_zone()->Allocate(len + 1));
7509 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 7507 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
7510 return chars; 7508 return chars;
7511 } 7509 }
7512 7510
7513 } // namespace dart 7511 } // namespace dart
OLDNEW
« no previous file with comments | « vm/dart.cc ('k') | vm/timer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698