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

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

Issue 1300033002: Fix compiler stats (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Review comments Created 5 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
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/parser.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/cpu.h" 10 #include "vm/cpu.h"
(...skipping 6859 matching lines...) Expand 10 before | Expand all | Expand 10 after
6870 intptr_t count = 0; 6870 intptr_t count = 0;
6871 for (intptr_t i = 0; i < deopt_id_to_ic_data.length(); i++) { 6871 for (intptr_t i = 0; i < deopt_id_to_ic_data.length(); i++) {
6872 if (deopt_id_to_ic_data[i] != NULL) { 6872 if (deopt_id_to_ic_data[i] != NULL) {
6873 count++; 6873 count++;
6874 } 6874 }
6875 } 6875 }
6876 if (count == 0) { 6876 if (count == 0) {
6877 set_ic_data_array(Object::empty_array()); 6877 set_ic_data_array(Object::empty_array());
6878 } else { 6878 } else {
6879 const Array& a = Array::Handle(Array::New(count, Heap::kOld)); 6879 const Array& a = Array::Handle(Array::New(count, Heap::kOld));
6880 INC_STAT(Isolate::Current(), total_code_size, count * sizeof(uword)); 6880 INC_STAT(Thread::Current(), total_code_size, count * sizeof(uword));
6881 count = 0; 6881 count = 0;
6882 for (intptr_t i = 0; i < deopt_id_to_ic_data.length(); i++) { 6882 for (intptr_t i = 0; i < deopt_id_to_ic_data.length(); i++) {
6883 if (deopt_id_to_ic_data[i] != NULL) { 6883 if (deopt_id_to_ic_data[i] != NULL) {
6884 a.SetAt(count++, *deopt_id_to_ic_data[i]); 6884 a.SetAt(count++, *deopt_id_to_ic_data[i]);
6885 } 6885 }
6886 } 6886 }
6887 set_ic_data_array(a); 6887 set_ic_data_array(a);
6888 } 6888 }
6889 } 6889 }
6890 6890
(...skipping 1679 matching lines...) Expand 10 before | Expand all | Expand 10 after
8570 8570
8571 8571
8572 void Script::set_tokens(const TokenStream& value) const { 8572 void Script::set_tokens(const TokenStream& value) const {
8573 StorePointer(&raw_ptr()->tokens_, value.raw()); 8573 StorePointer(&raw_ptr()->tokens_, value.raw());
8574 } 8574 }
8575 8575
8576 8576
8577 void Script::Tokenize(const String& private_key) const { 8577 void Script::Tokenize(const String& private_key) const {
8578 Thread* thread = Thread::Current(); 8578 Thread* thread = Thread::Current();
8579 Zone* zone = thread->zone(); 8579 Zone* zone = thread->zone();
8580 Isolate* isolate = thread->isolate();
8581 const TokenStream& tkns = TokenStream::Handle(zone, tokens()); 8580 const TokenStream& tkns = TokenStream::Handle(zone, tokens());
8582 if (!tkns.IsNull()) { 8581 if (!tkns.IsNull()) {
8583 // Already tokenized. 8582 // Already tokenized.
8584 return; 8583 return;
8585 } 8584 }
8586 // Get the source, scan and allocate the token stream. 8585 // Get the source, scan and allocate the token stream.
8587 VMTagScope tagScope(thread, VMTag::kCompileScannerTagId); 8586 VMTagScope tagScope(thread, VMTag::kCompileScannerTagId);
8588 CSTAT_TIMER_SCOPE(thread, scanner_timer); 8587 CSTAT_TIMER_SCOPE(thread, scanner_timer);
8589 const String& src = String::Handle(zone, Source()); 8588 const String& src = String::Handle(zone, Source());
8590 Scanner scanner(src, private_key); 8589 Scanner scanner(src, private_key);
8591 set_tokens(TokenStream::Handle(zone, 8590 set_tokens(TokenStream::Handle(zone,
8592 TokenStream::New(scanner.GetStream(), 8591 TokenStream::New(scanner.GetStream(),
8593 private_key))); 8592 private_key)));
8594 INC_STAT(isolate, src_length, src.Length()); 8593 INC_STAT(thread, src_length, src.Length());
8595 } 8594 }
8596 8595
8597 8596
8598 void Script::SetLocationOffset(intptr_t line_offset, 8597 void Script::SetLocationOffset(intptr_t line_offset,
8599 intptr_t col_offset) const { 8598 intptr_t col_offset) const {
8600 ASSERT(line_offset >= 0); 8599 ASSERT(line_offset >= 0);
8601 ASSERT(col_offset >= 0); 8600 ASSERT(col_offset >= 0);
8602 StoreNonPointer(&raw_ptr()->line_offset_, line_offset); 8601 StoreNonPointer(&raw_ptr()->line_offset_, line_offset);
8603 StoreNonPointer(&raw_ptr()->col_offset_, col_offset); 8602 StoreNonPointer(&raw_ptr()->col_offset_, col_offset);
8604 } 8603 }
(...skipping 2496 matching lines...) Expand 10 before | Expand all | Expand 10 after
11101 uint8_t* data = UnsafeMutableNonPointer(&raw_ptr()->data()[0]); 11100 uint8_t* data = UnsafeMutableNonPointer(&raw_ptr()->data()[0]);
11102 for (intptr_t i = 0; i < delta_encoded_data->length(); ++i) { 11101 for (intptr_t i = 0; i < delta_encoded_data->length(); ++i) {
11103 data[i] = (*delta_encoded_data)[i]; 11102 data[i] = (*delta_encoded_data)[i];
11104 } 11103 }
11105 } 11104 }
11106 11105
11107 11106
11108 RawPcDescriptors* PcDescriptors::New(GrowableArray<uint8_t>* data) { 11107 RawPcDescriptors* PcDescriptors::New(GrowableArray<uint8_t>* data) {
11109 ASSERT(Object::pc_descriptors_class() != Class::null()); 11108 ASSERT(Object::pc_descriptors_class() != Class::null());
11110 Thread* thread = Thread::Current(); 11109 Thread* thread = Thread::Current();
11111 Isolate* isolate = thread->isolate();
11112 PcDescriptors& result = PcDescriptors::Handle(thread->zone()); 11110 PcDescriptors& result = PcDescriptors::Handle(thread->zone());
11113 { 11111 {
11114 uword size = PcDescriptors::InstanceSize(data->length()); 11112 uword size = PcDescriptors::InstanceSize(data->length());
11115 RawObject* raw = Object::Allocate(PcDescriptors::kClassId, 11113 RawObject* raw = Object::Allocate(PcDescriptors::kClassId,
11116 size, 11114 size,
11117 Heap::kOld); 11115 Heap::kOld);
11118 INC_STAT(isolate, total_code_size, size); 11116 INC_STAT(thread, total_code_size, size);
11119 INC_STAT(isolate, pc_desc_size, size); 11117 INC_STAT(thread, pc_desc_size, size);
11120 NoSafepointScope no_safepoint; 11118 NoSafepointScope no_safepoint;
11121 result ^= raw; 11119 result ^= raw;
11122 result.SetLength(data->length()); 11120 result.SetLength(data->length());
11123 result.CopyData(data); 11121 result.CopyData(data);
11124 } 11122 }
11125 return result.raw(); 11123 return result.raw();
11126 } 11124 }
11127 11125
11128 11126
11129 RawPcDescriptors* PcDescriptors::New(intptr_t length) { 11127 RawPcDescriptors* PcDescriptors::New(intptr_t length) {
11130 ASSERT(Object::pc_descriptors_class() != Class::null()); 11128 ASSERT(Object::pc_descriptors_class() != Class::null());
11131 Thread* thread = Thread::Current(); 11129 Thread* thread = Thread::Current();
11132 Isolate* isolate = thread->isolate();
11133 PcDescriptors& result = PcDescriptors::Handle(thread->zone()); 11130 PcDescriptors& result = PcDescriptors::Handle(thread->zone());
11134 { 11131 {
11135 uword size = PcDescriptors::InstanceSize(length); 11132 uword size = PcDescriptors::InstanceSize(length);
11136 RawObject* raw = Object::Allocate(PcDescriptors::kClassId, 11133 RawObject* raw = Object::Allocate(PcDescriptors::kClassId,
11137 size, 11134 size,
11138 Heap::kOld); 11135 Heap::kOld);
11139 INC_STAT(isolate, total_code_size, size); 11136 INC_STAT(thread, total_code_size, size);
11140 INC_STAT(isolate, pc_desc_size, size); 11137 INC_STAT(thread, pc_desc_size, size);
11141 NoSafepointScope no_safepoint; 11138 NoSafepointScope no_safepoint;
11142 result ^= raw; 11139 result ^= raw;
11143 result.SetLength(length); 11140 result.SetLength(length);
11144 } 11141 }
11145 return result.raw(); 11142 return result.raw();
11146 } 11143 }
11147 11144
11148 11145
11149 const char* PcDescriptors::KindAsStr(RawPcDescriptors::Kind kind) { 11146 const char* PcDescriptors::KindAsStr(RawPcDescriptors::Kind kind) {
11150 switch (kind) { 11147 switch (kind) {
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
11580 FATAL2("Fatal error in LocalVarDescriptors::New: " 11577 FATAL2("Fatal error in LocalVarDescriptors::New: "
11581 "invalid num_variables %" Pd ". Maximum is: %d\n", 11578 "invalid num_variables %" Pd ". Maximum is: %d\n",
11582 num_variables, RawLocalVarDescriptors::kMaxIndex); 11579 num_variables, RawLocalVarDescriptors::kMaxIndex);
11583 } 11580 }
11584 LocalVarDescriptors& result = LocalVarDescriptors::Handle(); 11581 LocalVarDescriptors& result = LocalVarDescriptors::Handle();
11585 { 11582 {
11586 uword size = LocalVarDescriptors::InstanceSize(num_variables); 11583 uword size = LocalVarDescriptors::InstanceSize(num_variables);
11587 RawObject* raw = Object::Allocate(LocalVarDescriptors::kClassId, 11584 RawObject* raw = Object::Allocate(LocalVarDescriptors::kClassId,
11588 size, 11585 size,
11589 Heap::kOld); 11586 Heap::kOld);
11590 INC_STAT(Isolate::Current(), total_code_size, size); 11587 INC_STAT(Thread::Current(), total_code_size, size);
11591 INC_STAT(Isolate::Current(), vardesc_size, size); 11588 INC_STAT(Thread::Current(), vardesc_size, size);
11592 NoSafepointScope no_safepoint; 11589 NoSafepointScope no_safepoint;
11593 result ^= raw; 11590 result ^= raw;
11594 result.StoreNonPointer(&result.raw_ptr()->num_entries_, num_variables); 11591 result.StoreNonPointer(&result.raw_ptr()->num_entries_, num_variables);
11595 } 11592 }
11596 return result.raw(); 11593 return result.raw();
11597 } 11594 }
11598 11595
11599 11596
11600 intptr_t LocalVarDescriptors::Length() const { 11597 intptr_t LocalVarDescriptors::Length() const {
11601 return raw_ptr()->num_entries_; 11598 return raw_ptr()->num_entries_;
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after
12722 12719
12723 12720
12724 void Code::set_is_alive(bool value) const { 12721 void Code::set_is_alive(bool value) const {
12725 set_state_bits(AliveBit::update(value, raw_ptr()->state_bits_)); 12722 set_state_bits(AliveBit::update(value, raw_ptr()->state_bits_));
12726 } 12723 }
12727 12724
12728 12725
12729 void Code::set_stackmaps(const Array& maps) const { 12726 void Code::set_stackmaps(const Array& maps) const {
12730 ASSERT(maps.IsOld()); 12727 ASSERT(maps.IsOld());
12731 StorePointer(&raw_ptr()->stackmaps_, maps.raw()); 12728 StorePointer(&raw_ptr()->stackmaps_, maps.raw());
12732 INC_STAT(Isolate::Current(), 12729 INC_STAT(Thread::Current(),
12733 total_code_size, 12730 total_code_size,
12734 maps.IsNull() ? 0 : maps.Length() * sizeof(uword)); 12731 maps.IsNull() ? 0 : maps.Length() * sizeof(uword));
12735 } 12732 }
12736 12733
12737 12734
12738 void Code::set_deopt_info_array(const Array& array) const { 12735 void Code::set_deopt_info_array(const Array& array) const {
12739 ASSERT(array.IsOld()); 12736 ASSERT(array.IsOld());
12740 StorePointer(&raw_ptr()->deopt_info_array_, array.raw()); 12737 StorePointer(&raw_ptr()->deopt_info_array_, array.raw());
12741 } 12738 }
12742 12739
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
13026 const ObjectPool& object_pool = 13023 const ObjectPool& object_pool =
13027 ObjectPool::Handle(assembler->object_pool_wrapper().MakeObjectPool()); 13024 ObjectPool::Handle(assembler->object_pool_wrapper().MakeObjectPool());
13028 13025
13029 // Allocate the Code and Instructions objects. Code is allocated first 13026 // Allocate the Code and Instructions objects. Code is allocated first
13030 // because a GC during allocation of the code will leave the instruction 13027 // because a GC during allocation of the code will leave the instruction
13031 // pages read-only. 13028 // pages read-only.
13032 intptr_t pointer_offset_count = assembler->CountPointerOffsets(); 13029 intptr_t pointer_offset_count = assembler->CountPointerOffsets();
13033 Code& code = Code::ZoneHandle(Code::New(pointer_offset_count)); 13030 Code& code = Code::ZoneHandle(Code::New(pointer_offset_count));
13034 Instructions& instrs = 13031 Instructions& instrs =
13035 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize())); 13032 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize()));
13036 INC_STAT(isolate, total_instr_size, assembler->CodeSize()); 13033 INC_STAT(Thread::Current(), total_instr_size, assembler->CodeSize());
13037 INC_STAT(isolate, total_code_size, assembler->CodeSize()); 13034 INC_STAT(Thread::Current(), total_code_size, assembler->CodeSize());
13038 13035
13039 // Copy the instructions into the instruction area and apply all fixups. 13036 // Copy the instructions into the instruction area and apply all fixups.
13040 // Embedded pointers are still in handles at this point. 13037 // Embedded pointers are still in handles at this point.
13041 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()), 13038 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()),
13042 instrs.size()); 13039 instrs.size());
13043 assembler->FinalizeInstructions(region); 13040 assembler->FinalizeInstructions(region);
13044 VerifiedMemory::Accept(region.start(), region.size()); 13041 VerifiedMemory::Accept(region.start(), region.size());
13045 CPU::FlushICache(instrs.EntryPoint(), instrs.size()); 13042 CPU::FlushICache(instrs.EntryPoint(), instrs.size());
13046 13043
13047 code.set_compile_timestamp(OS::GetCurrentTimeMicros()); 13044 code.set_compile_timestamp(OS::GetCurrentTimeMicros());
(...skipping 19 matching lines...) Expand all
13067 instrs.raw()->StorePointer(reinterpret_cast<RawObject**>(addr), 13064 instrs.raw()->StorePointer(reinterpret_cast<RawObject**>(addr),
13068 object->raw()); 13065 object->raw());
13069 } 13066 }
13070 13067
13071 // Hook up Code and Instructions objects. 13068 // Hook up Code and Instructions objects.
13072 instrs.set_code(code.raw()); 13069 instrs.set_code(code.raw());
13073 code.set_instructions(instrs.raw()); 13070 code.set_instructions(instrs.raw());
13074 code.set_is_alive(true); 13071 code.set_is_alive(true);
13075 13072
13076 // Set object pool in Instructions object. 13073 // Set object pool in Instructions object.
13077 INC_STAT(isolate, 13074 INC_STAT(Thread::Current(),
13078 total_code_size, object_pool.Length() * sizeof(uintptr_t)); 13075 total_code_size, object_pool.Length() * sizeof(uintptr_t));
13079 instrs.set_object_pool(object_pool.raw()); 13076 instrs.set_object_pool(object_pool.raw());
13080 13077
13081 if (FLAG_write_protect_code) { 13078 if (FLAG_write_protect_code) {
13082 uword address = RawObject::ToAddr(instrs.raw()); 13079 uword address = RawObject::ToAddr(instrs.raw());
13083 bool status = VirtualMemory::Protect( 13080 bool status = VirtualMemory::Protect(
13084 reinterpret_cast<void*>(address), 13081 reinterpret_cast<void*>(address),
13085 instrs.raw()->Size(), 13082 instrs.raw()->Size(),
13086 VirtualMemory::kReadExecute); 13083 VirtualMemory::kReadExecute);
13087 ASSERT(status); 13084 ASSERT(status);
13088 } 13085 }
13089 } 13086 }
13090 code.set_comments(assembler->GetCodeComments()); 13087 code.set_comments(assembler->GetCodeComments());
13091 if (assembler->prologue_offset() >= 0) { 13088 if (assembler->prologue_offset() >= 0) {
13092 code.SetPrologueOffset(assembler->prologue_offset()); 13089 code.SetPrologueOffset(assembler->prologue_offset());
13093 } else { 13090 } else {
13094 // No prologue was ever entered, optimistically assume nothing was ever 13091 // No prologue was ever entered, optimistically assume nothing was ever
13095 // pushed onto the stack. 13092 // pushed onto the stack.
13096 code.SetPrologueOffset(assembler->CodeSize()); 13093 code.SetPrologueOffset(assembler->CodeSize());
13097 } 13094 }
13098 INC_STAT(isolate, 13095 INC_STAT(Thread::Current(),
13099 total_code_size, code.comments().comments_.Length()); 13096 total_code_size, code.comments().comments_.Length());
13100 return code.raw(); 13097 return code.raw();
13101 } 13098 }
13102 13099
13103 13100
13104 RawCode* Code::FinalizeCode(const Function& function, 13101 RawCode* Code::FinalizeCode(const Function& function,
13105 Assembler* assembler, 13102 Assembler* assembler,
13106 bool optimized) { 13103 bool optimized) {
13107 // Calling ToLibNamePrefixedQualifiedCString is very expensive, 13104 // Calling ToLibNamePrefixedQualifiedCString is very expensive,
13108 // try to avoid it. 13105 // try to avoid it.
(...skipping 8417 matching lines...) Expand 10 before | Expand all | Expand 10 after
21526 return tag_label.ToCString(); 21523 return tag_label.ToCString();
21527 } 21524 }
21528 21525
21529 21526
21530 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 21527 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
21531 Instance::PrintJSONImpl(stream, ref); 21528 Instance::PrintJSONImpl(stream, ref);
21532 } 21529 }
21533 21530
21534 21531
21535 } // namespace dart 21532 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698