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

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

Issue 1435533003: Make profiler work without Instructions -> Code pointer (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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/profiler.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 1753 matching lines...) Expand 10 before | Expand all | Expand 10 after
1764 1764
1765 RawString* Object::DictionaryName() const { 1765 RawString* Object::DictionaryName() const {
1766 return String::null(); 1766 return String::null();
1767 } 1767 }
1768 1768
1769 1769
1770 void Object::InitializeObject(uword address, 1770 void Object::InitializeObject(uword address,
1771 intptr_t class_id, 1771 intptr_t class_id,
1772 intptr_t size, 1772 intptr_t size,
1773 bool is_vm_object) { 1773 bool is_vm_object) {
1774 const uword break_instruction_value = Assembler::GetBreakInstructionFiller(); 1774 uword initial_value = (class_id == kInstructionsCid)
1775 const uword null_value = reinterpret_cast<uword>(null_); 1775 ? Assembler::GetBreakInstructionFiller() : reinterpret_cast<uword>(null_);
1776 const bool is_instructions = class_id == kInstructionsCid;
1777 uword initial_value =
1778 is_instructions ? break_instruction_value : null_value;
1779 uword cur = address; 1776 uword cur = address;
1780 uword end = address + size; 1777 uword end = address + size;
1781 if (is_instructions) {
1782 // Fill the header with null. The remainder of the Instructions object will
1783 // be filled with the break_instruction_value.
1784 uword header_end = address + Instructions::HeaderSize();
1785 while (cur < header_end) {
1786 *reinterpret_cast<uword*>(cur) = null_value;
1787 cur += kWordSize;
1788 }
1789 }
1790 while (cur < end) { 1778 while (cur < end) {
1791 *reinterpret_cast<uword*>(cur) = initial_value; 1779 *reinterpret_cast<uword*>(cur) = initial_value;
1792 cur += kWordSize; 1780 cur += kWordSize;
1793 } 1781 }
1794 uword tags = 0; 1782 uword tags = 0;
1795 ASSERT(class_id != kIllegalCid); 1783 ASSERT(class_id != kIllegalCid);
1796 tags = RawObject::ClassIdTag::update(class_id, tags); 1784 tags = RawObject::ClassIdTag::update(class_id, tags);
1797 tags = RawObject::SizeTag::update(size, tags); 1785 tags = RawObject::SizeTag::update(size, tags);
1798 tags = RawObject::VMHeapObjectTag::update(is_vm_object, tags); 1786 tags = RawObject::VMHeapObjectTag::update(is_vm_object, tags);
1799 reinterpret_cast<RawObject*>(address)->tags_ = tags; 1787 reinterpret_cast<RawObject*>(address)->tags_ = tags;
(...skipping 11530 matching lines...) Expand 10 before | Expand all | Expand 10 after
13330 intptr_t pointer_offset_count = assembler->CountPointerOffsets(); 13318 intptr_t pointer_offset_count = assembler->CountPointerOffsets();
13331 Code& code = Code::ZoneHandle(Code::New(pointer_offset_count)); 13319 Code& code = Code::ZoneHandle(Code::New(pointer_offset_count));
13332 #ifdef TARGET_ARCH_IA32 13320 #ifdef TARGET_ARCH_IA32
13333 assembler->set_code_object(code); 13321 assembler->set_code_object(code);
13334 #endif 13322 #endif
13335 Instructions& instrs = 13323 Instructions& instrs =
13336 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize())); 13324 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize()));
13337 INC_STAT(Thread::Current(), total_instr_size, assembler->CodeSize()); 13325 INC_STAT(Thread::Current(), total_instr_size, assembler->CodeSize());
13338 INC_STAT(Thread::Current(), total_code_size, assembler->CodeSize()); 13326 INC_STAT(Thread::Current(), total_code_size, assembler->CodeSize());
13339 13327
13340 instrs.set_code(code.raw());
13341 // Copy the instructions into the instruction area and apply all fixups. 13328 // Copy the instructions into the instruction area and apply all fixups.
13342 // Embedded pointers are still in handles at this point. 13329 // Embedded pointers are still in handles at this point.
13343 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()), 13330 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()),
13344 instrs.size()); 13331 instrs.size());
13345 assembler->FinalizeInstructions(region); 13332 assembler->FinalizeInstructions(region);
13346 VerifiedMemory::Accept(region.start(), region.size()); 13333 VerifiedMemory::Accept(region.start(), region.size());
13347 CPU::FlushICache(instrs.EntryPoint(), instrs.size()); 13334 CPU::FlushICache(instrs.EntryPoint(), instrs.size());
13348 13335
13349 code.set_compile_timestamp(OS::GetCurrentTimeMicros()); 13336 code.set_compile_timestamp(OS::GetCurrentTimeMicros());
13350 CodeObservers::NotifyAll(name, 13337 CodeObservers::NotifyAll(name,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
13411 if (CodeObservers::AreActive()) { 13398 if (CodeObservers::AreActive()) {
13412 return FinalizeCode(function.ToLibNamePrefixedQualifiedCString(), 13399 return FinalizeCode(function.ToLibNamePrefixedQualifiedCString(),
13413 assembler, 13400 assembler,
13414 optimized); 13401 optimized);
13415 } else { 13402 } else {
13416 return FinalizeCode("", assembler); 13403 return FinalizeCode("", assembler);
13417 } 13404 }
13418 } 13405 }
13419 13406
13420 13407
13421 // Check if object matches find condition.
13422 bool Code::FindRawCodeVisitor::FindObject(RawObject* raw_obj) const {
13423 uword tags = raw_obj->ptr()->tags_;
13424 if (RawObject::ClassIdTag::decode(tags) == kInstructionsCid) {
13425 RawInstructions* raw_insts = reinterpret_cast<RawInstructions*>(raw_obj);
13426 return RawInstructions::ContainsPC(raw_insts, pc_);
13427 }
13428 return false;
13429 }
13430
13431
13432 bool Code::SlowFindRawCodeVisitor::FindObject(RawObject* raw_obj) const { 13408 bool Code::SlowFindRawCodeVisitor::FindObject(RawObject* raw_obj) const {
13433 return RawCode::ContainsPC(raw_obj, pc_); 13409 return RawCode::ContainsPC(raw_obj, pc_);
13434 } 13410 }
13435 13411
13436 13412
13437 RawCode* Code::LookupCodeInIsolate(Isolate* isolate, uword pc) { 13413 RawCode* Code::LookupCodeInIsolate(Isolate* isolate, uword pc) {
13438 ASSERT((isolate == Isolate::Current()) || (isolate == Dart::vm_isolate())); 13414 ASSERT((isolate == Isolate::Current()) || (isolate == Dart::vm_isolate()));
13439 if (isolate->heap() == NULL) { 13415 if (isolate->heap() == NULL) {
13440 return Code::null(); 13416 return Code::null();
13441 } 13417 }
13442 NoSafepointScope no_safepoint; 13418 NoSafepointScope no_safepoint;
13443 // TODO(johnmccutchan): Make lookup without a back pointer faster and use for 13419 SlowFindRawCodeVisitor visitor(pc);
13444 // both cases. 13420 RawObject* needle = isolate->heap()->FindOldObject(&visitor);
13445 if (Dart::IsRunningPrecompiledCode()) { 13421 if (needle != Code::null()) {
13446 SlowFindRawCodeVisitor visitor(pc); 13422 return static_cast<RawCode*>(needle);
13447 RawObject* needle = isolate->heap()->FindOldObject(&visitor);
13448 if (needle != Code::null()) {
13449 return static_cast<RawCode*>(needle);
13450 }
13451 return Code::null();
13452 } else {
13453 FindRawCodeVisitor visitor(pc);
13454 RawInstructions* instr;
13455 instr = isolate->heap()->FindObjectInCodeSpace(&visitor);
13456 if (instr != Instructions::null()) {
13457 return Instructions::Handle(instr).code();
13458 }
13459 return Code::null();
13460 } 13423 }
13424 return Code::null();
13461 } 13425 }
13462 13426
13463 13427
13464 RawCode* Code::LookupCode(uword pc) { 13428 RawCode* Code::LookupCode(uword pc) {
13465 return LookupCodeInIsolate(Isolate::Current(), pc); 13429 return LookupCodeInIsolate(Isolate::Current(), pc);
13466 } 13430 }
13467 13431
13468 13432
13469 RawCode* Code::LookupCodeInVmIsolate(uword pc) { 13433 RawCode* Code::LookupCodeInVmIsolate(uword pc) {
13470 return LookupCodeInIsolate(Dart::vm_isolate(), pc); 13434 return LookupCodeInIsolate(Dart::vm_isolate(), pc);
(...skipping 8462 matching lines...) Expand 10 before | Expand all | Expand 10 after
21933 return tag_label.ToCString(); 21897 return tag_label.ToCString();
21934 } 21898 }
21935 21899
21936 21900
21937 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 21901 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
21938 Instance::PrintJSONImpl(stream, ref); 21902 Instance::PrintJSONImpl(stream, ref);
21939 } 21903 }
21940 21904
21941 21905
21942 } // namespace dart 21906 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/profiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698