Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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); |
| 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 Loading... | |
| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10321 return chars; | 10331 return chars; |
| 10322 } | 10332 } |
| 10323 | 10333 |
| 10324 | 10334 |
| 10325 void Code::PrintToJSONStream(JSONStream* stream, bool ref) const { | 10335 void Code::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 10326 JSONObject jsobj(stream); | 10336 JSONObject jsobj(stream); |
| 10327 jsobj.AddProperty("type", JSONType(ref)); | 10337 jsobj.AddProperty("type", JSONType(ref)); |
| 10328 jsobj.AddPropertyF("id", "code/%" Px "", EntryPoint()); | 10338 jsobj.AddPropertyF("id", "code/%" Px "", EntryPoint()); |
| 10329 jsobj.AddPropertyF("start", "%" Px "", EntryPoint()); | 10339 jsobj.AddPropertyF("start", "%" Px "", EntryPoint()); |
| 10330 jsobj.AddPropertyF("end", "%" Px "", EntryPoint() + Size()); | 10340 jsobj.AddPropertyF("end", "%" Px "", EntryPoint() + Size()); |
| 10331 Function& func = Function::Handle(); | 10341 jsobj.AddProperty("is_optimized", is_optimized()); |
| 10332 func ^= function(); | 10342 jsobj.AddProperty("is_alive", is_alive()); |
| 10333 ASSERT(!func.IsNull()); | 10343 if (OwnerIsNotNullFunction()) { |
|
Ivan Posva
2014/02/28 21:46:33
How about just adding Code::Name() and Code::UserN
| |
| 10334 String& name = String::Handle(); | 10344 // Dart function. |
| 10335 ASSERT(!func.IsNull()); | 10345 jsobj.AddProperty("kind", "Dart"); |
| 10336 name ^= func.name(); | 10346 Function& func = Function::Handle(); |
| 10337 const char* internal_function_name = name.ToCString(); | 10347 String& name = String::Handle(); |
| 10338 jsobj.AddPropertyF("name", "%s%s", is_optimized() ? "*" : "", | 10348 func ^= function(); |
| 10339 internal_function_name); | 10349 ASSERT(!func.IsNull()); |
| 10340 name ^= func.QualifiedUserVisibleName(); | 10350 name ^= func.name(); |
| 10341 const char* function_name = name.ToCString(); | 10351 ASSERT(!name.IsNull()); |
| 10342 jsobj.AddPropertyF("user_name", "%s%s", is_optimized() ? "*" : "", | 10352 const char* name_c = name.ToCString(); |
| 10343 function_name); | 10353 jsobj.AddPropertyF("name", "%s%s", is_optimized() ? "*" : "", name_c); |
| 10354 name ^= func.QualifiedUserVisibleName(); | |
| 10355 ASSERT(!name.IsNull()); | |
| 10356 name_c = name.ToCString(); | |
| 10357 jsobj.AddPropertyF("user_name", "%s%s", is_optimized() ? "*" : "", name_c); | |
| 10358 jsobj.AddProperty("function", Object::Handle(function())); | |
| 10359 } else if (OwnerIsAllocationStub()) { | |
| 10360 // Allocation stub. | |
| 10361 jsobj.AddProperty("kind", "DartAllocationStub"); | |
| 10362 Isolate* isolate = Isolate::Current(); | |
| 10363 ClassTable* class_table = isolate->class_table(); | |
| 10364 intptr_t cid = Smi::Value(allocation_stub_class_id()); | |
| 10365 Class& cls = Class::Handle(); | |
| 10366 cls ^= class_table->At(cid); | |
| 10367 ASSERT(!cls.IsNull()); | |
| 10368 String& cls_name = String::Handle(cls.UserVisibleName()); | |
| 10369 ASSERT(!cls_name.IsNull()); | |
| 10370 const char* name = cls_name.ToCString(); | |
| 10371 jsobj.AddPropertyF("name", "Allocation stub for %s\n", name); | |
| 10372 jsobj.AddPropertyF("user_name", "Allocation stub for %s\n", name); | |
| 10373 } else { | |
| 10374 // Regular stub. | |
| 10375 jsobj.AddProperty("kind", "DartStub"); | |
| 10376 const char* name = StubCode::NameOfStub(EntryPoint()); | |
| 10377 ASSERT(name != NULL); | |
| 10378 jsobj.AddProperty("name", name); | |
| 10379 jsobj.AddProperty("user_name", name); | |
| 10380 } | |
| 10344 if (ref) { | 10381 if (ref) { |
| 10345 return; | 10382 return; |
| 10346 } | 10383 } |
| 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"); | 10384 JSONArray jsarr(&jsobj, "disassembly"); |
| 10351 if (is_alive()) { | 10385 if (is_alive()) { |
| 10352 // Only disassemble alive code objects. | 10386 // Only disassemble alive code objects. |
| 10353 DisassembleToJSONStream formatter(jsarr); | 10387 DisassembleToJSONStream formatter(jsarr); |
| 10354 Disassemble(&formatter); | 10388 Disassemble(&formatter); |
| 10355 } | 10389 } |
| 10356 } | 10390 } |
| 10357 | 10391 |
| 10358 | 10392 |
| 10359 uword Code::GetPatchCodePc() const { | 10393 uword Code::GetPatchCodePc() const { |
| (...skipping 7066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 17426 return "_MirrorReference"; | 17460 return "_MirrorReference"; |
| 17427 } | 17461 } |
| 17428 | 17462 |
| 17429 | 17463 |
| 17430 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 17464 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 17431 Instance::PrintToJSONStream(stream, ref); | 17465 Instance::PrintToJSONStream(stream, ref); |
| 17432 } | 17466 } |
| 17433 | 17467 |
| 17434 | 17468 |
| 17435 } // namespace dart | 17469 } // namespace dart |
| OLD | NEW |