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

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

Issue 381483002: Allocate fewer empty arrays. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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/flow_graph_compiler.cc ('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 6493 matching lines...) Expand 10 before | Expand all | Expand 10 after
6504 6504
6505 void Function::SaveICDataMap( 6505 void Function::SaveICDataMap(
6506 const ZoneGrowableArray<const ICData*>& deopt_id_to_ic_data) const { 6506 const ZoneGrowableArray<const ICData*>& deopt_id_to_ic_data) const {
6507 // Compute number of ICData objectsto save. 6507 // Compute number of ICData objectsto save.
6508 intptr_t count = 0; 6508 intptr_t count = 0;
6509 for (intptr_t i = 0; i < deopt_id_to_ic_data.length(); i++) { 6509 for (intptr_t i = 0; i < deopt_id_to_ic_data.length(); i++) {
6510 if (deopt_id_to_ic_data[i] != NULL) { 6510 if (deopt_id_to_ic_data[i] != NULL) {
6511 count++; 6511 count++;
6512 } 6512 }
6513 } 6513 }
6514 6514 if (count == 0) {
6515 const Array& a = Array::Handle(Array::New(count, Heap::kOld)); 6515 set_ic_data_array(Object::empty_array());
6516 count = 0; 6516 } else {
6517 for (intptr_t i = 0; i < deopt_id_to_ic_data.length(); i++) { 6517 const Array& a = Array::Handle(Array::New(count, Heap::kOld));
6518 if (deopt_id_to_ic_data[i] != NULL) { 6518 count = 0;
6519 a.SetAt(count++, *deopt_id_to_ic_data[i]); 6519 for (intptr_t i = 0; i < deopt_id_to_ic_data.length(); i++) {
6520 if (deopt_id_to_ic_data[i] != NULL) {
6521 a.SetAt(count++, *deopt_id_to_ic_data[i]);
6522 }
6520 } 6523 }
6524 set_ic_data_array(a);
6521 } 6525 }
6522 set_ic_data_array(a);
6523 } 6526 }
6524 6527
6525 6528
6526 void Function::RestoreICDataMap( 6529 void Function::RestoreICDataMap(
6527 ZoneGrowableArray<const ICData*>* deopt_id_to_ic_data) const { 6530 ZoneGrowableArray<const ICData*>* deopt_id_to_ic_data) const {
6528 Isolate* isolate = Isolate::Current(); 6531 Isolate* isolate = Isolate::Current();
6529 const Array& saved_icd = Array::Handle(isolate, ic_data_array()); 6532 const Array& saved_icd = Array::Handle(isolate, ic_data_array());
6530 if (saved_icd.Length() == 0) { 6533 if (saved_icd.Length() == 0) {
6531 deopt_id_to_ic_data->Clear(); 6534 deopt_id_to_ic_data->Clear();
6532 return;; 6535 return;;
(...skipping 4159 matching lines...) Expand 10 before | Expand all | Expand 10 after
10692 LocalVarDescriptors& result = LocalVarDescriptors::Handle(); 10695 LocalVarDescriptors& result = LocalVarDescriptors::Handle();
10693 { 10696 {
10694 uword size = LocalVarDescriptors::InstanceSize(num_variables); 10697 uword size = LocalVarDescriptors::InstanceSize(num_variables);
10695 RawObject* raw = Object::Allocate(LocalVarDescriptors::kClassId, 10698 RawObject* raw = Object::Allocate(LocalVarDescriptors::kClassId,
10696 size, 10699 size,
10697 Heap::kOld); 10700 Heap::kOld);
10698 NoGCScope no_gc; 10701 NoGCScope no_gc;
10699 result ^= raw; 10702 result ^= raw;
10700 result.raw_ptr()->length_ = num_variables; 10703 result.raw_ptr()->length_ = num_variables;
10701 } 10704 }
10702 const Array& names = Array::Handle(Array::New(num_variables, Heap::kOld)); 10705 const Array& names = (num_variables == 0) ? Object::empty_array() :
10706 Array::Handle(Array::New(num_variables, Heap::kOld));
10703 result.raw_ptr()->names_ = names.raw(); 10707 result.raw_ptr()->names_ = names.raw();
10704 return result.raw(); 10708 return result.raw();
10705 } 10709 }
10706 10710
10707 10711
10708 intptr_t LocalVarDescriptors::Length() const { 10712 intptr_t LocalVarDescriptors::Length() const {
10709 return raw_ptr()->length_; 10713 return raw_ptr()->length_;
10710 } 10714 }
10711 10715
10712 10716
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
10793 ExceptionHandlers& result = ExceptionHandlers::Handle(); 10797 ExceptionHandlers& result = ExceptionHandlers::Handle();
10794 { 10798 {
10795 uword size = ExceptionHandlers::InstanceSize(num_handlers); 10799 uword size = ExceptionHandlers::InstanceSize(num_handlers);
10796 RawObject* raw = Object::Allocate(ExceptionHandlers::kClassId, 10800 RawObject* raw = Object::Allocate(ExceptionHandlers::kClassId,
10797 size, 10801 size,
10798 Heap::kOld); 10802 Heap::kOld);
10799 NoGCScope no_gc; 10803 NoGCScope no_gc;
10800 result ^= raw; 10804 result ^= raw;
10801 result.raw_ptr()->length_ = num_handlers; 10805 result.raw_ptr()->length_ = num_handlers;
10802 } 10806 }
10803 const Array& handled_types_data = Array::Handle(Array::New(num_handlers)); 10807 const Array& handled_types_data = (num_handlers == 0) ?
10808 Object::empty_array() :
10809 Array::Handle(Array::New(num_handlers));
10804 result.set_handled_types_data(handled_types_data); 10810 result.set_handled_types_data(handled_types_data);
10805 return result.raw(); 10811 return result.raw();
10806 } 10812 }
10807 10813
10808 10814
10809 const char* ExceptionHandlers::ToCString() const { 10815 const char* ExceptionHandlers::ToCString() const {
10810 if (Length() == 0) { 10816 if (Length() == 0) {
10811 return "No exception handlers\n"; 10817 return "No exception handlers\n";
10812 } 10818 }
10813 Array& handled_types = Array::Handle(); 10819 Array& handled_types = Array::Handle();
(...skipping 8344 matching lines...) Expand 10 before | Expand all | Expand 10 after
19158 return tag_label.ToCString(); 19164 return tag_label.ToCString();
19159 } 19165 }
19160 19166
19161 19167
19162 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 19168 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
19163 Instance::PrintJSONImpl(stream, ref); 19169 Instance::PrintJSONImpl(stream, ref);
19164 } 19170 }
19165 19171
19166 19172
19167 } // namespace dart 19173 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698