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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 DEFINE_FLAG(int, huge_method_cutoff_in_code_size, 200000, | 52 DEFINE_FLAG(int, huge_method_cutoff_in_code_size, 200000, |
53 "Huge method cutoff in unoptimized code size (in bytes)."); | 53 "Huge method cutoff in unoptimized code size (in bytes)."); |
54 DEFINE_FLAG(int, huge_method_cutoff_in_tokens, 20000, | 54 DEFINE_FLAG(int, huge_method_cutoff_in_tokens, 20000, |
55 "Huge method cutoff in tokens: Disables optimizations for huge methods."); | 55 "Huge method cutoff in tokens: Disables optimizations for huge methods."); |
56 DEFINE_FLAG(bool, overlap_type_arguments, true, | 56 DEFINE_FLAG(bool, overlap_type_arguments, true, |
57 "When possible, partially or fully overlap the type arguments of a type " | 57 "When possible, partially or fully overlap the type arguments of a type " |
58 "with the type arguments of its super type."); | 58 "with the type arguments of its super type."); |
59 DEFINE_FLAG(bool, show_internal_names, false, | 59 DEFINE_FLAG(bool, show_internal_names, false, |
60 "Show names of internal classes (e.g. \"OneByteString\") in error messages " | 60 "Show names of internal classes (e.g. \"OneByteString\") in error messages " |
61 "instead of showing the corresponding interface names (e.g. \"String\")"); | 61 "instead of showing the corresponding interface names (e.g. \"String\")"); |
62 DEFINE_FLAG(bool, trace_disabling_optimized_code, false, | |
63 "Trace disabling optimized code."); | |
64 DEFINE_FLAG(bool, throw_on_javascript_int_overflow, false, | 62 DEFINE_FLAG(bool, throw_on_javascript_int_overflow, false, |
65 "Throw an exception when the result of an integer calculation will not " | 63 "Throw an exception when the result of an integer calculation will not " |
66 "fit into a javascript integer."); | 64 "fit into a javascript integer."); |
67 DEFINE_FLAG(bool, use_field_guards, true, "Guard field cids."); | 65 DEFINE_FLAG(bool, use_field_guards, true, "Guard field cids."); |
68 DEFINE_FLAG(bool, use_lib_cache, true, "Use library name cache"); | 66 DEFINE_FLAG(bool, use_lib_cache, true, "Use library name cache"); |
69 DEFINE_FLAG(bool, trace_field_guards, false, "Trace changes in field's cids."); | 67 DEFINE_FLAG(bool, trace_field_guards, false, "Trace changes in field's cids."); |
70 | 68 |
71 DECLARE_FLAG(bool, enable_type_checks); | 69 DECLARE_FLAG(bool, enable_type_checks); |
72 DECLARE_FLAG(bool, error_on_bad_override); | 70 DECLARE_FLAG(bool, error_on_bad_override); |
73 DECLARE_FLAG(bool, trace_compiler); | 71 DECLARE_FLAG(bool, trace_compiler); |
(...skipping 5020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5094 StorePointer(&raw_ptr()->instructions_, | 5092 StorePointer(&raw_ptr()->instructions_, |
5095 Code::Handle(stub_code->LazyCompile_entry()->code()).instructions()); | 5093 Code::Handle(stub_code->LazyCompile_entry()->code()).instructions()); |
5096 } | 5094 } |
5097 | 5095 |
5098 | 5096 |
5099 void Function::SwitchToUnoptimizedCode() const { | 5097 void Function::SwitchToUnoptimizedCode() const { |
5100 ASSERT(HasOptimizedCode()); | 5098 ASSERT(HasOptimizedCode()); |
5101 Isolate* isolate = Isolate::Current(); | 5099 Isolate* isolate = Isolate::Current(); |
5102 const Code& current_code = Code::Handle(isolate, CurrentCode()); | 5100 const Code& current_code = Code::Handle(isolate, CurrentCode()); |
5103 | 5101 |
5104 if (FLAG_trace_deoptimization) { | 5102 if (FLAG_trace_deoptimization_verbose) { |
5105 OS::Print("Disabling optimized code: '%s' entry: %#" Px "\n", | 5103 OS::Print("Disabling optimized code: '%s' entry: %#" Px "\n", |
5106 ToFullyQualifiedCString(), | 5104 ToFullyQualifiedCString(), |
5107 current_code.EntryPoint()); | 5105 current_code.EntryPoint()); |
5108 } | 5106 } |
5109 // Patch entry of the optimized code. | 5107 // Patch entry of the optimized code. |
5110 CodePatcher::PatchEntry(current_code); | 5108 CodePatcher::PatchEntry(current_code); |
5111 // Use previously compiled unoptimized code. | 5109 // Use previously compiled unoptimized code. |
5110 Compiler::EnsureUnoptimizedCode(Thread::Current(), *this); | |
Vyacheslav Egorov (Google)
2015/04/09 12:23:08
Comment above no longer applies because previously
Florian Schneider
2015/04/09 14:48:38
Done.
| |
5112 AttachCode(Code::Handle(isolate, unoptimized_code())); | 5111 AttachCode(Code::Handle(isolate, unoptimized_code())); |
5113 CodePatcher::RestoreEntry(Code::Handle(isolate, unoptimized_code())); | 5112 CodePatcher::RestoreEntry(Code::Handle(isolate, unoptimized_code())); |
5114 isolate->TrackDeoptimizedCode(current_code); | 5113 isolate->TrackDeoptimizedCode(current_code); |
5115 } | 5114 } |
5116 | 5115 |
5117 | 5116 |
5118 void Function::set_unoptimized_code(const Code& value) const { | 5117 void Function::set_unoptimized_code(const Code& value) const { |
5119 ASSERT(!value.is_optimized()); | 5118 ASSERT(value.IsNull() || !value.is_optimized()); |
5120 StorePointer(&raw_ptr()->unoptimized_code_, value.raw()); | 5119 StorePointer(&raw_ptr()->unoptimized_code_, value.raw()); |
5121 } | 5120 } |
5122 | 5121 |
5123 | 5122 |
5124 RawContextScope* Function::context_scope() const { | 5123 RawContextScope* Function::context_scope() const { |
5125 if (IsClosureFunction()) { | 5124 if (IsClosureFunction()) { |
5126 const Object& obj = Object::Handle(raw_ptr()->data_); | 5125 const Object& obj = Object::Handle(raw_ptr()->data_); |
5127 ASSERT(!obj.IsNull()); | 5126 ASSERT(!obj.IsNull()); |
5128 return ClosureData::Cast(obj).context_scope(); | 5127 return ClosureData::Cast(obj).context_scope(); |
5129 } | 5128 } |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5551 // Do not optimize if collecting coverage data. | 5550 // Do not optimize if collecting coverage data. |
5552 return false; | 5551 return false; |
5553 } | 5552 } |
5554 if (is_native()) { | 5553 if (is_native()) { |
5555 // Native methods don't need to be optimized. | 5554 // Native methods don't need to be optimized. |
5556 return false; | 5555 return false; |
5557 } | 5556 } |
5558 if (is_optimizable() && (script() != Script::null()) && | 5557 if (is_optimizable() && (script() != Script::null()) && |
5559 ((end_token_pos() - token_pos()) < FLAG_huge_method_cutoff_in_tokens)) { | 5558 ((end_token_pos() - token_pos()) < FLAG_huge_method_cutoff_in_tokens)) { |
5560 // Additional check needed for implicit getters. | 5559 // Additional check needed for implicit getters. |
5561 if (HasCode() && | 5560 if ((unoptimized_code() != Object::null()) && |
Vyacheslav Egorov (Google)
2015/04/09 12:23:08
if (x) { return false } else { return true }
can
Florian Schneider
2015/04/09 14:48:38
Done.
| |
5562 (Code::Handle(unoptimized_code()).Size() >= | 5561 (Code::Handle(unoptimized_code()).Size() >= |
5563 FLAG_huge_method_cutoff_in_code_size)) { | 5562 FLAG_huge_method_cutoff_in_code_size)) { |
5564 return false; | 5563 return false; |
5565 } else { | 5564 } else { |
5566 return true; | 5565 return true; |
5567 } | 5566 } |
5568 } | 5567 } |
5569 return false; | 5568 return false; |
5570 } | 5569 } |
5571 | 5570 |
5572 | 5571 |
5573 bool Function::IsNativeAutoSetupScope() const { | 5572 bool Function::IsNativeAutoSetupScope() const { |
(...skipping 15153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
20727 return tag_label.ToCString(); | 20726 return tag_label.ToCString(); |
20728 } | 20727 } |
20729 | 20728 |
20730 | 20729 |
20731 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20730 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20732 Instance::PrintJSONImpl(stream, ref); | 20731 Instance::PrintJSONImpl(stream, ref); |
20733 } | 20732 } |
20734 | 20733 |
20735 | 20734 |
20736 } // namespace dart | 20735 } // namespace dart |
OLD | NEW |