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

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

Issue 10832292: Reduce space used for stackmaps. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Restore inadvertently deleted code. Created 8 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 | Annotate | Revision Log
« runtime/vm/object.h ('K') | « 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/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 6835 matching lines...) Expand 10 before | Expand all | Expand 10 after
6846 uint8_t byte_mask = 1U << bit_remainder; 6846 uint8_t byte_mask = 1U << bit_remainder;
6847 uint8_t* byte_addr = &(raw_ptr()->data_[byte_index]); 6847 uint8_t* byte_addr = &(raw_ptr()->data_[byte_index]);
6848 if (value) { 6848 if (value) {
6849 *byte_addr |= byte_mask; 6849 *byte_addr |= byte_mask;
6850 } else { 6850 } else {
6851 *byte_addr &= ~byte_mask; 6851 *byte_addr &= ~byte_mask;
6852 } 6852 }
6853 } 6853 }
6854 6854
6855 6855
6856 RawStackmap* Stackmap::New(uword pc_offset, BitmapBuilder* bmap) { 6856 RawStackmap* Stackmap::New(intptr_t pc_offset,
6857 intptr_t length_in_bits,
6858 BitmapBuilder* bmap) {
6857 ASSERT(Object::stackmap_class() != Class::null()); 6859 ASSERT(Object::stackmap_class() != Class::null());
6858 ASSERT(bmap != NULL); 6860 ASSERT(bmap != NULL);
6859 Stackmap& result = Stackmap::Handle(); 6861 Stackmap& result = Stackmap::Handle();
6860 intptr_t size = bmap->SizeInBytes(); 6862 intptr_t length_in_bytes =
Kevin Millikin (Google) 2012/08/14 13:02:32 Here we need to use the number of bytes covered by
6861 if (size < 0 || size > kMaxElements) { 6863 Utils::RoundUp(length_in_bits, kBitsPerByte) / kBitsPerByte;
6864 if (length_in_bytes < 0 || length_in_bytes > kMaxLengthInBytes) {
6862 // This should be caught before we reach here. 6865 // This should be caught before we reach here.
6863 FATAL1("Fatal error in PcDescriptors::New: invalid size %ld\n", size); 6866 FATAL1("Fatal error in Stackmap::New: invalid length %" PRIdPTR "\n",
6867 length_in_bytes);
6864 } 6868 }
6865 { 6869 {
6866 // Stackmap data objects are associated with a code object, allocate them 6870 // Stackmap data objects are associated with a code object, allocate them
6867 // in old generation. 6871 // in old generation.
6868 RawObject* raw = Object::Allocate(Stackmap::kClassId, 6872 RawObject* raw = Object::Allocate(Stackmap::kClassId,
6869 Stackmap::InstanceSize(size), 6873 Stackmap::InstanceSize(length_in_bytes),
6870 Heap::kOld); 6874 Heap::kOld);
6871 NoGCScope no_gc; 6875 NoGCScope no_gc;
6872 result ^= raw; 6876 result ^= raw;
6873 result.set_bitmap_size_in_bytes(size); 6877 result.set_bitmap_size_in_bytes(length_in_bytes);
Vyacheslav Egorov (Google) 2012/08/15 14:17:37 I would prefer store length in bits here.
Kevin Millikin (Google) 2012/08/15 14:41:31 That is part of the next change.
6874 } 6878 }
6879 // When constructing a stackmap we store the pc offset in the stackmap's
6880 // PC. StackmapTableBuilder::FinalizeStackmaps will replace it with the pc
6881 // address.
6882 ASSERT(pc_offset >= 0);
6875 result.SetPC(pc_offset); 6883 result.SetPC(pc_offset);
6876 intptr_t bound = bmap->SizeInBits(); 6884 for (intptr_t i = 0; i < length_in_bits; i++) {
6877 for (intptr_t i = 0; i < bound; i++) {
6878 result.SetBit(i, bmap->Get(i)); 6885 result.SetBit(i, bmap->Get(i));
6879 } 6886 }
6887 ASSERT(bmap->Maximum() < length_in_bits);
6880 result.SetMinBitIndex(bmap->Minimum()); 6888 result.SetMinBitIndex(bmap->Minimum());
6881 result.SetMaxBitIndex(bmap->Maximum()); 6889 result.SetMaxBitIndex(bmap->Maximum());
6882 return result.raw(); 6890 return result.raw();
6883 } 6891 }
6884 6892
6885 6893
6886 void Stackmap::set_bitmap_size_in_bytes(intptr_t value) const { 6894 void Stackmap::set_bitmap_size_in_bytes(intptr_t value) const {
6887 // This is only safe because we create a new Smi, which does not cause 6895 // This is only safe because we create a new Smi, which does not cause
6888 // heap allocation. 6896 // heap allocation.
6889 raw_ptr()->bitmap_size_in_bytes_ = Smi::New(value); 6897 raw_ptr()->bitmap_size_in_bytes_ = Smi::New(value);
6890 } 6898 }
6891 6899
6892 6900
6893 const char* Stackmap::ToCString() const { 6901 const char* Stackmap::ToCString() const {
6894 if (IsNull()) { 6902 if (IsNull()) {
6895 return "{null}"; 6903 return "{null}";
6896 } else { 6904 } else {
6897 // Guard against integer overflow, though it is highly unlikely. 6905 // Guard against integer overflow, though it is highly unlikely.
6898 if (MaximumBitIndex() > kIntptrMax / 4) { 6906 if (MaximumBitIndex() > kIntptrMax / 4) {
6899 FATAL1("MaximumBitIndex() is unexpectedly large (%ld)", 6907 FATAL1("MaximumBitIndex() is unexpectedly large (%" PRIdPTR ")",
6900 MaximumBitIndex()); 6908 MaximumBitIndex());
6901 } 6909 }
6902 intptr_t index = OS::SNPrint(NULL, 0, "0x%lx { ", PC()); 6910 intptr_t index = OS::SNPrint(NULL, 0, "0x%" PRIxPTR " { ", PC());
6903 intptr_t alloc_size = 6911 intptr_t alloc_size =
6904 index + ((MaximumBitIndex() + 1) * 2) + 2; // "{ 1 0 .... }". 6912 index + ((MaximumBitIndex() + 1) * 2) + 2; // "{ 1 0 .... }".
6905 Isolate* isolate = Isolate::Current(); 6913 Isolate* isolate = Isolate::Current();
6906 char* chars = isolate->current_zone()->Alloc<char>(alloc_size); 6914 char* chars = isolate->current_zone()->Alloc<char>(alloc_size);
6907 index = OS::SNPrint(chars, alloc_size, "0x%lx { ", PC()); 6915 index = OS::SNPrint(chars, alloc_size, "0x%" PRIxPTR " { ", PC());
6908 for (intptr_t i = 0; i <= MaximumBitIndex(); i++) { 6916 for (intptr_t i = 0; i <= MaximumBitIndex(); i++) {
6909 index += OS::SNPrint((chars + index), 6917 index += OS::SNPrint((chars + index),
6910 (alloc_size - index), 6918 (alloc_size - index),
6911 "%d ", 6919 "%d ",
6912 IsObject(i) ? 1 : 0); 6920 IsObject(i) ? 1 : 0);
6913 } 6921 }
6914 OS::SNPrint((chars + index), (alloc_size - index), "}"); 6922 OS::SNPrint((chars + index), (alloc_size - index), "}");
6915 return chars; 6923 return chars;
6916 } 6924 }
6917 } 6925 }
(...skipping 4283 matching lines...) Expand 10 before | Expand all | Expand 10 after
11201 const char* JSRegExp::ToCString() const { 11209 const char* JSRegExp::ToCString() const {
11202 const String& str = String::Handle(pattern()); 11210 const String& str = String::Handle(pattern());
11203 const char* format = "JSRegExp: pattern=%s flags=%s"; 11211 const char* format = "JSRegExp: pattern=%s flags=%s";
11204 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 11212 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
11205 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); 11213 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
11206 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 11214 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
11207 return chars; 11215 return chars;
11208 } 11216 }
11209 11217
11210 } // namespace dart 11218 } // namespace dart
OLDNEW
« runtime/vm/object.h ('K') | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698