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

Side by Side Diff: vm/object_store.cc

Issue 9580036: - Always write a Null Object for Code objects (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 9 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_store.h ('k') | vm/raw_object_snapshot.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) 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_store.h" 5 #include "vm/object_store.h"
6 6
7 #include "vm/exceptions.h" 7 #include "vm/exceptions.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/raw_object.h" 10 #include "vm/raw_object.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 core_library_(Library::null()), 47 core_library_(Library::null()),
48 core_impl_library_(Library::null()), 48 core_impl_library_(Library::null()),
49 native_wrappers_library_(Library::null()), 49 native_wrappers_library_(Library::null()),
50 root_library_(Library::null()), 50 root_library_(Library::null()),
51 registered_libraries_(Library::null()), 51 registered_libraries_(Library::null()),
52 pending_classes_(Array::null()), 52 pending_classes_(Array::null()),
53 sticky_error_(Error::null()), 53 sticky_error_(Error::null()),
54 empty_context_(Context::null()), 54 empty_context_(Context::null()),
55 stack_overflow_(Instance::null()), 55 stack_overflow_(Instance::null()),
56 out_of_memory_(Instance::null()), 56 out_of_memory_(Instance::null()),
57 keyword_symbols_(Array::null()), 57 keyword_symbols_(Array::null()) {
58 preallocate_objects_called_(false) {
59 } 58 }
60 59
61 60
62 ObjectStore::~ObjectStore() { 61 ObjectStore::~ObjectStore() {
63 } 62 }
64 63
65 64
66 void ObjectStore::VisitObjectPointers(ObjectPointerVisitor* visitor) { 65 void ObjectStore::VisitObjectPointers(ObjectPointerVisitor* visitor) {
67 ASSERT(visitor != NULL); 66 ASSERT(visitor != NULL);
68 visitor->VisitPointers(from(), to()); 67 visitor->VisitPointers(from(), to());
69 } 68 }
70 69
71 70
72 void ObjectStore::Init(Isolate* isolate) { 71 void ObjectStore::Init(Isolate* isolate) {
73 ASSERT(isolate->object_store() == NULL); 72 ASSERT(isolate->object_store() == NULL);
74 ObjectStore* store = new ObjectStore(); 73 ObjectStore* store = new ObjectStore();
75 isolate->set_object_store(store); 74 isolate->set_object_store(store);
76 } 75 }
77 76
78 77
79 bool ObjectStore::PreallocateObjects() { 78 bool ObjectStore::PreallocateObjects() {
80 if (preallocate_objects_called_) { 79 Isolate* isolate = Isolate::Current();
80 ASSERT(isolate != NULL && isolate->object_store() == this);
81 if (this->stack_overflow() != Instance::null() &&
82 this->out_of_memory() != Instance::null()) {
81 return true; 83 return true;
82 } 84 }
83 Isolate* isolate = Isolate::Current(); 85 ASSERT(this->stack_overflow() == Instance::null());
84 ASSERT(isolate != NULL && isolate->object_store() == this); 86 ASSERT(this->out_of_memory() == Instance::null());
85 GrowableArray<const Object*> args; 87 GrowableArray<const Object*> args;
86 Object& result = Object::Handle(); 88 Object& result = Object::Handle();
87 Instance& exception = Instance::Handle(); 89 Instance& exception = Instance::Handle();
88 90
89 result = Exceptions::Create(Exceptions::kStackOverflow, args); 91 result = Exceptions::Create(Exceptions::kStackOverflow, args);
90 if (result.IsError()) { 92 if (result.IsError()) {
91 return false; 93 return false;
92 } 94 }
93 exception ^= result.raw(); 95 exception ^= result.raw();
94 set_stack_overflow(exception); 96 set_stack_overflow(exception);
95 97
96 result = Exceptions::Create(Exceptions::kOutOfMemory, args); 98 result = Exceptions::Create(Exceptions::kOutOfMemory, args);
97 if (result.IsError()) { 99 if (result.IsError()) {
98 return false; 100 return false;
99 } 101 }
100 exception ^= result.raw(); 102 exception ^= result.raw();
101 set_out_of_memory(exception); 103 set_out_of_memory(exception);
102
103 preallocate_objects_called_ = true;
104 return true; 104 return true;
105 } 105 }
106 106
107 107
108 void ObjectStore::InitKeywordTable() { 108 void ObjectStore::InitKeywordTable() {
109 // Set up the keywords symbol array so that we can access it while scanning. 109 // Set up the keywords symbol array so that we can access it while scanning.
110 Array& keywords = Array::Handle(keyword_symbols()); 110 Array& keywords = Array::Handle(keyword_symbols());
111 ASSERT(keywords.IsNull()); 111 ASSERT(keywords.IsNull());
112 keywords = Array::New(Token::numKeywords, Heap::kOld); 112 keywords = Array::New(Token::numKeywords, Heap::kOld);
113 ASSERT(!keywords.IsError() && !keywords.IsNull()); 113 ASSERT(!keywords.IsError() && !keywords.IsNull());
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 return kStringInterface; 230 return kStringInterface;
231 } else if (raw_type == list_interface()) { 231 } else if (raw_type == list_interface()) {
232 return kListInterface; 232 return kListInterface;
233 } else if (raw_type == byte_array_interface()) { 233 } else if (raw_type == byte_array_interface()) {
234 return kByteArrayInterface; 234 return kByteArrayInterface;
235 } 235 }
236 return kInvalidIndex; 236 return kInvalidIndex;
237 } 237 }
238 238
239 } // namespace dart 239 } // namespace dart
OLDNEW
« no previous file with comments | « vm/object_store.h ('k') | vm/raw_object_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698