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

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

Issue 575663002: Eliminate 99% of allocated ExceptionHandler objects (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 3 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
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 TypeArguments* Object::null_type_arguments_ = NULL; 97 TypeArguments* Object::null_type_arguments_ = NULL;
98 Array* Object::empty_array_ = NULL; 98 Array* Object::empty_array_ = NULL;
99 Array* Object::zero_array_ = NULL; 99 Array* Object::zero_array_ = NULL;
100 PcDescriptors* Object::empty_descriptors_ = NULL; 100 PcDescriptors* Object::empty_descriptors_ = NULL;
101 LocalVarDescriptors* Object::empty_var_descriptors_ = NULL; 101 LocalVarDescriptors* Object::empty_var_descriptors_ = NULL;
102 ExceptionHandlers* Object::empty_exception_handlers_ = NULL;
102 Instance* Object::sentinel_ = NULL; 103 Instance* Object::sentinel_ = NULL;
103 Instance* Object::transition_sentinel_ = NULL; 104 Instance* Object::transition_sentinel_ = NULL;
104 Instance* Object::unknown_constant_ = NULL; 105 Instance* Object::unknown_constant_ = NULL;
105 Instance* Object::non_constant_ = NULL; 106 Instance* Object::non_constant_ = NULL;
106 Bool* Object::bool_true_ = NULL; 107 Bool* Object::bool_true_ = NULL;
107 Bool* Object::bool_false_ = NULL; 108 Bool* Object::bool_false_ = NULL;
108 Smi* Object::smi_illegal_cid_ = NULL; 109 Smi* Object::smi_illegal_cid_ = NULL;
109 LanguageError* Object::snapshot_writer_error_ = NULL; 110 LanguageError* Object::snapshot_writer_error_ = NULL;
110 LanguageError* Object::branch_offset_error_ = NULL; 111 LanguageError* Object::branch_offset_error_ = NULL;
111 112
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 // Allocate the read only object handles here. 431 // Allocate the read only object handles here.
431 null_object_ = Object::ReadOnlyHandle(); 432 null_object_ = Object::ReadOnlyHandle();
432 null_array_ = Array::ReadOnlyHandle(); 433 null_array_ = Array::ReadOnlyHandle();
433 null_string_ = String::ReadOnlyHandle(); 434 null_string_ = String::ReadOnlyHandle();
434 null_instance_ = Instance::ReadOnlyHandle(); 435 null_instance_ = Instance::ReadOnlyHandle();
435 null_type_arguments_ = TypeArguments::ReadOnlyHandle(); 436 null_type_arguments_ = TypeArguments::ReadOnlyHandle();
436 empty_array_ = Array::ReadOnlyHandle(); 437 empty_array_ = Array::ReadOnlyHandle();
437 zero_array_ = Array::ReadOnlyHandle(); 438 zero_array_ = Array::ReadOnlyHandle();
438 empty_descriptors_ = PcDescriptors::ReadOnlyHandle(); 439 empty_descriptors_ = PcDescriptors::ReadOnlyHandle();
439 empty_var_descriptors_ = LocalVarDescriptors::ReadOnlyHandle(); 440 empty_var_descriptors_ = LocalVarDescriptors::ReadOnlyHandle();
441 empty_exception_handlers_ = ExceptionHandlers::ReadOnlyHandle();
440 sentinel_ = Instance::ReadOnlyHandle(); 442 sentinel_ = Instance::ReadOnlyHandle();
441 transition_sentinel_ = Instance::ReadOnlyHandle(); 443 transition_sentinel_ = Instance::ReadOnlyHandle();
442 unknown_constant_ = Instance::ReadOnlyHandle(); 444 unknown_constant_ = Instance::ReadOnlyHandle();
443 non_constant_ = Instance::ReadOnlyHandle(); 445 non_constant_ = Instance::ReadOnlyHandle();
444 bool_true_ = Bool::ReadOnlyHandle(); 446 bool_true_ = Bool::ReadOnlyHandle();
445 bool_false_ = Bool::ReadOnlyHandle(); 447 bool_false_ = Bool::ReadOnlyHandle();
446 smi_illegal_cid_ = Smi::ReadOnlyHandle(); 448 smi_illegal_cid_ = Smi::ReadOnlyHandle();
447 snapshot_writer_error_ = LanguageError::ReadOnlyHandle(); 449 snapshot_writer_error_ = LanguageError::ReadOnlyHandle();
448 branch_offset_error_ = LanguageError::ReadOnlyHandle(); 450 branch_offset_error_ = LanguageError::ReadOnlyHandle();
449 451
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 heap->Allocate(LocalVarDescriptors::InstanceSize(0), Heap::kOld); 675 heap->Allocate(LocalVarDescriptors::InstanceSize(0), Heap::kOld);
674 InitializeObject(address, 676 InitializeObject(address,
675 kLocalVarDescriptorsCid, 677 kLocalVarDescriptorsCid,
676 LocalVarDescriptors::InstanceSize(0)); 678 LocalVarDescriptors::InstanceSize(0));
677 LocalVarDescriptors::initializeHandle( 679 LocalVarDescriptors::initializeHandle(
678 empty_var_descriptors_, 680 empty_var_descriptors_,
679 reinterpret_cast<RawLocalVarDescriptors*>(address + kHeapObjectTag)); 681 reinterpret_cast<RawLocalVarDescriptors*>(address + kHeapObjectTag));
680 empty_var_descriptors_->raw_ptr()->num_entries_ = 0; 682 empty_var_descriptors_->raw_ptr()->num_entries_ = 0;
681 } 683 }
682 684
685 // Allocate and initialize the canonical empty exception handler info object.
686 // The vast majority of all functions do not contain an exception handler
687 // and can share this cononical descriptor.
srdjan 2014/09/15 23:47:14 s/cononical/cananical/ ;-)
hausner 2014/09/16 00:28:41 Dro Chonoson mot dom Kontroboss, sosson of dor Str
688 {
689 uword address =
690 heap->Allocate(ExceptionHandlers::InstanceSize(0), Heap::kOld);
691 InitializeObject(address,
692 kExceptionHandlersCid,
693 ExceptionHandlers::InstanceSize(0));
694 ExceptionHandlers::initializeHandle(
695 empty_exception_handlers_,
696 reinterpret_cast<RawExceptionHandlers*>(address + kHeapObjectTag));
697 empty_exception_handlers_->raw_ptr()->num_entries_ = 0;
698 }
699
683 cls = Class::New<Instance>(kDynamicCid); 700 cls = Class::New<Instance>(kDynamicCid);
684 cls.set_is_abstract(); 701 cls.set_is_abstract();
685 cls.set_num_type_arguments(0); 702 cls.set_num_type_arguments(0);
686 cls.set_num_own_type_arguments(0); 703 cls.set_num_own_type_arguments(0);
687 cls.set_is_type_finalized(); 704 cls.set_is_type_finalized();
688 cls.set_is_finalized(); 705 cls.set_is_finalized();
689 dynamic_class_ = cls.raw(); 706 dynamic_class_ = cls.raw();
690 707
691 cls = Class::New<Instance>(kVoidCid); 708 cls = Class::New<Instance>(kVoidCid);
692 cls.set_num_type_arguments(0); 709 cls.set_num_type_arguments(0);
(...skipping 10290 matching lines...) Expand 10 before | Expand all | Expand 10 after
10983 } 11000 }
10984 return result.raw(); 11001 return result.raw();
10985 } 11002 }
10986 11003
10987 11004
10988 intptr_t LocalVarDescriptors::Length() const { 11005 intptr_t LocalVarDescriptors::Length() const {
10989 return raw_ptr()->num_entries_; 11006 return raw_ptr()->num_entries_;
10990 } 11007 }
10991 11008
10992 11009
10993 intptr_t ExceptionHandlers::Length() const { 11010 intptr_t ExceptionHandlers::Length() const {
srdjan 2014/09/15 23:47:15 s/Length/num_entries/
hausner 2014/09/16 00:28:41 Done. (But what's the point of having accessors i
10994 return raw_ptr()->length_; 11011 return raw_ptr()->num_entries_;
10995 } 11012 }
10996 11013
10997 11014
10998 void ExceptionHandlers::SetHandlerInfo(intptr_t try_index, 11015 void ExceptionHandlers::SetHandlerInfo(intptr_t try_index,
10999 intptr_t outer_try_index, 11016 intptr_t outer_try_index,
11000 intptr_t handler_pc, 11017 intptr_t handler_pc,
11001 bool needs_stacktrace, 11018 bool needs_stacktrace,
11002 bool has_catch_all) const { 11019 bool has_catch_all) const {
11003 ASSERT((try_index >= 0) && (try_index < Length())); 11020 ASSERT((try_index >= 0) && (try_index < Length()));
11004 RawExceptionHandlers::HandlerInfo* info = &raw_ptr()->data()[try_index]; 11021 RawExceptionHandlers::HandlerInfo* info = &raw_ptr()->data()[try_index];
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
11071 num_handlers); 11088 num_handlers);
11072 } 11089 }
11073 ExceptionHandlers& result = ExceptionHandlers::Handle(); 11090 ExceptionHandlers& result = ExceptionHandlers::Handle();
11074 { 11091 {
11075 uword size = ExceptionHandlers::InstanceSize(num_handlers); 11092 uword size = ExceptionHandlers::InstanceSize(num_handlers);
11076 RawObject* raw = Object::Allocate(ExceptionHandlers::kClassId, 11093 RawObject* raw = Object::Allocate(ExceptionHandlers::kClassId,
11077 size, 11094 size,
11078 Heap::kOld); 11095 Heap::kOld);
11079 NoGCScope no_gc; 11096 NoGCScope no_gc;
11080 result ^= raw; 11097 result ^= raw;
11081 result.raw_ptr()->length_ = num_handlers; 11098 result.raw_ptr()->num_entries_ = num_handlers;
11082 } 11099 }
11083 const Array& handled_types_data = (num_handlers == 0) ? 11100 const Array& handled_types_data = (num_handlers == 0) ?
11084 Object::empty_array() : 11101 Object::empty_array() :
11085 Array::Handle(Array::New(num_handlers)); 11102 Array::Handle(Array::New(num_handlers));
11086 result.set_handled_types_data(handled_types_data); 11103 result.set_handled_types_data(handled_types_data);
11087 return result.raw(); 11104 return result.raw();
11088 } 11105 }
11089 11106
11090 11107
11091 const char* ExceptionHandlers::ToCString() const { 11108 const char* ExceptionHandlers::ToCString() const {
(...skipping 9242 matching lines...) Expand 10 before | Expand all | Expand 10 after
20334 return tag_label.ToCString(); 20351 return tag_label.ToCString();
20335 } 20352 }
20336 20353
20337 20354
20338 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20355 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20339 Instance::PrintJSONImpl(stream, ref); 20356 Instance::PrintJSONImpl(stream, ref);
20340 } 20357 }
20341 20358
20342 20359
20343 } // namespace dart 20360 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698