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

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

Issue 12260026: Add support for object pool (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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') | runtime/vm/raw_object.h » ('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/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 7630 matching lines...) Expand 10 before | Expand all | Expand 10 after
7641 // Set pointer offsets list in Code object and resolve all handles in 7641 // Set pointer offsets list in Code object and resolve all handles in
7642 // the instruction stream to raw objects. 7642 // the instruction stream to raw objects.
7643 ASSERT(code.pointer_offsets_length() == pointer_offsets.length()); 7643 ASSERT(code.pointer_offsets_length() == pointer_offsets.length());
7644 for (int i = 0; i < pointer_offsets.length(); i++) { 7644 for (int i = 0; i < pointer_offsets.length(); i++) {
7645 int offset_in_instrs = pointer_offsets[i]; 7645 int offset_in_instrs = pointer_offsets[i];
7646 code.SetPointerOffsetAt(i, offset_in_instrs); 7646 code.SetPointerOffsetAt(i, offset_in_instrs);
7647 const Object* object = region.Load<const Object*>(offset_in_instrs); 7647 const Object* object = region.Load<const Object*>(offset_in_instrs);
7648 region.Store<RawObject*>(offset_in_instrs, object->raw()); 7648 region.Store<RawObject*>(offset_in_instrs, object->raw());
7649 } 7649 }
7650 7650
7651 // Hook up Code and Instruction objects. 7651 // Hook up Code and Instructions objects.
7652 instrs.set_code(code.raw()); 7652 instrs.set_code(code.raw());
7653 code.set_instructions(instrs.raw()); 7653 code.set_instructions(instrs.raw());
7654
7655 // Set object pool in Instructions object.
7656 instrs.set_object_pool(Array::MakeArray(assembler->object_pool()));
7654 } 7657 }
7655 return code.raw(); 7658 return code.raw();
7656 } 7659 }
7657 7660
7658 7661
7659 RawCode* Code::FinalizeCode(const Function& function, 7662 RawCode* Code::FinalizeCode(const Function& function,
7660 Assembler* assembler, 7663 Assembler* assembler,
7661 bool optimized) { 7664 bool optimized) {
7662 // Calling ToFullyQualifiedCString is very expensive, try to avoid it. 7665 // Calling ToFullyQualifiedCString is very expensive, try to avoid it.
7663 if (CodeObservers::AreActive()) { 7666 if (CodeObservers::AreActive()) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
7701 return token_pos; 7704 return token_pos;
7702 } 7705 }
7703 7706
7704 7707
7705 uword Code::GetPcForDeoptId(intptr_t deopt_id, PcDescriptors::Kind kind) const { 7708 uword Code::GetPcForDeoptId(intptr_t deopt_id, PcDescriptors::Kind kind) const {
7706 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); 7709 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors());
7707 for (intptr_t i = 0; i < descriptors.Length(); i++) { 7710 for (intptr_t i = 0; i < descriptors.Length(); i++) {
7708 if ((descriptors.DeoptId(i) == deopt_id) && 7711 if ((descriptors.DeoptId(i) == deopt_id) &&
7709 (descriptors.DescriptorKind(i) == kind)) { 7712 (descriptors.DescriptorKind(i) == kind)) {
7710 uword pc = descriptors.PC(i); 7713 uword pc = descriptors.PC(i);
7711 ASSERT((EntryPoint() <= pc) && (pc < (EntryPoint() + Size()))); 7714 ASSERT(ContainsInstructionAt(pc));
7712 return pc; 7715 return pc;
7713 } 7716 }
7714 } 7717 }
7715 return 0; 7718 return 0;
7716 } 7719 }
7717 7720
7718 7721
7719 uword Code::GetDeoptBeforePcAtDeoptId(intptr_t deopt_id) const { 7722 uword Code::GetDeoptBeforePcAtDeoptId(intptr_t deopt_id) const {
7720 ASSERT(!is_optimized()); 7723 ASSERT(!is_optimized());
7721 return GetPcForDeoptId(deopt_id, PcDescriptors::kDeoptBefore); 7724 return GetPcForDeoptId(deopt_id, PcDescriptors::kDeoptBefore);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
7770 PcDescriptors::Handle(this->pc_descriptors()); 7773 PcDescriptors::Handle(this->pc_descriptors());
7771 ICData& ic_data_obj = ICData::Handle(); 7774 ICData& ic_data_obj = ICData::Handle();
7772 intptr_t max_id = -1; 7775 intptr_t max_id = -1;
7773 for (intptr_t i = 0; i < descriptors.Length(); i++) { 7776 for (intptr_t i = 0; i < descriptors.Length(); i++) {
7774 if (descriptors.DescriptorKind(i) == PcDescriptors::kIcCall) { 7777 if (descriptors.DescriptorKind(i) == PcDescriptors::kIcCall) {
7775 intptr_t deopt_id = descriptors.DeoptId(i); 7778 intptr_t deopt_id = descriptors.DeoptId(i);
7776 if (deopt_id > max_id) { 7779 if (deopt_id > max_id) {
7777 max_id = deopt_id; 7780 max_id = deopt_id;
7778 } 7781 }
7779 node_ids->Add(deopt_id); 7782 node_ids->Add(deopt_id);
7780 CodePatcher::GetInstanceCallAt(descriptors.PC(i), &ic_data_obj, NULL); 7783 CodePatcher::GetInstanceCallAt(descriptors.PC(i), *this,
7784 &ic_data_obj, NULL);
7781 ic_data_objs.Add(ic_data_obj); 7785 ic_data_objs.Add(ic_data_obj);
7782 } 7786 }
7783 } 7787 }
7784 return max_id; 7788 return max_id;
7785 } 7789 }
7786 7790
7787 7791
7788 RawArray* Code::ExtractTypeFeedbackArray() const { 7792 RawArray* Code::ExtractTypeFeedbackArray() const {
7789 ASSERT(!IsNull() && !is_optimized()); 7793 ASSERT(!IsNull() && !is_optimized());
7790 GrowableArray<intptr_t> deopt_ids; 7794 GrowableArray<intptr_t> deopt_ids;
(...skipping 15 matching lines...) Expand all
7806 GrowableArray<intptr_t>* deopt_ids) const { 7810 GrowableArray<intptr_t>* deopt_ids) const {
7807 ASSERT(!IsNull() && !is_optimized()); 7811 ASSERT(!IsNull() && !is_optimized());
7808 ASSERT(deopt_ids != NULL); 7812 ASSERT(deopt_ids != NULL);
7809 deopt_ids->Clear(); 7813 deopt_ids->Clear();
7810 const PcDescriptors& descriptors = 7814 const PcDescriptors& descriptors =
7811 PcDescriptors::Handle(this->pc_descriptors()); 7815 PcDescriptors::Handle(this->pc_descriptors());
7812 for (intptr_t i = 0; i < descriptors.Length(); i++) { 7816 for (intptr_t i = 0; i < descriptors.Length(); i++) {
7813 if (descriptors.DescriptorKind(i) == PcDescriptors::kFuncCall) { 7817 if (descriptors.DescriptorKind(i) == PcDescriptors::kFuncCall) {
7814 // Static call. 7818 // Static call.
7815 const uword target_addr = 7819 const uword target_addr =
7816 CodePatcher::GetStaticCallTargetAt(descriptors.PC(i)); 7820 CodePatcher::GetStaticCallTargetAt(descriptors.PC(i), *this);
7817 if (target_addr == StubCode::CallStaticFunctionEntryPoint()) { 7821 if (target_addr == StubCode::CallStaticFunctionEntryPoint()) {
7818 deopt_ids->Add(descriptors.DeoptId(i)); 7822 deopt_ids->Add(descriptors.DeoptId(i));
7819 } 7823 }
7820 } 7824 }
7821 } 7825 }
7822 } 7826 }
7823 7827
7824 7828
7825 RawStackmap* Code::GetStackmap(uword pc, Array* maps, Stackmap* map) const { 7829 RawStackmap* Code::GetStackmap(uword pc, Array* maps, Stackmap* map) const {
7826 // This code is used during iterating frames during a GC and hence it 7830 // This code is used during iterating frames during a GC and hence it
(...skipping 4056 matching lines...) Expand 10 before | Expand all | Expand 10 after
11883 Object& obj = Object::Handle(); 11887 Object& obj = Object::Handle();
11884 for (int i = 0; i < len; i++) { 11888 for (int i = 0; i < len; i++) {
11885 obj = source.At(i); 11889 obj = source.At(i);
11886 result.SetAt(i, obj); 11890 result.SetAt(i, obj);
11887 } 11891 }
11888 return result.raw(); 11892 return result.raw();
11889 } 11893 }
11890 11894
11891 11895
11892 RawArray* Array::MakeArray(const GrowableObjectArray& growable_array) { 11896 RawArray* Array::MakeArray(const GrowableObjectArray& growable_array) {
11897 if (growable_array.IsNull()) {
11898 return Array::null();
11899 }
11893 intptr_t used_len = growable_array.Length(); 11900 intptr_t used_len = growable_array.Length();
11894 intptr_t capacity_len = growable_array.Capacity(); 11901 intptr_t capacity_len = growable_array.Capacity();
11895 Isolate* isolate = Isolate::Current(); 11902 Isolate* isolate = Isolate::Current();
11896 const Array& array = Array::Handle(isolate, growable_array.data()); 11903 const Array& array = Array::Handle(isolate, growable_array.data());
11897 intptr_t capacity_size = Array::InstanceSize(capacity_len); 11904 intptr_t capacity_size = Array::InstanceSize(capacity_len);
11898 intptr_t used_size = Array::InstanceSize(used_len); 11905 intptr_t used_size = Array::InstanceSize(used_len);
11899 NoGCScope no_gc; 11906 NoGCScope no_gc;
11900 11907
11901 // Update the size in the header field and length of the array object. 11908 // Update the size in the header field and length of the array object.
11902 uword tags = array.raw_ptr()->tags_; 11909 uword tags = array.raw_ptr()->tags_;
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after
12885 } 12892 }
12886 return result.raw(); 12893 return result.raw();
12887 } 12894 }
12888 12895
12889 12896
12890 const char* WeakProperty::ToCString() const { 12897 const char* WeakProperty::ToCString() const {
12891 return "_WeakProperty"; 12898 return "_WeakProperty";
12892 } 12899 }
12893 12900
12894 } // namespace dart 12901 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698