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 6093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6104 id = cls.FindFunctionIndex(*this); | 6104 id = cls.FindFunctionIndex(*this); |
| 6105 selector = "functions"; | 6105 selector = "functions"; |
| 6106 } | 6106 } |
| 6107 ASSERT(id >= 0); | 6107 ASSERT(id >= 0); |
| 6108 intptr_t cid = cls.id(); | 6108 intptr_t cid = cls.id(); |
| 6109 JSONObject jsobj(stream); | 6109 JSONObject jsobj(stream); |
| 6110 jsobj.AddProperty("type", JSONType(ref)); | 6110 jsobj.AddProperty("type", JSONType(ref)); |
| 6111 jsobj.AddPropertyF("id", "classes/%" Pd "/%s/%" Pd "", cid, selector, id); | 6111 jsobj.AddPropertyF("id", "classes/%" Pd "/%s/%" Pd "", cid, selector, id); |
| 6112 jsobj.AddProperty("name", internal_name); | 6112 jsobj.AddProperty("name", internal_name); |
| 6113 jsobj.AddProperty("user_name", user_name); | 6113 jsobj.AddProperty("user_name", user_name); |
| 6114 jsobj.AddProperty("class", cls); | |
| 6115 const char* kind_string = Function::KindToCString(kind()); | |
| 6116 jsobj.AddProperty("kind", kind_string); | |
| 6114 if (ref) return; | 6117 if (ref) return; |
| 6115 jsobj.AddProperty("is_static", is_static()); | 6118 jsobj.AddProperty("is_static", is_static()); |
| 6116 jsobj.AddProperty("is_const", is_const()); | 6119 jsobj.AddProperty("is_const", is_const()); |
| 6117 jsobj.AddProperty("is_optimizable", is_optimizable()); | 6120 jsobj.AddProperty("is_optimizable", is_optimizable()); |
| 6118 jsobj.AddProperty("is_inlinable", IsInlineable()); | 6121 jsobj.AddProperty("is_inlinable", IsInlineable()); |
| 6119 const char* kind_string = Function::KindToCString(kind()); | |
| 6120 jsobj.AddProperty("kind", kind_string); | |
| 6121 jsobj.AddProperty("unoptimized_code", Object::Handle(unoptimized_code())); | 6122 jsobj.AddProperty("unoptimized_code", Object::Handle(unoptimized_code())); |
| 6122 jsobj.AddProperty("usage_counter", usage_counter()); | 6123 jsobj.AddProperty("usage_counter", usage_counter()); |
| 6123 jsobj.AddProperty("optimized_call_site_count", optimized_call_site_count()); | 6124 jsobj.AddProperty("optimized_call_site_count", optimized_call_site_count()); |
| 6124 jsobj.AddProperty("code", Object::Handle(CurrentCode())); | 6125 jsobj.AddProperty("code", Object::Handle(CurrentCode())); |
| 6125 jsobj.AddProperty("deoptimizations", | 6126 jsobj.AddProperty("deoptimizations", |
| 6126 static_cast<intptr_t>(deoptimization_counter())); | 6127 static_cast<intptr_t>(deoptimization_counter())); |
| 6127 } | 6128 } |
| 6128 | 6129 |
| 6129 | 6130 |
| 6130 void ClosureData::set_context_scope(const ContextScope& value) const { | 6131 void ClosureData::set_context_scope(const ContextScope& value) const { |
| (...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6867 for (int i = 0; i < indent; i++) { | 6868 for (int i = 0; i < indent; i++) { |
| 6868 literals.Add(Symbols::TwoSpaces()); | 6869 literals.Add(Symbols::TwoSpaces()); |
| 6869 } | 6870 } |
| 6870 } | 6871 } |
| 6871 | 6872 |
| 6872 // Setup for next iteration. | 6873 // Setup for next iteration. |
| 6873 prev = curr; | 6874 prev = curr; |
| 6874 curr = next; | 6875 curr = next; |
| 6875 } | 6876 } |
| 6876 const Array& source = Array::Handle(Array::MakeArray(literals)); | 6877 const Array& source = Array::Handle(Array::MakeArray(literals)); |
| 6877 return String::ConcatAll(source); | 6878 const String& s = String::Handle(String::ConcatAll(source)); |
| 6879 return s.raw(); | |
|
turnidge
2014/03/10 21:03:28
Why this delta?
Cutch
2014/03/11 03:17:48
Removed.
| |
| 6878 } | 6880 } |
| 6879 | 6881 |
| 6880 | 6882 |
| 6881 intptr_t TokenStream::ComputeSourcePosition(intptr_t tok_pos) const { | 6883 intptr_t TokenStream::ComputeSourcePosition(intptr_t tok_pos) const { |
| 6882 Iterator iterator(*this, 0, Iterator::kAllTokens); | 6884 Iterator iterator(*this, 0, Iterator::kAllTokens); |
| 6883 intptr_t src_pos = 0; | 6885 intptr_t src_pos = 0; |
| 6884 Token::Kind kind = iterator.CurrentTokenKind(); | 6886 Token::Kind kind = iterator.CurrentTokenKind(); |
| 6885 while (iterator.CurrentPosition() < tok_pos && kind != Token::kEOS) { | 6887 while (iterator.CurrentPosition() < tok_pos && kind != Token::kEOS) { |
| 6886 iterator.Advance(); | 6888 iterator.Advance(); |
| 6887 kind = iterator.CurrentTokenKind(); | 6889 kind = iterator.CurrentTokenKind(); |
| (...skipping 3575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10463 jsobj.AddProperty("is_optimized", is_optimized()); | 10465 jsobj.AddProperty("is_optimized", is_optimized()); |
| 10464 jsobj.AddProperty("is_alive", is_alive()); | 10466 jsobj.AddProperty("is_alive", is_alive()); |
| 10465 const String& name = String::Handle(Name()); | 10467 const String& name = String::Handle(Name()); |
| 10466 const String& user_name = String::Handle(UserName()); | 10468 const String& user_name = String::Handle(UserName()); |
| 10467 const char* name_prefix = is_optimized() ? "*" : ""; | 10469 const char* name_prefix = is_optimized() ? "*" : ""; |
| 10468 jsobj.AddPropertyF("name", "%s%s", name_prefix, name.ToCString()); | 10470 jsobj.AddPropertyF("name", "%s%s", name_prefix, name.ToCString()); |
| 10469 jsobj.AddPropertyF("user_name", "%s%s", name_prefix, user_name.ToCString()); | 10471 jsobj.AddPropertyF("user_name", "%s%s", name_prefix, user_name.ToCString()); |
| 10470 const Object& obj = Object::Handle(owner()); | 10472 const Object& obj = Object::Handle(owner()); |
| 10471 if (obj.IsFunction()) { | 10473 if (obj.IsFunction()) { |
| 10472 jsobj.AddProperty("function", obj); | 10474 jsobj.AddProperty("function", obj); |
| 10475 } else { | |
| 10476 // Generate a fake function reference. | |
| 10477 JSONObject func(&jsobj, "function"); | |
| 10478 func.AddProperty("type", "@Function"); | |
| 10479 func.AddProperty("kind", "Stub"); | |
| 10480 func.AddPropertyF("id", "stub/functions/%" Pd "", EntryPoint()); | |
| 10481 func.AddProperty("user_name", user_name.ToCString()); | |
| 10482 func.AddProperty("name", name.ToCString()); | |
| 10473 } | 10483 } |
| 10474 if (ref) { | 10484 if (ref) { |
| 10475 return; | 10485 return; |
| 10476 } | 10486 } |
| 10477 JSONArray jsarr(&jsobj, "disassembly"); | 10487 JSONArray jsarr(&jsobj, "disassembly"); |
| 10478 if (is_alive()) { | 10488 if (is_alive()) { |
| 10479 // Only disassemble alive code objects. | 10489 // Only disassemble alive code objects. |
| 10480 DisassembleToJSONStream formatter(jsarr); | 10490 DisassembleToJSONStream formatter(jsarr); |
| 10481 Disassemble(&formatter); | 10491 Disassemble(&formatter); |
| 10482 } | 10492 } |
| (...skipping 4912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 15395 if (len > 0) { | 15405 if (len > 0) { |
| 15396 result[len] = 0; | 15406 result[len] = 0; |
| 15397 return reinterpret_cast<const char*>(result); | 15407 return reinterpret_cast<const char*>(result); |
| 15398 } | 15408 } |
| 15399 } | 15409 } |
| 15400 const intptr_t len = Utf8::Length(*this); | 15410 const intptr_t len = Utf8::Length(*this); |
| 15401 Zone* zone = Isolate::Current()->current_zone(); | 15411 Zone* zone = Isolate::Current()->current_zone(); |
| 15402 uint8_t* result = zone->Alloc<uint8_t>(len + 1); | 15412 uint8_t* result = zone->Alloc<uint8_t>(len + 1); |
| 15403 ToUTF8(result, len); | 15413 ToUTF8(result, len); |
| 15404 result[len] = 0; | 15414 result[len] = 0; |
| 15415 ASSERT(Utf8::IsValid(result, len)); | |
|
turnidge
2014/03/10 21:03:28
Is this expensive for our debug builds?
Cutch
2014/03/11 03:17:48
I haven't noticed but I've removed it.
| |
| 15405 return reinterpret_cast<const char*>(result); | 15416 return reinterpret_cast<const char*>(result); |
| 15406 } | 15417 } |
| 15407 | 15418 |
| 15408 | 15419 |
| 15409 static bool IsAsciiPrintChar(intptr_t code_point) { | 15420 static bool IsAsciiPrintChar(intptr_t code_point) { |
| 15410 return code_point >= ' ' && code_point <= '~'; | 15421 return code_point >= ' ' && code_point <= '~'; |
| 15411 } | 15422 } |
| 15412 | 15423 |
| 15413 | 15424 |
| 15414 // Does not null-terminate. | 15425 // Does not null-terminate. |
| (...skipping 2153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 17568 return "_MirrorReference"; | 17579 return "_MirrorReference"; |
| 17569 } | 17580 } |
| 17570 | 17581 |
| 17571 | 17582 |
| 17572 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 17583 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 17573 Instance::PrintToJSONStream(stream, ref); | 17584 Instance::PrintToJSONStream(stream, ref); |
| 17574 } | 17585 } |
| 17575 | 17586 |
| 17576 | 17587 |
| 17577 } // namespace dart | 17588 } // namespace dart |
| OLD | NEW |