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

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

Issue 1289813005: Use Object::null_instance and Object::null_function and do not create Handles everytime. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.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) 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // These are initialized to a value that will force a illegal memory access if 87 // These are initialized to a value that will force a illegal memory access if
88 // they are being used. 88 // they are being used.
89 #if defined(RAW_NULL) 89 #if defined(RAW_NULL)
90 #error RAW_NULL should not be defined. 90 #error RAW_NULL should not be defined.
91 #endif 91 #endif
92 #define RAW_NULL kHeapObjectTag 92 #define RAW_NULL kHeapObjectTag
93 Object* Object::null_object_ = NULL; 93 Object* Object::null_object_ = NULL;
94 Array* Object::null_array_ = NULL; 94 Array* Object::null_array_ = NULL;
95 String* Object::null_string_ = NULL; 95 String* Object::null_string_ = NULL;
96 Instance* Object::null_instance_ = NULL; 96 Instance* Object::null_instance_ = NULL;
97 Function* Object::null_function_ = NULL;
97 TypeArguments* Object::null_type_arguments_ = NULL; 98 TypeArguments* Object::null_type_arguments_ = NULL;
98 Array* Object::empty_array_ = NULL; 99 Array* Object::empty_array_ = NULL;
99 Array* Object::zero_array_ = NULL; 100 Array* Object::zero_array_ = NULL;
100 ObjectPool* Object::empty_object_pool_ = NULL; 101 ObjectPool* Object::empty_object_pool_ = NULL;
101 PcDescriptors* Object::empty_descriptors_ = NULL; 102 PcDescriptors* Object::empty_descriptors_ = NULL;
102 LocalVarDescriptors* Object::empty_var_descriptors_ = NULL; 103 LocalVarDescriptors* Object::empty_var_descriptors_ = NULL;
103 ExceptionHandlers* Object::empty_exception_handlers_ = NULL; 104 ExceptionHandlers* Object::empty_exception_handlers_ = NULL;
104 Array* Object::extractor_parameter_types_ = NULL; 105 Array* Object::extractor_parameter_types_ = NULL;
105 Array* Object::extractor_parameter_names_ = NULL; 106 Array* Object::extractor_parameter_names_ = NULL;
106 Instance* Object::sentinel_ = NULL; 107 Instance* Object::sentinel_ = NULL;
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 Smi::handle_vtable_ = fake_smi.vtable(); 417 Smi::handle_vtable_ = fake_smi.vtable();
417 } 418 }
418 419
419 Heap* heap = isolate->heap(); 420 Heap* heap = isolate->heap();
420 421
421 // Allocate the read only object handles here. 422 // Allocate the read only object handles here.
422 null_object_ = Object::ReadOnlyHandle(); 423 null_object_ = Object::ReadOnlyHandle();
423 null_array_ = Array::ReadOnlyHandle(); 424 null_array_ = Array::ReadOnlyHandle();
424 null_string_ = String::ReadOnlyHandle(); 425 null_string_ = String::ReadOnlyHandle();
425 null_instance_ = Instance::ReadOnlyHandle(); 426 null_instance_ = Instance::ReadOnlyHandle();
427 null_function_ = Function::ReadOnlyHandle();
426 null_type_arguments_ = TypeArguments::ReadOnlyHandle(); 428 null_type_arguments_ = TypeArguments::ReadOnlyHandle();
427 empty_array_ = Array::ReadOnlyHandle(); 429 empty_array_ = Array::ReadOnlyHandle();
428 zero_array_ = Array::ReadOnlyHandle(); 430 zero_array_ = Array::ReadOnlyHandle();
429 empty_object_pool_ = ObjectPool::ReadOnlyHandle(); 431 empty_object_pool_ = ObjectPool::ReadOnlyHandle();
430 empty_descriptors_ = PcDescriptors::ReadOnlyHandle(); 432 empty_descriptors_ = PcDescriptors::ReadOnlyHandle();
431 empty_var_descriptors_ = LocalVarDescriptors::ReadOnlyHandle(); 433 empty_var_descriptors_ = LocalVarDescriptors::ReadOnlyHandle();
432 empty_exception_handlers_ = ExceptionHandlers::ReadOnlyHandle(); 434 empty_exception_handlers_ = ExceptionHandlers::ReadOnlyHandle();
433 extractor_parameter_types_ = Array::ReadOnlyHandle(); 435 extractor_parameter_types_ = Array::ReadOnlyHandle();
434 extractor_parameter_names_ = Array::ReadOnlyHandle(); 436 extractor_parameter_names_ = Array::ReadOnlyHandle();
435 sentinel_ = Instance::ReadOnlyHandle(); 437 sentinel_ = Instance::ReadOnlyHandle();
436 transition_sentinel_ = Instance::ReadOnlyHandle(); 438 transition_sentinel_ = Instance::ReadOnlyHandle();
437 unknown_constant_ = Instance::ReadOnlyHandle(); 439 unknown_constant_ = Instance::ReadOnlyHandle();
438 non_constant_ = Instance::ReadOnlyHandle(); 440 non_constant_ = Instance::ReadOnlyHandle();
439 bool_true_ = Bool::ReadOnlyHandle(); 441 bool_true_ = Bool::ReadOnlyHandle();
440 bool_false_ = Bool::ReadOnlyHandle(); 442 bool_false_ = Bool::ReadOnlyHandle();
441 smi_illegal_cid_ = Smi::ReadOnlyHandle(); 443 smi_illegal_cid_ = Smi::ReadOnlyHandle();
442 snapshot_writer_error_ = LanguageError::ReadOnlyHandle(); 444 snapshot_writer_error_ = LanguageError::ReadOnlyHandle();
443 branch_offset_error_ = LanguageError::ReadOnlyHandle(); 445 branch_offset_error_ = LanguageError::ReadOnlyHandle();
444 vm_isolate_snapshot_object_table_ = Array::ReadOnlyHandle(); 446 vm_isolate_snapshot_object_table_ = Array::ReadOnlyHandle();
445 447
446 *null_object_ = Object::null(); 448 *null_object_ = Object::null();
447 *null_array_ = Array::null(); 449 *null_array_ = Array::null();
448 *null_string_ = String::null(); 450 *null_string_ = String::null();
449 *null_instance_ = Instance::null(); 451 *null_instance_ = Instance::null();
452 *null_function_ = Function::null();
450 *null_type_arguments_ = TypeArguments::null(); 453 *null_type_arguments_ = TypeArguments::null();
451 454
452 // Initialize the empty and zero array handles to null_ in order to be able to 455 // Initialize the empty and zero array handles to null_ in order to be able to
453 // check if the empty and zero arrays were allocated (RAW_NULL is not 456 // check if the empty and zero arrays were allocated (RAW_NULL is not
454 // available). 457 // available).
455 *empty_array_ = Array::null(); 458 *empty_array_ = Array::null();
456 *zero_array_ = Array::null(); 459 *zero_array_ = Array::null();
457 460
458 Class& cls = Class::Handle(); 461 Class& cls = Class::Handle();
459 462
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 Report::kBailout, 765 Report::kBailout,
763 Heap::kOld); 766 Heap::kOld);
764 767
765 ASSERT(!null_object_->IsSmi()); 768 ASSERT(!null_object_->IsSmi());
766 ASSERT(!null_array_->IsSmi()); 769 ASSERT(!null_array_->IsSmi());
767 ASSERT(null_array_->IsArray()); 770 ASSERT(null_array_->IsArray());
768 ASSERT(!null_string_->IsSmi()); 771 ASSERT(!null_string_->IsSmi());
769 ASSERT(null_string_->IsString()); 772 ASSERT(null_string_->IsString());
770 ASSERT(!null_instance_->IsSmi()); 773 ASSERT(!null_instance_->IsSmi());
771 ASSERT(null_instance_->IsInstance()); 774 ASSERT(null_instance_->IsInstance());
775 ASSERT(!null_function_->IsSmi());
776 ASSERT(null_function_->IsFunction());
772 ASSERT(!null_type_arguments_->IsSmi()); 777 ASSERT(!null_type_arguments_->IsSmi());
773 ASSERT(null_type_arguments_->IsTypeArguments()); 778 ASSERT(null_type_arguments_->IsTypeArguments());
774 ASSERT(!empty_array_->IsSmi()); 779 ASSERT(!empty_array_->IsSmi());
775 ASSERT(empty_array_->IsArray()); 780 ASSERT(empty_array_->IsArray());
776 ASSERT(!zero_array_->IsSmi()); 781 ASSERT(!zero_array_->IsSmi());
777 ASSERT(zero_array_->IsArray()); 782 ASSERT(zero_array_->IsArray());
778 ASSERT(!empty_descriptors_->IsSmi()); 783 ASSERT(!empty_descriptors_->IsSmi());
779 ASSERT(empty_descriptors_->IsPcDescriptors()); 784 ASSERT(empty_descriptors_->IsPcDescriptors());
780 ASSERT(!empty_var_descriptors_->IsSmi()); 785 ASSERT(!empty_var_descriptors_->IsSmi());
781 ASSERT(empty_var_descriptors_->IsLocalVarDescriptors()); 786 ASSERT(empty_var_descriptors_->IsLocalVarDescriptors());
(...skipping 6460 matching lines...) Expand 10 before | Expand all | Expand 10 after
7242 } else { 7247 } else {
7243 result.SetOffset(0); 7248 result.SetOffset(0);
7244 } 7249 }
7245 result.set_is_final(is_final); 7250 result.set_is_final(is_final);
7246 result.set_is_const(is_const); 7251 result.set_is_const(is_const);
7247 result.set_is_reflectable(is_reflectable); 7252 result.set_is_reflectable(is_reflectable);
7248 result.set_is_double_initialized(false); 7253 result.set_is_double_initialized(false);
7249 result.set_owner(owner); 7254 result.set_owner(owner);
7250 result.set_token_pos(token_pos); 7255 result.set_token_pos(token_pos);
7251 result.set_has_initializer(false); 7256 result.set_has_initializer(false);
7252 result.set_initializer(Function::Handle()); 7257 result.set_initializer(Object::null_function());
srdjan 2015/08/13 15:49:01 Is this necessary at all, since all data is initia
siva 2015/08/13 16:52:02 That is a good point, not sure why it was there in
7253 result.set_is_unboxing_candidate(true); 7258 result.set_is_unboxing_candidate(true);
7254 result.set_guarded_cid(FLAG_use_field_guards ? kIllegalCid : kDynamicCid); 7259 result.set_guarded_cid(FLAG_use_field_guards ? kIllegalCid : kDynamicCid);
7255 result.set_is_nullable(FLAG_use_field_guards ? false : true); 7260 result.set_is_nullable(FLAG_use_field_guards ? false : true);
7256 result.set_guarded_list_length_in_object_offset(Field::kUnknownLengthOffset); 7261 result.set_guarded_list_length_in_object_offset(Field::kUnknownLengthOffset);
7257 // Presently, we only attempt to remember the list length for final fields. 7262 // Presently, we only attempt to remember the list length for final fields.
7258 if (is_final && FLAG_use_field_guards) { 7263 if (is_final && FLAG_use_field_guards) {
7259 result.set_guarded_list_length(Field::kUnknownFixedLength); 7264 result.set_guarded_list_length(Field::kUnknownFixedLength);
7260 } else { 7265 } else {
7261 result.set_guarded_list_length(Field::kNoFixedLength); 7266 result.set_guarded_list_length(Field::kNoFixedLength);
7262 } 7267 }
(...skipping 14105 matching lines...) Expand 10 before | Expand all | Expand 10 after
21368 return tag_label.ToCString(); 21373 return tag_label.ToCString();
21369 } 21374 }
21370 21375
21371 21376
21372 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 21377 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
21373 Instance::PrintJSONImpl(stream, ref); 21378 Instance::PrintJSONImpl(stream, ref);
21374 } 21379 }
21375 21380
21376 21381
21377 } // namespace dart 21382 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698