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 5013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5087 StorePointer(&raw_ptr()->instructions_, | 5085 StorePointer(&raw_ptr()->instructions_, |
5088 Code::Handle(stub_code->LazyCompile_entry()->code()).instructions()); | 5086 Code::Handle(stub_code->LazyCompile_entry()->code()).instructions()); |
5089 } | 5087 } |
5090 | 5088 |
5091 | 5089 |
5092 void Function::SwitchToUnoptimizedCode() const { | 5090 void Function::SwitchToUnoptimizedCode() const { |
5093 ASSERT(HasOptimizedCode()); | 5091 ASSERT(HasOptimizedCode()); |
5094 Isolate* isolate = Isolate::Current(); | 5092 Isolate* isolate = Isolate::Current(); |
5095 const Code& current_code = Code::Handle(isolate, CurrentCode()); | 5093 const Code& current_code = Code::Handle(isolate, CurrentCode()); |
5096 | 5094 |
5097 if (FLAG_trace_deoptimization) { | 5095 if (FLAG_trace_deoptimization_verbose) { |
5098 OS::Print("Disabling optimized code: '%s' entry: %#" Px "\n", | 5096 OS::Print("Disabling optimized code: '%s' entry: %#" Px "\n", |
5099 ToFullyQualifiedCString(), | 5097 ToFullyQualifiedCString(), |
5100 current_code.EntryPoint()); | 5098 current_code.EntryPoint()); |
5101 } | 5099 } |
5102 // Patch entry of the optimized code. | 5100 // Patch entry of the optimized code. |
5103 CodePatcher::PatchEntry(current_code); | 5101 CodePatcher::PatchEntry(current_code); |
5104 // Use previously compiled unoptimized code. | 5102 Compiler::EnsureUnoptimizedCode(Thread::Current(), *this); |
5105 AttachCode(Code::Handle(isolate, unoptimized_code())); | 5103 AttachCode(Code::Handle(isolate, unoptimized_code())); |
5106 CodePatcher::RestoreEntry(Code::Handle(isolate, unoptimized_code())); | 5104 CodePatcher::RestoreEntry(Code::Handle(isolate, unoptimized_code())); |
5107 isolate->TrackDeoptimizedCode(current_code); | 5105 isolate->TrackDeoptimizedCode(current_code); |
5108 } | 5106 } |
5109 | 5107 |
5110 | 5108 |
5111 void Function::set_unoptimized_code(const Code& value) const { | 5109 void Function::set_unoptimized_code(const Code& value) const { |
5112 ASSERT(!value.is_optimized()); | 5110 ASSERT(value.IsNull() || !value.is_optimized()); |
5113 StorePointer(&raw_ptr()->unoptimized_code_, value.raw()); | 5111 StorePointer(&raw_ptr()->unoptimized_code_, value.raw()); |
5114 } | 5112 } |
5115 | 5113 |
5116 | 5114 |
5117 RawContextScope* Function::context_scope() const { | 5115 RawContextScope* Function::context_scope() const { |
5118 if (IsClosureFunction()) { | 5116 if (IsClosureFunction()) { |
5119 const Object& obj = Object::Handle(raw_ptr()->data_); | 5117 const Object& obj = Object::Handle(raw_ptr()->data_); |
5120 ASSERT(!obj.IsNull()); | 5118 ASSERT(!obj.IsNull()); |
5121 return ClosureData::Cast(obj).context_scope(); | 5119 return ClosureData::Cast(obj).context_scope(); |
5122 } | 5120 } |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5544 // Do not optimize if collecting coverage data. | 5542 // Do not optimize if collecting coverage data. |
5545 return false; | 5543 return false; |
5546 } | 5544 } |
5547 if (is_native()) { | 5545 if (is_native()) { |
5548 // Native methods don't need to be optimized. | 5546 // Native methods don't need to be optimized. |
5549 return false; | 5547 return false; |
5550 } | 5548 } |
5551 if (is_optimizable() && (script() != Script::null()) && | 5549 if (is_optimizable() && (script() != Script::null()) && |
5552 ((end_token_pos() - token_pos()) < FLAG_huge_method_cutoff_in_tokens)) { | 5550 ((end_token_pos() - token_pos()) < FLAG_huge_method_cutoff_in_tokens)) { |
5553 // Additional check needed for implicit getters. | 5551 // Additional check needed for implicit getters. |
5554 if (HasCode() && | 5552 return (unoptimized_code() == Object::null()) || |
5555 (Code::Handle(unoptimized_code()).Size() >= | 5553 (Code::Handle(unoptimized_code()).Size() < |
5556 FLAG_huge_method_cutoff_in_code_size)) { | 5554 FLAG_huge_method_cutoff_in_code_size); |
5557 return false; | |
5558 } else { | |
5559 return true; | |
5560 } | |
5561 } | 5555 } |
5562 return false; | 5556 return false; |
5563 } | 5557 } |
5564 | 5558 |
5565 | 5559 |
5566 bool Function::IsNativeAutoSetupScope() const { | 5560 bool Function::IsNativeAutoSetupScope() const { |
5567 return is_native() ? is_optimizable() : false; | 5561 return is_native() ? is_optimizable() : false; |
5568 } | 5562 } |
5569 | 5563 |
5570 | 5564 |
(...skipping 15094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20665 return tag_label.ToCString(); | 20659 return tag_label.ToCString(); |
20666 } | 20660 } |
20667 | 20661 |
20668 | 20662 |
20669 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20663 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20670 Instance::PrintJSONImpl(stream, ref); | 20664 Instance::PrintJSONImpl(stream, ref); |
20671 } | 20665 } |
20672 | 20666 |
20673 | 20667 |
20674 } // namespace dart | 20668 } // namespace dart |
OLD | NEW |