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

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

Issue 182703003: Cleanup native, collected, and stub code handling in profiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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/profiler.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 4510 matching lines...) Expand 10 before | Expand all | Expand 10 after
4521 4521
4522 bool Function::HasBreakpoint() const { 4522 bool Function::HasBreakpoint() const {
4523 return Isolate::Current()->debugger()->HasBreakpoint(*this); 4523 return Isolate::Current()->debugger()->HasBreakpoint(*this);
4524 } 4524 }
4525 4525
4526 4526
4527 void Function::SetCode(const Code& value) const { 4527 void Function::SetCode(const Code& value) const {
4528 StorePointer(&raw_ptr()->code_, value.raw()); 4528 StorePointer(&raw_ptr()->code_, value.raw());
4529 ASSERT(Function::Handle(value.function()).IsNull() || 4529 ASSERT(Function::Handle(value.function()).IsNull() ||
4530 (value.function() == this->raw())); 4530 (value.function() == this->raw()));
4531 value.set_function(*this); 4531 value.set_owner(*this);
4532 } 4532 }
4533 4533
4534 4534
4535 void Function::SwitchToUnoptimizedCode() const { 4535 void Function::SwitchToUnoptimizedCode() const {
4536 ASSERT(HasOptimizedCode()); 4536 ASSERT(HasOptimizedCode());
4537 4537
4538 const Code& current_code = Code::Handle(CurrentCode()); 4538 const Code& current_code = Code::Handle(CurrentCode());
4539 4539
4540 // Optimized code object might have been actually fully produced by the 4540 // Optimized code object might have been actually fully produced by the
4541 // intrinsifier in this case nothing has to be done. In fact an attempt to 4541 // intrinsifier in this case nothing has to be done. In fact an attempt to
(...skipping 5709 matching lines...) Expand 10 before | Expand all | Expand 10 after
10251 } 10251 }
10252 } 10252 }
10253 10253
10254 10254
10255 // Check if object matches find condition. 10255 // Check if object matches find condition.
10256 bool Code::FindRawCodeVisitor::FindObject(RawObject* obj) const { 10256 bool Code::FindRawCodeVisitor::FindObject(RawObject* obj) const {
10257 return RawInstructions::ContainsPC(obj, pc_); 10257 return RawInstructions::ContainsPC(obj, pc_);
10258 } 10258 }
10259 10259
10260 10260
10261 RawCode* Code::LookupCode(uword pc) { 10261 RawCode* Code::LookupCodeInIsolate(Isolate* isolate, uword pc) {
10262 Isolate* isolate = Isolate::Current(); 10262 ASSERT((isolate == Isolate::Current()) || (isolate == Dart::vm_isolate()));
10263 NoGCScope no_gc; 10263 NoGCScope no_gc;
10264 FindRawCodeVisitor visitor(pc); 10264 FindRawCodeVisitor visitor(pc);
10265 RawInstructions* instr; 10265 RawInstructions* instr;
10266 if (isolate->heap() == NULL) { 10266 if (isolate->heap() == NULL) {
10267 return Code::null(); 10267 return Code::null();
10268 } 10268 }
10269 instr = isolate->heap()->FindObjectInCodeSpace(&visitor); 10269 instr = isolate->heap()->FindObjectInCodeSpace(&visitor);
10270 if (instr != Instructions::null()) { 10270 if (instr != Instructions::null()) {
10271 return instr->ptr()->code_; 10271 return instr->ptr()->code_;
10272 } 10272 }
10273 return Code::null(); 10273 return Code::null();
10274 } 10274 }
10275 10275
10276 10276
10277 RawCode* Code::LookupCode(uword pc) {
10278 return LookupCodeInIsolate(Isolate::Current(), pc);
10279 }
10280
10281
10282 RawCode* Code::LookupCodeInVmIsolate(uword pc) {
10283 return LookupCodeInIsolate(Dart::vm_isolate(), pc);
10284 }
10285
10286
10277 intptr_t Code::GetTokenIndexOfPC(uword pc) const { 10287 intptr_t Code::GetTokenIndexOfPC(uword pc) const {
10278 intptr_t token_pos = -1; 10288 intptr_t token_pos = -1;
10279 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); 10289 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors());
10280 for (intptr_t i = 0; i < descriptors.Length(); i++) { 10290 for (intptr_t i = 0; i < descriptors.Length(); i++) {
10281 if (descriptors.PC(i) == pc) { 10291 if (descriptors.PC(i) == pc) {
10282 token_pos = descriptors.TokenPos(i); 10292 token_pos = descriptors.TokenPos(i);
10283 break; 10293 break;
10284 } 10294 }
10285 } 10295 }
10286 return token_pos; 10296 return token_pos;
(...skipping 28 matching lines...) Expand all
10315 10325
10316 const char* Code::ToCString() const { 10326 const char* Code::ToCString() const {
10317 const char* kFormat = "Code entry:%p"; 10327 const char* kFormat = "Code entry:%p";
10318 intptr_t len = OS::SNPrint(NULL, 0, kFormat, EntryPoint()) + 1; 10328 intptr_t len = OS::SNPrint(NULL, 0, kFormat, EntryPoint()) + 1;
10319 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 10329 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
10320 OS::SNPrint(chars, len, kFormat, EntryPoint()); 10330 OS::SNPrint(chars, len, kFormat, EntryPoint());
10321 return chars; 10331 return chars;
10322 } 10332 }
10323 10333
10324 10334
10335 RawString* Code::Name() const {
10336 const Object& obj = Object::Handle(owner());
10337 if (obj.IsNull()) {
10338 // Regular stub.
10339 const char* name = StubCode::NameOfStub(EntryPoint());
10340 ASSERT(name != NULL);
10341 return String::New(name);
10342 } else if (obj.IsClass()) {
10343 // Allocation stub.
10344 const Class& cls = Class::Cast(obj);
10345 String& cls_name = String::Handle(cls.Name());
10346 ASSERT(!cls_name.IsNull());
10347 return String::Concat(Symbols::AllocationStubFor(), cls_name);
10348 } else {
10349 ASSERT(obj.IsFunction());
10350 // Dart function.
10351 return Function::Cast(obj).name();
10352 }
10353 }
10354
10355
10356 RawString* Code::UserName() const {
10357 const Object& obj = Object::Handle(owner());
10358 if (obj.IsNull()) {
10359 // Regular stub.
10360 const char* name = StubCode::NameOfStub(EntryPoint());
10361 ASSERT(name != NULL);
10362 return String::New(name);
10363 } else if (obj.IsClass()) {
10364 // Allocation stub.
10365 const Class& cls = Class::Cast(obj);
10366 String& cls_name = String::Handle(cls.Name());
10367 ASSERT(!cls_name.IsNull());
10368 return String::Concat(Symbols::AllocationStubFor(), cls_name);
10369 } else {
10370 ASSERT(obj.IsFunction());
10371 // Dart function.
10372 return Function::Cast(obj).QualifiedUserVisibleName();
10373 }
10374 }
10375
10376
10325 void Code::PrintToJSONStream(JSONStream* stream, bool ref) const { 10377 void Code::PrintToJSONStream(JSONStream* stream, bool ref) const {
10326 JSONObject jsobj(stream); 10378 JSONObject jsobj(stream);
10327 jsobj.AddProperty("type", JSONType(ref)); 10379 jsobj.AddProperty("type", JSONType(ref));
10328 jsobj.AddPropertyF("id", "code/%" Px "", EntryPoint()); 10380 jsobj.AddPropertyF("id", "code/%" Px "", EntryPoint());
10329 jsobj.AddPropertyF("start", "%" Px "", EntryPoint()); 10381 jsobj.AddPropertyF("start", "%" Px "", EntryPoint());
10330 jsobj.AddPropertyF("end", "%" Px "", EntryPoint() + Size()); 10382 jsobj.AddPropertyF("end", "%" Px "", EntryPoint() + Size());
10331 Function& func = Function::Handle(); 10383 jsobj.AddProperty("is_optimized", is_optimized());
10332 func ^= function(); 10384 jsobj.AddProperty("is_alive", is_alive());
10333 ASSERT(!func.IsNull()); 10385 const String& name = String::Handle(Name());
10334 String& name = String::Handle(); 10386 const String& user_name = String::Handle(UserName());
10335 ASSERT(!func.IsNull()); 10387 const char* name_prefix = is_optimized() ? "*" : "";
10336 name ^= func.name(); 10388 jsobj.AddPropertyF("name", "%s%s", name_prefix, name.ToCString());
10337 const char* internal_function_name = name.ToCString(); 10389 jsobj.AddPropertyF("user_name", "%s%s", name_prefix, user_name.ToCString());
10338 jsobj.AddPropertyF("name", "%s%s", is_optimized() ? "*" : "", 10390 const Object& obj = Object::Handle(owner());
10339 internal_function_name); 10391 if (obj.IsFunction()) {
10340 name ^= func.QualifiedUserVisibleName(); 10392 jsobj.AddProperty("function", obj);
10341 const char* function_name = name.ToCString(); 10393 }
10342 jsobj.AddPropertyF("user_name", "%s%s", is_optimized() ? "*" : "",
10343 function_name);
10344 if (ref) { 10394 if (ref) {
10345 return; 10395 return;
10346 } 10396 }
10347 jsobj.AddProperty("is_optimized", is_optimized());
10348 jsobj.AddProperty("is_alive", is_alive());
10349 jsobj.AddProperty("function", Object::Handle(function()));
10350 JSONArray jsarr(&jsobj, "disassembly"); 10397 JSONArray jsarr(&jsobj, "disassembly");
10351 if (is_alive()) { 10398 if (is_alive()) {
10352 // Only disassemble alive code objects. 10399 // Only disassemble alive code objects.
10353 DisassembleToJSONStream formatter(jsarr); 10400 DisassembleToJSONStream formatter(jsarr);
10354 Disassemble(&formatter); 10401 Disassemble(&formatter);
10355 } 10402 }
10356 } 10403 }
10357 10404
10358 10405
10359 uword Code::GetPatchCodePc() const { 10406 uword Code::GetPatchCodePc() const {
(...skipping 7066 matching lines...) Expand 10 before | Expand all | Expand 10 after
17426 return "_MirrorReference"; 17473 return "_MirrorReference";
17427 } 17474 }
17428 17475
17429 17476
17430 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 17477 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
17431 Instance::PrintToJSONStream(stream, ref); 17478 Instance::PrintToJSONStream(stream, ref);
17432 } 17479 }
17433 17480
17434 17481
17435 } // namespace dart 17482 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698