Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(955)

Side by Side Diff: runtime/vm/object.cc

Issue 27802002: Disconnects code objects from infrequently used unoptimized functions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/pages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 4020 matching lines...) Expand 10 before | Expand all | Expand 10 after
4031 4031
4032 4032
4033 void Function::SetCode(const Code& value) const { 4033 void Function::SetCode(const Code& value) const {
4034 StorePointer(&raw_ptr()->code_, value.raw()); 4034 StorePointer(&raw_ptr()->code_, value.raw());
4035 ASSERT(Function::Handle(value.function()).IsNull() || 4035 ASSERT(Function::Handle(value.function()).IsNull() ||
4036 (value.function() == this->raw())); 4036 (value.function() == this->raw()));
4037 value.set_function(*this); 4037 value.set_function(*this);
4038 } 4038 }
4039 4039
4040 4040
4041 void Function::DetachCode() const {
4042 // Set unoptimized code as non-entrant, and set code and unoptimized code
4043 // to null.
4044 CodePatcher::PatchEntry(Code::Handle(unoptimized_code()));
4045 StorePointer(&raw_ptr()->code_, Code::null());
4046 StorePointer(&raw_ptr()->unoptimized_code_, Code::null());
4047 }
4048
4049
4050 void Function::ReattachCode(const Code& code) const {
4051 set_unoptimized_code(code);
4052 SetCode(code);
4053 CodePatcher::RestoreEntry(code);
4054 }
4055
4056
4041 void Function::SwitchToUnoptimizedCode() const { 4057 void Function::SwitchToUnoptimizedCode() const {
4042 ASSERT(HasOptimizedCode()); 4058 ASSERT(HasOptimizedCode());
4043 4059
4044 const Code& current_code = Code::Handle(CurrentCode()); 4060 const Code& current_code = Code::Handle(CurrentCode());
4045 4061
4046 // Optimized code object might have been actually fully produced by the 4062 // Optimized code object might have been actually fully produced by the
4047 // intrinsifier in this case nothing has to be done. In fact an attempt to 4063 // intrinsifier in this case nothing has to be done. In fact an attempt to
4048 // patch such code will cause crash. 4064 // patch such code will cause crash.
4049 // TODO(vegorov): if intrisifier can fully intrisify the function then we 4065 // TODO(vegorov): if intrisifier can fully intrisify the function then we
4050 // should not later try to optimize it. 4066 // should not later try to optimize it.
4051 if (PcDescriptors::Handle(current_code.pc_descriptors()).Length() == 0) { 4067 if (PcDescriptors::Handle(current_code.pc_descriptors()).Length() == 0) {
4052 return; 4068 return;
4053 } 4069 }
4054 4070
4055 if (FLAG_trace_disabling_optimized_code) { 4071 if (FLAG_trace_disabling_optimized_code) {
4056 OS::Print("Disabling optimized code: '%s' entry: %#" Px "\n", 4072 OS::Print("Disabling optimized code: '%s' entry: %#" Px "\n",
4057 ToFullyQualifiedCString(), 4073 ToFullyQualifiedCString(),
4058 current_code.EntryPoint()); 4074 current_code.EntryPoint());
4059 } 4075 }
4060 // Patch entry of the optimized code. 4076 // Patch entry of the optimized code.
4061 CodePatcher::PatchEntry(current_code); 4077 CodePatcher::PatchEntry(current_code);
4062 // Use previously compiled unoptimized code. 4078 // Use previously compiled unoptimized code.
4063 SetCode(Code::Handle(unoptimized_code())); 4079 SetCode(Code::Handle(unoptimized_code()));
4064 CodePatcher::RestoreEntry(Code::Handle(unoptimized_code())); 4080 CodePatcher::RestoreEntry(Code::Handle(unoptimized_code()));
4065 } 4081 }
4066 4082
4067 4083
4068 void Function::set_unoptimized_code(const Code& value) const { 4084 void Function::set_unoptimized_code(const Code& value) const {
4085 ASSERT(!value.is_optimized());
4069 StorePointer(&raw_ptr()->unoptimized_code_, value.raw()); 4086 StorePointer(&raw_ptr()->unoptimized_code_, value.raw());
4070 } 4087 }
4071 4088
4072 4089
4073 RawContextScope* Function::context_scope() const { 4090 RawContextScope* Function::context_scope() const {
4074 if (IsClosureFunction()) { 4091 if (IsClosureFunction()) {
4075 const Object& obj = Object::Handle(raw_ptr()->data_); 4092 const Object& obj = Object::Handle(raw_ptr()->data_);
4076 ASSERT(!obj.IsNull()); 4093 ASSERT(!obj.IsNull());
4077 return ClosureData::Cast(obj).context_scope(); 4094 return ClosureData::Cast(obj).context_scope();
4078 } 4095 }
(...skipping 5186 matching lines...) Expand 10 before | Expand all | Expand 10 after
9265 return Function::null(); 9282 return Function::null();
9266 } 9283 }
9267 const Array& array = 9284 const Array& array =
9268 Array::Handle(raw_ptr()->static_calls_target_table_); 9285 Array::Handle(raw_ptr()->static_calls_target_table_);
9269 Function& function = Function::Handle(); 9286 Function& function = Function::Handle();
9270 function ^= array.At(i + kSCallTableFunctionEntry); 9287 function ^= array.At(i + kSCallTableFunctionEntry);
9271 return function.raw(); 9288 return function.raw();
9272 } 9289 }
9273 9290
9274 9291
9292 RawCode* Code::GetStaticCallTargetCodeAt(uword pc) const {
9293 const intptr_t i = BinarySearchInSCallTable(pc);
9294 if (i < 0) {
9295 return Code::null();
9296 }
9297 const Array& array =
9298 Array::Handle(raw_ptr()->static_calls_target_table_);
9299 Code& code = Code::Handle();
9300 code ^= array.At(i + kSCallTableCodeEntry);
9301 return code.raw();
9302 }
9303
9304
9275 void Code::SetStaticCallTargetCodeAt(uword pc, const Code& code) const { 9305 void Code::SetStaticCallTargetCodeAt(uword pc, const Code& code) const {
9276 const intptr_t i = BinarySearchInSCallTable(pc); 9306 const intptr_t i = BinarySearchInSCallTable(pc);
9277 ASSERT(i >= 0); 9307 ASSERT(i >= 0);
9278 const Array& array = 9308 const Array& array =
9279 Array::Handle(raw_ptr()->static_calls_target_table_); 9309 Array::Handle(raw_ptr()->static_calls_target_table_);
9280 ASSERT(code.IsNull() || 9310 ASSERT(code.IsNull() ||
9281 (code.function() == array.At(i + kSCallTableFunctionEntry))); 9311 (code.function() == array.At(i + kSCallTableFunctionEntry)));
9282 array.SetAt(i + kSCallTableCodeEntry, code); 9312 array.SetAt(i + kSCallTableCodeEntry, code);
9283 } 9313 }
9284 9314
(...skipping 6282 matching lines...) Expand 10 before | Expand all | Expand 10 after
15567 return "_MirrorReference"; 15597 return "_MirrorReference";
15568 } 15598 }
15569 15599
15570 15600
15571 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 15601 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
15572 JSONObject jsobj(stream); 15602 JSONObject jsobj(stream);
15573 } 15603 }
15574 15604
15575 15605
15576 } // namespace dart 15606 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/pages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698