| 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 25 matching lines...) Expand all Loading... |
| 36 #include "vm/object_id_ring.h" | 36 #include "vm/object_id_ring.h" |
| 37 #include "vm/object_store.h" | 37 #include "vm/object_store.h" |
| 38 #include "vm/parser.h" | 38 #include "vm/parser.h" |
| 39 #include "vm/reusable_handles.h" | 39 #include "vm/reusable_handles.h" |
| 40 #include "vm/runtime_entry.h" | 40 #include "vm/runtime_entry.h" |
| 41 #include "vm/scopes.h" | 41 #include "vm/scopes.h" |
| 42 #include "vm/stack_frame.h" | 42 #include "vm/stack_frame.h" |
| 43 #include "vm/symbols.h" | 43 #include "vm/symbols.h" |
| 44 #include "vm/tags.h" | 44 #include "vm/tags.h" |
| 45 #include "vm/timer.h" | 45 #include "vm/timer.h" |
| 46 #include "vm/trace_buffer.h" |
| 46 #include "vm/unicode.h" | 47 #include "vm/unicode.h" |
| 47 | 48 |
| 48 namespace dart { | 49 namespace dart { |
| 49 | 50 |
| 50 DEFINE_FLAG(int, huge_method_cutoff_in_code_size, 200000, | 51 DEFINE_FLAG(int, huge_method_cutoff_in_code_size, 200000, |
| 51 "Huge method cutoff in unoptimized code size (in bytes)."); | 52 "Huge method cutoff in unoptimized code size (in bytes)."); |
| 52 DEFINE_FLAG(int, huge_method_cutoff_in_tokens, 20000, | 53 DEFINE_FLAG(int, huge_method_cutoff_in_tokens, 20000, |
| 53 "Huge method cutoff in tokens: Disables optimizations for huge methods."); | 54 "Huge method cutoff in tokens: Disables optimizations for huge methods."); |
| 54 DEFINE_FLAG(bool, overlap_type_arguments, true, | 55 DEFINE_FLAG(bool, overlap_type_arguments, true, |
| 55 "When possible, partially or fully overlap the type arguments of a type " | 56 "When possible, partially or fully overlap the type arguments of a type " |
| (...skipping 5826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5882 result.set_end_token_pos(token_pos); | 5883 result.set_end_token_pos(token_pos); |
| 5883 result.set_num_fixed_parameters(0); | 5884 result.set_num_fixed_parameters(0); |
| 5884 result.set_num_optional_parameters(0); | 5885 result.set_num_optional_parameters(0); |
| 5885 result.set_usage_counter(0); | 5886 result.set_usage_counter(0); |
| 5886 result.set_deoptimization_counter(0); | 5887 result.set_deoptimization_counter(0); |
| 5887 result.set_optimized_instruction_count(0); | 5888 result.set_optimized_instruction_count(0); |
| 5888 result.set_optimized_call_site_count(0); | 5889 result.set_optimized_call_site_count(0); |
| 5889 result.set_is_optimizable(is_native ? false : true); | 5890 result.set_is_optimizable(is_native ? false : true); |
| 5890 result.set_is_inlinable(true); | 5891 result.set_is_inlinable(true); |
| 5891 result.set_allows_hoisting_check_class(true); | 5892 result.set_allows_hoisting_check_class(true); |
| 5893 result.set_log(new TraceBuffer()); |
| 5892 if (kind == RawFunction::kClosureFunction) { | 5894 if (kind == RawFunction::kClosureFunction) { |
| 5893 const ClosureData& data = ClosureData::Handle(ClosureData::New()); | 5895 const ClosureData& data = ClosureData::Handle(ClosureData::New()); |
| 5894 result.set_data(data); | 5896 result.set_data(data); |
| 5895 } | 5897 } |
| 5896 | 5898 |
| 5897 // TODO(zra): Remove when arm64 is ready. | 5899 // TODO(zra): Remove when arm64 is ready. |
| 5898 #if !defined(TARGET_ARCH_ARM64) | 5900 #if !defined(TARGET_ARCH_ARM64) |
| 5899 result.set_code(Code::Handle(StubCode::LazyCompile_entry()->code())); | 5901 result.set_code(Code::Handle(StubCode::LazyCompile_entry()->code())); |
| 5900 #else | 5902 #else |
| 5901 result.set_code(Code::Handle()); | 5903 result.set_code(Code::Handle()); |
| 5902 #endif | 5904 #endif |
| 5903 return result.raw(); | 5905 return result.raw(); |
| 5904 } | 5906 } |
| 5905 | 5907 |
| 5906 | 5908 |
| 5907 RawFunction* Function::Clone(const Class& new_owner) const { | 5909 RawFunction* Function::Clone(const Class& new_owner) const { |
| 5908 ASSERT(!IsConstructor()); | 5910 ASSERT(!IsConstructor()); |
| 5909 Function& clone = Function::Handle(); | 5911 Function& clone = Function::Handle(); |
| 5910 clone ^= Object::Clone(*this, Heap::kOld); | 5912 clone ^= Object::Clone(*this, Heap::kOld); |
| 5911 const Class& origin = Class::Handle(this->origin()); | 5913 const Class& origin = Class::Handle(this->origin()); |
| 5912 const PatchClass& clone_owner = | 5914 const PatchClass& clone_owner = |
| 5913 PatchClass::Handle(PatchClass::New(new_owner, origin)); | 5915 PatchClass::Handle(PatchClass::New(new_owner, origin)); |
| 5914 clone.set_owner(clone_owner); | 5916 clone.set_owner(clone_owner); |
| 5915 clone.ClearCode(); | 5917 clone.ClearCode(); |
| 5916 clone.set_usage_counter(0); | 5918 clone.set_usage_counter(0); |
| 5917 clone.set_deoptimization_counter(0); | 5919 clone.set_deoptimization_counter(0); |
| 5918 clone.set_optimized_instruction_count(0); | 5920 clone.set_optimized_instruction_count(0); |
| 5919 clone.set_optimized_call_site_count(0); | 5921 clone.set_optimized_call_site_count(0); |
| 5922 clone.set_log(new TraceBuffer()); |
| 5920 return clone.raw(); | 5923 return clone.raw(); |
| 5921 } | 5924 } |
| 5922 | 5925 |
| 5923 | 5926 |
| 5924 RawFunction* Function::NewClosureFunction(const String& name, | 5927 RawFunction* Function::NewClosureFunction(const String& name, |
| 5925 const Function& parent, | 5928 const Function& parent, |
| 5926 intptr_t token_pos) { | 5929 intptr_t token_pos) { |
| 5927 ASSERT(!parent.IsNull()); | 5930 ASSERT(!parent.IsNull()); |
| 5928 // Use the owner defining the parent function and not the class containing it. | 5931 // Use the owner defining the parent function and not the class containing it. |
| 5929 const Object& parent_owner = Object::Handle(parent.raw_ptr()->owner_); | 5932 const Object& parent_owner = Object::Handle(parent.raw_ptr()->owner_); |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6443 } | 6446 } |
| 6444 const char* kind_string = Function::KindToCString(kind()); | 6447 const char* kind_string = Function::KindToCString(kind()); |
| 6445 jsobj.AddProperty("kind", kind_string); | 6448 jsobj.AddProperty("kind", kind_string); |
| 6446 if (ref) { | 6449 if (ref) { |
| 6447 return; | 6450 return; |
| 6448 } | 6451 } |
| 6449 jsobj.AddProperty("is_static", is_static()); | 6452 jsobj.AddProperty("is_static", is_static()); |
| 6450 jsobj.AddProperty("is_const", is_const()); | 6453 jsobj.AddProperty("is_const", is_const()); |
| 6451 jsobj.AddProperty("is_optimizable", is_optimizable()); | 6454 jsobj.AddProperty("is_optimizable", is_optimizable()); |
| 6452 jsobj.AddProperty("is_inlinable", IsInlineable()); | 6455 jsobj.AddProperty("is_inlinable", IsInlineable()); |
| 6453 jsobj.AddProperty("unoptimized_code", Object::Handle(unoptimized_code())); | 6456 jsobj.AddProperty("code", Object::Handle(unoptimized_code())); |
| 6457 if (HasOptimizedCode()) { |
| 6458 jsobj.AddProperty("optimizedCode", Object::Handle(CurrentCode())); |
| 6459 } |
| 6454 jsobj.AddProperty("usage_counter", usage_counter()); | 6460 jsobj.AddProperty("usage_counter", usage_counter()); |
| 6455 jsobj.AddProperty("optimized_call_site_count", optimized_call_site_count()); | 6461 jsobj.AddProperty("optimized_call_site_count", optimized_call_site_count()); |
| 6456 jsobj.AddProperty("code", Object::Handle(CurrentCode())); | |
| 6457 jsobj.AddProperty("deoptimizations", | 6462 jsobj.AddProperty("deoptimizations", |
| 6458 static_cast<intptr_t>(deoptimization_counter())); | 6463 static_cast<intptr_t>(deoptimization_counter())); |
| 6459 | 6464 |
| 6460 const Script& script = Script::Handle(this->script()); | 6465 const Script& script = Script::Handle(this->script()); |
| 6461 if (!script.IsNull()) { | 6466 if (!script.IsNull()) { |
| 6462 jsobj.AddProperty("script", script); | 6467 jsobj.AddProperty("script", script); |
| 6463 jsobj.AddProperty("tokenPos", token_pos()); | 6468 jsobj.AddProperty("tokenPos", token_pos()); |
| 6464 jsobj.AddProperty("endTokenPos", end_token_pos()); | 6469 jsobj.AddProperty("endTokenPos", end_token_pos()); |
| 6465 } | 6470 } |
| 6471 if (log() != NULL) { |
| 6472 JSONObject l(&jsobj, "log"); |
| 6473 log()->PrintToJSONObject(&l); |
| 6474 } |
| 6466 } | 6475 } |
| 6467 | 6476 |
| 6468 | 6477 |
| 6469 void ClosureData::set_context_scope(const ContextScope& value) const { | 6478 void ClosureData::set_context_scope(const ContextScope& value) const { |
| 6470 StorePointer(&raw_ptr()->context_scope_, value.raw()); | 6479 StorePointer(&raw_ptr()->context_scope_, value.raw()); |
| 6471 } | 6480 } |
| 6472 | 6481 |
| 6473 | 6482 |
| 6474 void ClosureData::set_implicit_static_closure(const Instance& closure) const { | 6483 void ClosureData::set_implicit_static_closure(const Instance& closure) const { |
| 6475 ASSERT(!closure.IsNull()); | 6484 ASSERT(!closure.IsNull()); |
| (...skipping 11951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18427 return tag_label.ToCString(); | 18436 return tag_label.ToCString(); |
| 18428 } | 18437 } |
| 18429 | 18438 |
| 18430 | 18439 |
| 18431 void UserTag::PrintToJSONStream(JSONStream* stream, bool ref) const { | 18440 void UserTag::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 18432 Instance::PrintToJSONStream(stream, ref); | 18441 Instance::PrintToJSONStream(stream, ref); |
| 18433 } | 18442 } |
| 18434 | 18443 |
| 18435 | 18444 |
| 18436 } // namespace dart | 18445 } // namespace dart |
| OLD | NEW |