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

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
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_function(*this);
Ivan Posva 2014/02/28 21:46:32 How about just value.set_owner(*this)? The set_own
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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
4850 Function& outer_function = Function::Handle(parent_function()); 4850 Function& outer_function = Function::Handle(parent_function());
4851 while (outer_function.IsLocalFunction()) { 4851 while (outer_function.IsLocalFunction()) {
4852 outer_function = outer_function.parent_function(); 4852 outer_function = outer_function.parent_function();
4853 } 4853 }
4854 return outer_function.IsFactory(); 4854 return outer_function.IsFactory();
4855 } 4855 }
4856 4856
4857 4857
4858 void Function::set_name(const String& value) const { 4858 void Function::set_name(const String& value) const {
4859 ASSERT(value.IsSymbol()); 4859 ASSERT(value.IsSymbol());
4860 if (value.IsNull()) {
Ivan Posva 2014/02/28 21:46:32 Debugging code...
4861 printf("Function given null name.\n");
turnidge 2014/02/28 19:23:37 Debug printf?
Cutch 2014/02/28 19:37:08 Done.
4862 }
4863 if (value.IsSymbol() == false) {
4864 printf("Function name is not a symbol.\n");
turnidge 2014/02/28 19:23:37 Debug printf?
Cutch 2014/02/28 19:37:08 Done.
4865 }
4860 StorePointer(&raw_ptr()->name_, value.raw()); 4866 StorePointer(&raw_ptr()->name_, value.raw());
4861 } 4867 }
4862 4868
4863 4869
4864 void Function::set_owner(const Object& value) const { 4870 void Function::set_owner(const Object& value) const {
4865 ASSERT(!value.IsNull()); 4871 ASSERT(!value.IsNull());
4866 StorePointer(&raw_ptr()->owner_, value.raw()); 4872 StorePointer(&raw_ptr()->owner_, value.raw());
4867 } 4873 }
4868 4874
4869 4875
(...skipping 5381 matching lines...) Expand 10 before | Expand all | Expand 10 after
10251 } 10257 }
10252 } 10258 }
10253 10259
10254 10260
10255 // Check if object matches find condition. 10261 // Check if object matches find condition.
10256 bool Code::FindRawCodeVisitor::FindObject(RawObject* obj) const { 10262 bool Code::FindRawCodeVisitor::FindObject(RawObject* obj) const {
10257 return RawInstructions::ContainsPC(obj, pc_); 10263 return RawInstructions::ContainsPC(obj, pc_);
10258 } 10264 }
10259 10265
10260 10266
10261 RawCode* Code::LookupCode(uword pc) { 10267 RawCode* Code::LookupCodeInIsolate(Isolate* isolate, uword pc) {
10262 Isolate* isolate = Isolate::Current(); 10268 ASSERT((isolate == Isolate::Current()) || (isolate == Dart::vm_isolate()));
10263 NoGCScope no_gc; 10269 NoGCScope no_gc;
10264 FindRawCodeVisitor visitor(pc); 10270 FindRawCodeVisitor visitor(pc);
10265 RawInstructions* instr; 10271 RawInstructions* instr;
10266 if (isolate->heap() == NULL) { 10272 if (isolate->heap() == NULL) {
10267 return Code::null(); 10273 return Code::null();
10268 } 10274 }
10269 instr = isolate->heap()->FindObjectInCodeSpace(&visitor); 10275 instr = isolate->heap()->FindObjectInCodeSpace(&visitor);
10270 if (instr != Instructions::null()) { 10276 if (instr != Instructions::null()) {
10271 return instr->ptr()->code_; 10277 return instr->ptr()->code_;
10272 } 10278 }
10273 return Code::null(); 10279 return Code::null();
10274 } 10280 }
10275 10281
10276 10282
10283 RawCode* Code::LookupCode(uword pc) {
10284 return LookupCodeInIsolate(Isolate::Current(), pc);
10285 }
10286
10287
10288 RawCode* Code::LookupCodeInVmIsolate(uword pc) {
10289 return LookupCodeInIsolate(Dart::vm_isolate(), pc);
10290 }
10291
10292
10277 intptr_t Code::GetTokenIndexOfPC(uword pc) const { 10293 intptr_t Code::GetTokenIndexOfPC(uword pc) const {
10278 intptr_t token_pos = -1; 10294 intptr_t token_pos = -1;
10279 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); 10295 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors());
10280 for (intptr_t i = 0; i < descriptors.Length(); i++) { 10296 for (intptr_t i = 0; i < descriptors.Length(); i++) {
10281 if (descriptors.PC(i) == pc) { 10297 if (descriptors.PC(i) == pc) {
10282 token_pos = descriptors.TokenPos(i); 10298 token_pos = descriptors.TokenPos(i);
10283 break; 10299 break;
10284 } 10300 }
10285 } 10301 }
10286 return token_pos; 10302 return token_pos;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
10321 return chars; 10337 return chars;
10322 } 10338 }
10323 10339
10324 10340
10325 void Code::PrintToJSONStream(JSONStream* stream, bool ref) const { 10341 void Code::PrintToJSONStream(JSONStream* stream, bool ref) const {
10326 JSONObject jsobj(stream); 10342 JSONObject jsobj(stream);
10327 jsobj.AddProperty("type", JSONType(ref)); 10343 jsobj.AddProperty("type", JSONType(ref));
10328 jsobj.AddPropertyF("id", "code/%" Px "", EntryPoint()); 10344 jsobj.AddPropertyF("id", "code/%" Px "", EntryPoint());
10329 jsobj.AddPropertyF("start", "%" Px "", EntryPoint()); 10345 jsobj.AddPropertyF("start", "%" Px "", EntryPoint());
10330 jsobj.AddPropertyF("end", "%" Px "", EntryPoint() + Size()); 10346 jsobj.AddPropertyF("end", "%" Px "", EntryPoint() + Size());
10331 Function& func = Function::Handle(); 10347 jsobj.AddProperty("is_optimized", is_optimized());
10332 func ^= function(); 10348 jsobj.AddProperty("is_alive", is_alive());
10333 ASSERT(!func.IsNull()); 10349 if (OwnerIsNotNullFunction()) {
turnidge 2014/02/28 19:23:37 I don't care for negations in predicate names unle
Cutch 2014/02/28 19:37:08 Done.
10334 String& name = String::Handle(); 10350 // Dart function.
10335 ASSERT(!func.IsNull()); 10351 jsobj.AddProperty("kind", "Dart");
10336 name ^= func.name(); 10352 Function& func = Function::Handle();
10337 const char* internal_function_name = name.ToCString(); 10353 String& name = String::Handle();
10338 jsobj.AddPropertyF("name", "%s%s", is_optimized() ? "*" : "", 10354 func ^= function();
10339 internal_function_name); 10355 ASSERT(!func.IsNull());
10340 name ^= func.QualifiedUserVisibleName(); 10356 name ^= func.name();
10341 const char* function_name = name.ToCString(); 10357 ASSERT(!name.IsNull());
10342 jsobj.AddPropertyF("user_name", "%s%s", is_optimized() ? "*" : "", 10358 const char* name_c = name.ToCString();
10343 function_name); 10359 jsobj.AddPropertyF("name", "%s%s", is_optimized() ? "*" : "", name_c);
10360 name ^= func.QualifiedUserVisibleName();
10361 ASSERT(!name.IsNull());
10362 name_c = name.ToCString();
10363 jsobj.AddPropertyF("user_name", "%s%s", is_optimized() ? "*" : "", name_c);
10364 jsobj.AddProperty("function", Object::Handle(function()));
10365 } else if (OwnerIsAllocationStub()) {
10366 // Allocation stub.
10367 jsobj.AddProperty("kind", "DartAllocationStub");
10368 Isolate* isolate = Isolate::Current();
10369 ClassTable* class_table = isolate->class_table();
10370 intptr_t cid = Smi::Value(allocation_stub_class_id());
10371 Class& cls = Class::Handle();
10372 cls ^= class_table->At(cid);
10373 ASSERT(!cls.IsNull());
10374 String& cls_name = String::Handle(cls.UserVisibleName());
10375 ASSERT(!cls_name.IsNull());
10376 const char* name = cls_name.ToCString();
10377 jsobj.AddPropertyF("name", "Allocation stub for %s\n", name);
10378 jsobj.AddPropertyF("user_name", "Allocation stub for %s\n", name);
10379 } else {
10380 // Regular stub.
10381 jsobj.AddProperty("kind", "DartStub");
10382 const char* name = StubCode::NameOfStub(EntryPoint());
10383 ASSERT(name != NULL);
10384 jsobj.AddProperty("name", name);
10385 jsobj.AddProperty("user_name", name);
10386 }
10344 if (ref) { 10387 if (ref) {
10345 return; 10388 return;
10346 } 10389 }
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"); 10390 JSONArray jsarr(&jsobj, "disassembly");
10351 if (is_alive()) { 10391 if (is_alive()) {
10352 // Only disassemble alive code objects. 10392 // Only disassemble alive code objects.
10353 DisassembleToJSONStream formatter(jsarr); 10393 DisassembleToJSONStream formatter(jsarr);
10354 Disassemble(&formatter); 10394 Disassemble(&formatter);
10355 } 10395 }
10356 } 10396 }
10357 10397
10358 10398
10359 uword Code::GetPatchCodePc() const { 10399 uword Code::GetPatchCodePc() const {
(...skipping 7066 matching lines...) Expand 10 before | Expand all | Expand 10 after
17426 return "_MirrorReference"; 17466 return "_MirrorReference";
17427 } 17467 }
17428 17468
17429 17469
17430 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 17470 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
17431 Instance::PrintToJSONStream(stream, ref); 17471 Instance::PrintToJSONStream(stream, ref);
17432 } 17472 }
17433 17473
17434 17474
17435 } // namespace dart 17475 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698