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

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

Issue 1188973003: Port "Add snapshoting methods for code's metadata." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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/raw_object_snapshot.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 10824 matching lines...) Expand 10 before | Expand all | Expand 10 after
10835 INC_STAT(isolate, pc_desc_size, size); 10835 INC_STAT(isolate, pc_desc_size, size);
10836 NoSafepointScope no_safepoint; 10836 NoSafepointScope no_safepoint;
10837 result ^= raw; 10837 result ^= raw;
10838 result.SetLength(data->length()); 10838 result.SetLength(data->length());
10839 result.CopyData(data); 10839 result.CopyData(data);
10840 } 10840 }
10841 return result.raw(); 10841 return result.raw();
10842 } 10842 }
10843 10843
10844 10844
10845 RawPcDescriptors* PcDescriptors::New(intptr_t length) {
10846 ASSERT(Object::pc_descriptors_class() != Class::null());
10847 Isolate* isolate = Isolate::Current();
10848 PcDescriptors& result = PcDescriptors::Handle(isolate);
10849 {
10850 uword size = PcDescriptors::InstanceSize(length);
10851 RawObject* raw = Object::Allocate(PcDescriptors::kClassId,
10852 size,
10853 Heap::kOld);
10854 INC_STAT(isolate, total_code_size, size);
10855 INC_STAT(isolate, pc_desc_size, size);
10856 NoSafepointScope no_safepoint;
10857 result ^= raw;
10858 result.SetLength(length);
10859 }
10860 return result.raw();
10861 }
10862
10863
10845 const char* PcDescriptors::KindAsStr(RawPcDescriptors::Kind kind) { 10864 const char* PcDescriptors::KindAsStr(RawPcDescriptors::Kind kind) {
10846 switch (kind) { 10865 switch (kind) {
10847 case RawPcDescriptors::kDeopt: return "deopt "; 10866 case RawPcDescriptors::kDeopt: return "deopt ";
10848 case RawPcDescriptors::kIcCall: return "ic-call "; 10867 case RawPcDescriptors::kIcCall: return "ic-call ";
10849 case RawPcDescriptors::kUnoptStaticCall: return "unopt-call "; 10868 case RawPcDescriptors::kUnoptStaticCall: return "unopt-call ";
10850 case RawPcDescriptors::kRuntimeCall: return "runtime-call "; 10869 case RawPcDescriptors::kRuntimeCall: return "runtime-call ";
10851 case RawPcDescriptors::kOsrEntry: return "osr-entry "; 10870 case RawPcDescriptors::kOsrEntry: return "osr-entry ";
10852 case RawPcDescriptors::kOther: return "other "; 10871 case RawPcDescriptors::kOther: return "other ";
10853 case RawPcDescriptors::kAnyKind: UNREACHABLE(); break; 10872 case RawPcDescriptors::kAnyKind: UNREACHABLE(); break;
10854 } 10873 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
11032 ASSERT(pc_offset >= 0); 11051 ASSERT(pc_offset >= 0);
11033 result.SetPcOffset(pc_offset); 11052 result.SetPcOffset(pc_offset);
11034 for (intptr_t i = 0; i < length; ++i) { 11053 for (intptr_t i = 0; i < length; ++i) {
11035 result.SetBit(i, bmap->Get(i)); 11054 result.SetBit(i, bmap->Get(i));
11036 } 11055 }
11037 result.SetRegisterBitCount(register_bit_count); 11056 result.SetRegisterBitCount(register_bit_count);
11038 return result.raw(); 11057 return result.raw();
11039 } 11058 }
11040 11059
11041 11060
11061 RawStackmap* Stackmap::New(intptr_t length,
11062 intptr_t register_bit_count,
11063 intptr_t pc_offset) {
11064 ASSERT(Object::stackmap_class() != Class::null());
11065 Stackmap& result = Stackmap::Handle();
11066 // Guard against integer overflow of the instance size computation.
11067 intptr_t payload_size =
11068 Utils::RoundUp(length, kBitsPerByte) / kBitsPerByte;
11069 if ((payload_size < 0) ||
11070 (payload_size > kMaxLengthInBytes)) {
11071 // This should be caught before we reach here.
11072 FATAL1("Fatal error in Stackmap::New: invalid length %" Pd "\n",
11073 length);
11074 }
11075 {
11076 // Stackmap data objects are associated with a code object, allocate them
11077 // in old generation.
11078 RawObject* raw = Object::Allocate(Stackmap::kClassId,
11079 Stackmap::InstanceSize(length),
11080 Heap::kOld);
11081 NoSafepointScope no_safepoint;
11082 result ^= raw;
11083 result.SetLength(length);
11084 }
11085 // When constructing a stackmap we store the pc offset in the stackmap's
11086 // PC. StackmapTableBuilder::FinalizeStackmaps will replace it with the pc
11087 // address.
11088 ASSERT(pc_offset >= 0);
11089 result.SetPcOffset(pc_offset);
11090 result.SetRegisterBitCount(register_bit_count);
11091 return result.raw();
11092 }
11093
11094
11042 const char* Stackmap::ToCString() const { 11095 const char* Stackmap::ToCString() const {
11043 if (IsNull()) { 11096 if (IsNull()) {
11044 return "{null}"; 11097 return "{null}";
11045 } else { 11098 } else {
11046 const char* kFormat = "%#" Px ": "; 11099 const char* kFormat = "%#" Px ": ";
11047 intptr_t fixed_length = OS::SNPrint(NULL, 0, kFormat, PcOffset()) + 1; 11100 intptr_t fixed_length = OS::SNPrint(NULL, 0, kFormat, PcOffset()) + 1;
11048 Isolate* isolate = Isolate::Current(); 11101 Isolate* isolate = Isolate::Current();
11049 // Guard against integer overflow in the computation of alloc_size. 11102 // Guard against integer overflow in the computation of alloc_size.
11050 // 11103 //
11051 // TODO(kmillikin): We could just truncate the string if someone 11104 // TODO(kmillikin): We could just truncate the string if someone
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
11353 result.StoreNonPointer(&result.raw_ptr()->num_entries_, num_handlers); 11406 result.StoreNonPointer(&result.raw_ptr()->num_entries_, num_handlers);
11354 } 11407 }
11355 const Array& handled_types_data = (num_handlers == 0) ? 11408 const Array& handled_types_data = (num_handlers == 0) ?
11356 Object::empty_array() : 11409 Object::empty_array() :
11357 Array::Handle(Array::New(num_handlers)); 11410 Array::Handle(Array::New(num_handlers));
11358 result.set_handled_types_data(handled_types_data); 11411 result.set_handled_types_data(handled_types_data);
11359 return result.raw(); 11412 return result.raw();
11360 } 11413 }
11361 11414
11362 11415
11416 RawExceptionHandlers* ExceptionHandlers::New(const Array& handled_types_data) {
11417 ASSERT(Object::exception_handlers_class() != Class::null());
11418 const intptr_t num_handlers = handled_types_data.Length();
11419 if ((num_handlers < 0) || (num_handlers >= kMaxHandlers)) {
11420 FATAL1("Fatal error in ExceptionHandlers::New(): "
11421 "invalid num_handlers %" Pd "\n",
11422 num_handlers);
11423 }
11424 ExceptionHandlers& result = ExceptionHandlers::Handle();
11425 {
11426 uword size = ExceptionHandlers::InstanceSize(num_handlers);
11427 RawObject* raw = Object::Allocate(ExceptionHandlers::kClassId,
11428 size,
11429 Heap::kOld);
11430 NoSafepointScope no_safepoint;
11431 result ^= raw;
11432 result.StoreNonPointer(&result.raw_ptr()->num_entries_, num_handlers);
11433 }
11434 result.set_handled_types_data(handled_types_data);
11435 return result.raw();
11436 }
11437
11438
11363 const char* ExceptionHandlers::ToCString() const { 11439 const char* ExceptionHandlers::ToCString() const {
11364 if (num_entries() == 0) { 11440 if (num_entries() == 0) {
11365 return "No exception handlers\n"; 11441 return "No exception handlers\n";
11366 } 11442 }
11367 Array& handled_types = Array::Handle(); 11443 Array& handled_types = Array::Handle();
11368 Type& type = Type::Handle(); 11444 Type& type = Type::Handle();
11369 RawExceptionHandlers::HandlerInfo info; 11445 RawExceptionHandlers::HandlerInfo info;
11370 // First compute the buffer size required. 11446 // First compute the buffer size required.
11371 const char* kFormat = "%" Pd " => %#" Px " (%" Pd 11447 const char* kFormat = "%" Pd " => %#" Px " (%" Pd
11372 " types) (outer %" Pd ")\n"; 11448 " types) (outer %" Pd ")\n";
(...skipping 9617 matching lines...) Expand 10 before | Expand all | Expand 10 after
20990 return tag_label.ToCString(); 21066 return tag_label.ToCString();
20991 } 21067 }
20992 21068
20993 21069
20994 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 21070 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20995 Instance::PrintJSONImpl(stream, ref); 21071 Instance::PrintJSONImpl(stream, ref);
20996 } 21072 }
20997 21073
20998 21074
20999 } // namespace dart 21075 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698