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

Side by Side Diff: runtime/vm/object.cc

Issue 14969019: A load static of an initialized static final field can be converted to its value, as long as it is … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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 | « runtime/vm/object.h ('k') | no next file » | 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 "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 // These are initialized to a value that will force a illegal memory access if 65 // These are initialized to a value that will force a illegal memory access if
66 // they are being used. 66 // they are being used.
67 #if defined(RAW_NULL) 67 #if defined(RAW_NULL)
68 #error RAW_NULL should not be defined. 68 #error RAW_NULL should not be defined.
69 #endif 69 #endif
70 #define RAW_NULL kHeapObjectTag 70 #define RAW_NULL kHeapObjectTag
71 Array* Object::empty_array_ = NULL; 71 Array* Object::empty_array_ = NULL;
72 Instance* Object::sentinel_ = NULL; 72 Instance* Object::sentinel_ = NULL;
73 Instance* Object::transition_sentinel_ = NULL; 73 Instance* Object::transition_sentinel_ = NULL;
74 Instance* Object::unknown_constant_ = NULL;
75 Instance* Object::non_constant_ = NULL;
74 Bool* Object::bool_true_ = NULL; 76 Bool* Object::bool_true_ = NULL;
75 Bool* Object::bool_false_ = NULL; 77 Bool* Object::bool_false_ = NULL;
76 LanguageError* Object::snapshot_writer_error_ = NULL; 78 LanguageError* Object::snapshot_writer_error_ = NULL;
77 79
78 RawObject* Object::null_ = reinterpret_cast<RawObject*>(RAW_NULL); 80 RawObject* Object::null_ = reinterpret_cast<RawObject*>(RAW_NULL);
79 RawClass* Object::class_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 81 RawClass* Object::class_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
80 RawClass* Object::null_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 82 RawClass* Object::null_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
81 RawClass* Object::dynamic_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 83 RawClass* Object::dynamic_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
82 RawClass* Object::void_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 84 RawClass* Object::void_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
83 RawClass* Object::unresolved_class_class_ = 85 RawClass* Object::unresolved_class_class_ =
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 Smi::handle_vtable_ = fake_smi.vtable(); 316 Smi::handle_vtable_ = fake_smi.vtable();
315 } 317 }
316 318
317 Isolate* isolate = Isolate::Current(); 319 Isolate* isolate = Isolate::Current();
318 Heap* heap = isolate->heap(); 320 Heap* heap = isolate->heap();
319 321
320 // Allocate the read only object handles here. 322 // Allocate the read only object handles here.
321 empty_array_ = Array::ReadOnlyHandle(isolate); 323 empty_array_ = Array::ReadOnlyHandle(isolate);
322 sentinel_ = Instance::ReadOnlyHandle(isolate); 324 sentinel_ = Instance::ReadOnlyHandle(isolate);
323 transition_sentinel_ = Instance::ReadOnlyHandle(isolate); 325 transition_sentinel_ = Instance::ReadOnlyHandle(isolate);
326 unknown_constant_ = Instance::ReadOnlyHandle(isolate);
327 non_constant_ = Instance::ReadOnlyHandle(isolate);
324 bool_true_ = Bool::ReadOnlyHandle(isolate); 328 bool_true_ = Bool::ReadOnlyHandle(isolate);
325 bool_false_ = Bool::ReadOnlyHandle(isolate); 329 bool_false_ = Bool::ReadOnlyHandle(isolate);
326 snapshot_writer_error_ = LanguageError::ReadOnlyHandle(isolate); 330 snapshot_writer_error_ = LanguageError::ReadOnlyHandle(isolate);
327 331
328 // Allocate and initialize the null instance. 332 // Allocate and initialize the null instance.
329 // 'null_' must be the first object allocated as it is used in allocation to 333 // 'null_' must be the first object allocated as it is used in allocation to
330 // clear the object. 334 // clear the object.
331 { 335 {
332 uword address = heap->Allocate(Instance::InstanceSize(), Heap::kOld); 336 uword address = heap->Allocate(Instance::InstanceSize(), Heap::kOld);
333 null_ = reinterpret_cast<RawInstance*>(address + kHeapObjectTag); 337 null_ = reinterpret_cast<RawInstance*>(address + kHeapObjectTag);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 381
378 // Allocate and initialize the sentinel values of Null class. 382 // Allocate and initialize the sentinel values of Null class.
379 { 383 {
380 *sentinel_ ^= 384 *sentinel_ ^=
381 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld); 385 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld);
382 386
383 *transition_sentinel_ ^= 387 *transition_sentinel_ ^=
384 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld); 388 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld);
385 } 389 }
386 390
391 // Allocate and initialize optimizing compiler constants.
392 {
393 *unknown_constant_ ^=
394 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld);
395 *non_constant_ ^=
396 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld);
397 }
398
387 cls = Class::New<Instance>(kDynamicCid); 399 cls = Class::New<Instance>(kDynamicCid);
388 cls.set_is_finalized(); 400 cls.set_is_finalized();
389 cls.set_is_abstract(); 401 cls.set_is_abstract();
390 dynamic_class_ = cls.raw(); 402 dynamic_class_ = cls.raw();
391 403
392 // Allocate the remaining VM internal classes. 404 // Allocate the remaining VM internal classes.
393 cls = Class::New<UnresolvedClass>(); 405 cls = Class::New<UnresolvedClass>();
394 unresolved_class_class_ = cls.raw(); 406 unresolved_class_class_ = cls.raw();
395 407
396 cls = Class::New<Instance>(kVoidCid); 408 cls = Class::New<Instance>(kVoidCid);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 529
518 *snapshot_writer_error_ = 530 *snapshot_writer_error_ =
519 LanguageError::New(String::Handle(String::New("SnapshotWriter Error"))); 531 LanguageError::New(String::Handle(String::New("SnapshotWriter Error")));
520 532
521 ASSERT(!empty_array_->IsSmi()); 533 ASSERT(!empty_array_->IsSmi());
522 ASSERT(empty_array_->IsArray()); 534 ASSERT(empty_array_->IsArray());
523 ASSERT(!sentinel_->IsSmi()); 535 ASSERT(!sentinel_->IsSmi());
524 ASSERT(sentinel_->IsInstance()); 536 ASSERT(sentinel_->IsInstance());
525 ASSERT(!transition_sentinel_->IsSmi()); 537 ASSERT(!transition_sentinel_->IsSmi());
526 ASSERT(transition_sentinel_->IsInstance()); 538 ASSERT(transition_sentinel_->IsInstance());
539 ASSERT(!unknown_constant_->IsSmi());
540 ASSERT(unknown_constant_->IsInstance());
541 ASSERT(!non_constant_->IsSmi());
542 ASSERT(non_constant_->IsInstance());
527 ASSERT(!bool_true_->IsSmi()); 543 ASSERT(!bool_true_->IsSmi());
528 ASSERT(bool_true_->IsBool()); 544 ASSERT(bool_true_->IsBool());
529 ASSERT(!bool_false_->IsSmi()); 545 ASSERT(!bool_false_->IsSmi());
530 ASSERT(bool_false_->IsBool()); 546 ASSERT(bool_false_->IsBool());
531 ASSERT(!snapshot_writer_error_->IsSmi()); 547 ASSERT(!snapshot_writer_error_->IsSmi());
532 ASSERT(snapshot_writer_error_->IsLanguageError()); 548 ASSERT(snapshot_writer_error_->IsLanguageError());
533 } 549 }
534 550
535 551
536 #define SET_CLASS_NAME(class_name, name) \ 552 #define SET_CLASS_NAME(class_name, name) \
(...skipping 8633 matching lines...) Expand 10 before | Expand all | Expand 10 after
9170 } 9186 }
9171 9187
9172 9188
9173 const char* Instance::ToCString() const { 9189 const char* Instance::ToCString() const {
9174 if (IsNull()) { 9190 if (IsNull()) {
9175 return "null"; 9191 return "null";
9176 } else if (raw() == Object::sentinel().raw()) { 9192 } else if (raw() == Object::sentinel().raw()) {
9177 return "sentinel"; 9193 return "sentinel";
9178 } else if (raw() == Object::transition_sentinel().raw()) { 9194 } else if (raw() == Object::transition_sentinel().raw()) {
9179 return "transition_sentinel"; 9195 return "transition_sentinel";
9196 } else if (raw() == Object::unknown_constant().raw()) {
9197 return "unknown_constant";
9198 } else if (raw() == Object::non_constant().raw()) {
9199 return "non_constant";
9180 } else if (Isolate::Current()->no_gc_scope_depth() > 0) { 9200 } else if (Isolate::Current()->no_gc_scope_depth() > 0) {
9181 // Can occur when running disassembler. 9201 // Can occur when running disassembler.
9182 return "Instance"; 9202 return "Instance";
9183 } else { 9203 } else {
9184 if (IsClosure()) { 9204 if (IsClosure()) {
9185 return Closure::ToCString(*this); 9205 return Closure::ToCString(*this);
9186 } 9206 }
9187 const char* kFormat = "Instance of '%s'"; 9207 const char* kFormat = "Instance of '%s'";
9188 const Class& cls = Class::Handle(clazz()); 9208 const Class& cls = Class::Handle(clazz());
9189 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); 9209 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle();
(...skipping 4044 matching lines...) Expand 10 before | Expand all | Expand 10 after
13234 } 13254 }
13235 return result.raw(); 13255 return result.raw();
13236 } 13256 }
13237 13257
13238 13258
13239 const char* WeakProperty::ToCString() const { 13259 const char* WeakProperty::ToCString() const {
13240 return "_WeakProperty"; 13260 return "_WeakProperty";
13241 } 13261 }
13242 13262
13243 } // namespace dart 13263 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698