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

Side by Side Diff: vm/object.cc

Issue 9139067: Use special allocation functions for object creation while deserializing from a full snapshot in ... (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/object.h ('k') | vm/raw_object.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) 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"
(...skipping 2649 matching lines...) Expand 10 before | Expand all | Expand 10 after
2660 Class::Handle(Object::type_arguments_class()); 2660 Class::Handle(Object::type_arguments_class());
2661 TypeArguments& result = TypeArguments::Handle(); 2661 TypeArguments& result = TypeArguments::Handle();
2662 { 2662 {
2663 RawObject* raw = Object::Allocate(type_arguments_class, 2663 RawObject* raw = Object::Allocate(type_arguments_class,
2664 TypeArguments::InstanceSize(len), 2664 TypeArguments::InstanceSize(len),
2665 Heap::kOld); 2665 Heap::kOld);
2666 NoGCScope no_gc; 2666 NoGCScope no_gc;
2667 result ^= raw; 2667 result ^= raw;
2668 // Length must be set before we start storing into the array. 2668 // Length must be set before we start storing into the array.
2669 result.SetLength(len); 2669 result.SetLength(len);
2670 for (intptr_t i = 0; i < len; i++) {
2671 *result.TypeAddr(i) = Type::null();
2672 }
2673 } 2670 }
2674 return result.raw(); 2671 return result.raw();
2675 } 2672 }
2676 2673
2677 2674
2678 2675
2679 RawAbstractType** TypeArguments::TypeAddr(intptr_t index) const { 2676 RawAbstractType** TypeArguments::TypeAddr(intptr_t index) const {
2680 // TODO(iposva): Determine if we should throw an exception here. 2677 // TODO(iposva): Determine if we should throw an exception here.
2681 ASSERT((index >= 0) && (index < Length())); 2678 ASSERT((index >= 0) && (index < Length()));
2682 return &raw_ptr()->types_[index]; 2679 return &raw_ptr()->types_[index];
(...skipping 4508 matching lines...) Expand 10 before | Expand all | Expand 10 after
7191 7188
7192 for (intptr_t i = 0; i < len; i++) { 7189 for (intptr_t i = 0; i < len; i++) {
7193 if (this->At(i) != other_arr.At(i)) { 7190 if (this->At(i) != other_arr.At(i)) {
7194 return false; 7191 return false;
7195 } 7192 }
7196 } 7193 }
7197 return true; 7194 return true;
7198 } 7195 }
7199 7196
7200 7197
7201 RawArray* Array::New(word len, bool immutable, Heap::Space space) { 7198 RawArray* Array::New(intptr_t len, Heap::Space space) {
7199 ObjectStore* object_store = Isolate::Current()->object_store();
7200 Class& cls = Class::Handle(object_store->array_class());
7201 return New(cls, len, space);
7202 }
7203
7204
7205 RawArray* Array::New(const Class& cls, intptr_t len, Heap::Space space) {
7202 if ((len < 0) || (len > kMaxArrayElements)) { 7206 if ((len < 0) || (len > kMaxArrayElements)) {
7203 // TODO(iposva): Should we throw an illegal parameter exception? 7207 // TODO(iposva): Should we throw an illegal parameter exception?
7204 UNIMPLEMENTED(); 7208 UNIMPLEMENTED();
7205 return null(); 7209 return null();
7206 } 7210 }
7207
7208 Isolate* isolate = Isolate::Current();
7209 Class& cls = Class::Handle();
7210 if (immutable) {
7211 cls = isolate->object_store()->immutable_array_class();
7212 } else {
7213 cls = isolate->object_store()->array_class();
7214 }
7215 Array& result = Array::Handle(); 7211 Array& result = Array::Handle();
7216 { 7212 {
7217 RawObject* raw = Object::Allocate(cls, 7213 RawObject* raw = Object::Allocate(cls,
7218 Array::InstanceSize(len), 7214 Array::InstanceSize(len),
7219 space); 7215 space);
7220 NoGCScope no_gc; 7216 NoGCScope no_gc;
7221 result ^= raw; 7217 result ^= raw;
7222 result.SetLength(len); 7218 result.SetLength(len);
7223 } 7219 }
7224 return result.raw(); 7220 return result.raw();
(...skipping 23 matching lines...) Expand all
7248 } 7244 }
7249 return result.raw(); 7245 return result.raw();
7250 } 7246 }
7251 7247
7252 7248
7253 RawArray* Array::Empty() { 7249 RawArray* Array::Empty() {
7254 return Isolate::Current()->object_store()->empty_array(); 7250 return Isolate::Current()->object_store()->empty_array();
7255 } 7251 }
7256 7252
7257 7253
7254 RawImmutableArray* ImmutableArray::New(intptr_t len,
7255 Heap::Space space) {
7256 ObjectStore* object_store = Isolate::Current()->object_store();
7257 Class& cls = Class::Handle(object_store->immutable_array_class());
7258 return reinterpret_cast<RawImmutableArray*>(Array::New(cls, len, space));
7259 }
7260
7261
7258 const char* ImmutableArray::ToCString() const { 7262 const char* ImmutableArray::ToCString() const {
7259 return "ImmutableArray"; 7263 return "ImmutableArray";
7260 } 7264 }
7261 7265
7262 7266
7263 RawByteBuffer* ByteBuffer::New(uint8_t* data, 7267 RawByteBuffer* ByteBuffer::New(uint8_t* data,
7264 intptr_t len, 7268 intptr_t len,
7265 Heap::Space space) { 7269 Heap::Space space) {
7266 Isolate* isolate = Isolate::Current(); 7270 Isolate* isolate = Isolate::Current();
7267 const Class& byte_buffer_class = 7271 const Class& byte_buffer_class =
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
7609 const String& str = String::Handle(pattern()); 7613 const String& str = String::Handle(pattern());
7610 const char* format = "JSRegExp: pattern=%s flags=%s"; 7614 const char* format = "JSRegExp: pattern=%s flags=%s";
7611 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 7615 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
7612 char* chars = reinterpret_cast<char*>( 7616 char* chars = reinterpret_cast<char*>(
7613 Isolate::Current()->current_zone()->Allocate(len + 1)); 7617 Isolate::Current()->current_zone()->Allocate(len + 1));
7614 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 7618 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
7615 return chars; 7619 return chars;
7616 } 7620 }
7617 7621
7618 } // namespace dart 7622 } // namespace dart
OLDNEW
« no previous file with comments | « vm/object.h ('k') | vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698