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

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

Issue 1376963002: Cleanup: we are not patching entries any longer (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Address review comments Created 5 years, 2 months 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
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/weak_code.cc » ('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 3734 matching lines...) Expand 10 before | Expand all | Expand 10 after
3745 ASSERT(raw_ptr()->allocation_stub_ == Code::null()); 3745 ASSERT(raw_ptr()->allocation_stub_ == Code::null());
3746 StorePointer(&raw_ptr()->allocation_stub_, value.raw()); 3746 StorePointer(&raw_ptr()->allocation_stub_, value.raw());
3747 } 3747 }
3748 3748
3749 3749
3750 void Class::DisableAllocationStub() const { 3750 void Class::DisableAllocationStub() const {
3751 const Code& existing_stub = Code::Handle(allocation_stub()); 3751 const Code& existing_stub = Code::Handle(allocation_stub());
3752 if (existing_stub.IsNull()) { 3752 if (existing_stub.IsNull()) {
3753 return; 3753 return;
3754 } 3754 }
3755 ASSERT(!CodePatcher::IsEntryPatched(existing_stub)); 3755 ASSERT(!existing_stub.IsDisabled());
3756 // Patch the stub so that the next caller will regenerate the stub. 3756 // Change the stub so that the next caller will regenerate the stub.
3757 CodePatcher::PatchEntry( 3757 existing_stub.DisableStubCode();
3758 existing_stub,
3759 Code::Handle(StubCode::FixAllocationStubTarget_entry()->code()));
3760 // Disassociate the existing stub from class. 3758 // Disassociate the existing stub from class.
3761 StorePointer(&raw_ptr()->allocation_stub_, Code::null()); 3759 StorePointer(&raw_ptr()->allocation_stub_, Code::null());
3762 } 3760 }
3763 3761
3764 3762
3765 bool Class::IsFunctionClass() const { 3763 bool Class::IsFunctionClass() const {
3766 return raw() == Type::Handle(Type::Function()).type_class(); 3764 return raw() == Type::Handle(Type::Function()).type_class();
3767 } 3765 }
3768 3766
3769 3767
(...skipping 1536 matching lines...) Expand 10 before | Expand all | Expand 10 after
5306 Thread* thread = Thread::Current(); 5304 Thread* thread = Thread::Current();
5307 Isolate* isolate = thread->isolate(); 5305 Isolate* isolate = thread->isolate();
5308 Zone* zone = thread->zone(); 5306 Zone* zone = thread->zone();
5309 const Code& current_code = Code::Handle(zone, CurrentCode()); 5307 const Code& current_code = Code::Handle(zone, CurrentCode());
5310 5308
5311 if (FLAG_trace_deoptimization_verbose) { 5309 if (FLAG_trace_deoptimization_verbose) {
5312 THR_Print("Disabling optimized code: '%s' entry: %#" Px "\n", 5310 THR_Print("Disabling optimized code: '%s' entry: %#" Px "\n",
5313 ToFullyQualifiedCString(), 5311 ToFullyQualifiedCString(),
5314 current_code.EntryPoint()); 5312 current_code.EntryPoint());
5315 } 5313 }
5316 // Patch entry of the optimized code. 5314 current_code.DisableDartCode();
5317 CodePatcher::PatchEntry(
5318 current_code, Code::Handle(StubCode::FixCallersTarget_entry()->code()));
5319 const Error& error = Error::Handle(zone, 5315 const Error& error = Error::Handle(zone,
5320 Compiler::EnsureUnoptimizedCode(thread, *this)); 5316 Compiler::EnsureUnoptimizedCode(thread, *this));
5321 if (!error.IsNull()) { 5317 if (!error.IsNull()) {
5322 Exceptions::PropagateError(error); 5318 Exceptions::PropagateError(error);
5323 } 5319 }
5324 const Code& unopt_code = Code::Handle(zone, unoptimized_code()); 5320 const Code& unopt_code = Code::Handle(zone, unoptimized_code());
5325 AttachCode(unopt_code); 5321 AttachCode(unopt_code);
5326 CodePatcher::RestoreEntry(unopt_code); 5322 unopt_code.Enable();
5327 isolate->TrackDeoptimizedCode(current_code); 5323 isolate->TrackDeoptimizedCode(current_code);
5328 } 5324 }
5329 5325
5330 5326
5331 void Function::set_unoptimized_code(const Code& value) const { 5327 void Function::set_unoptimized_code(const Code& value) const {
5332 ASSERT(value.IsNull() || !value.is_optimized()); 5328 ASSERT(value.IsNull() || !value.is_optimized());
5333 StorePointer(&raw_ptr()->unoptimized_code_, value.raw()); 5329 StorePointer(&raw_ptr()->unoptimized_code_, value.raw());
5334 } 5330 }
5335 5331
5336 5332
(...skipping 5235 matching lines...) Expand 10 before | Expand all | Expand 10 after
10572 // this to happen, so make sure we die loudly if we find 10568 // this to happen, so make sure we die loudly if we find
10573 // ourselves here. 10569 // ourselves here.
10574 UNIMPLEMENTED(); 10570 UNIMPLEMENTED();
10575 } 10571 }
10576 10572
10577 virtual void ReportSwitchingCode(const Code& code) { 10573 virtual void ReportSwitchingCode(const Code& code) {
10578 if (FLAG_trace_deoptimization || FLAG_trace_deoptimization_verbose) { 10574 if (FLAG_trace_deoptimization || FLAG_trace_deoptimization_verbose) {
10579 THR_Print("Prefix '%s': disabling %s code for %s function '%s'\n", 10575 THR_Print("Prefix '%s': disabling %s code for %s function '%s'\n",
10580 String::Handle(prefix_.name()).ToCString(), 10576 String::Handle(prefix_.name()).ToCString(),
10581 code.is_optimized() ? "optimized" : "unoptimized", 10577 code.is_optimized() ? "optimized" : "unoptimized",
10582 CodePatcher::IsEntryPatched(code) ? "patched" : "unpatched", 10578 code.IsDisabled() ? "'patched'" : "'unpatched'",
10583 Function::Handle(code.function()).ToCString()); 10579 Function::Handle(code.function()).ToCString());
10584 } 10580 }
10585 } 10581 }
10586 10582
10587 private: 10583 private:
10588 const LibraryPrefix& prefix_; 10584 const LibraryPrefix& prefix_;
10589 DISALLOW_COPY_AND_ASSIGN(PrefixDependentArray); 10585 DISALLOW_COPY_AND_ASSIGN(PrefixDependentArray);
10590 }; 10586 };
10591 10587
10592 10588
(...skipping 2685 matching lines...) Expand 10 before | Expand all | Expand 10 after
13278 return obj.IsNull(); 13274 return obj.IsNull();
13279 } 13275 }
13280 13276
13281 13277
13282 bool Code::IsFunctionCode() const { 13278 bool Code::IsFunctionCode() const {
13283 const Object& obj = Object::Handle(owner()); 13279 const Object& obj = Object::Handle(owner());
13284 return obj.IsFunction(); 13280 return obj.IsFunction();
13285 } 13281 }
13286 13282
13287 13283
13284 void Code::DisableDartCode() const {
13285 ASSERT(IsFunctionCode());
13286 ASSERT(instructions() == active_instructions());
13287 const Code& new_code =
13288 Code::Handle(StubCode::FixCallersTarget_entry()->code());
13289 set_active_instructions(new_code.instructions());
13290 }
13291
13292
13293 void Code::DisableStubCode() const {
13294 ASSERT(IsAllocationStubCode());
13295 ASSERT(instructions() == active_instructions());
13296 const Code& new_code =
13297 Code::Handle(StubCode::FixAllocationStubTarget_entry()->code());
13298 set_active_instructions(new_code.instructions());
13299 }
13300
13301
13288 void Code::PrintJSONImpl(JSONStream* stream, bool ref) const { 13302 void Code::PrintJSONImpl(JSONStream* stream, bool ref) const {
13289 JSONObject jsobj(stream); 13303 JSONObject jsobj(stream);
13290 AddCommonObjectProperties(&jsobj, "Code", ref); 13304 AddCommonObjectProperties(&jsobj, "Code", ref);
13291 jsobj.AddFixedServiceId("code/%" Px64"-%" Px "", 13305 jsobj.AddFixedServiceId("code/%" Px64"-%" Px "",
13292 compile_timestamp(), 13306 compile_timestamp(),
13293 EntryPoint()); 13307 EntryPoint());
13294 const String& user_name = String::Handle(PrettyName()); 13308 const String& user_name = String::Handle(PrettyName());
13295 const String& vm_name = String::Handle(Name()); 13309 const String& vm_name = String::Handle(Name());
13296 AddNameProperties(&jsobj, user_name, vm_name); 13310 AddNameProperties(&jsobj, user_name, vm_name);
13297 const bool is_stub = IsStubCode() || IsAllocationStubCode(); 13311 const bool is_stub = IsStubCode() || IsAllocationStubCode();
(...skipping 8157 matching lines...) Expand 10 before | Expand all | Expand 10 after
21455 return tag_label.ToCString(); 21469 return tag_label.ToCString();
21456 } 21470 }
21457 21471
21458 21472
21459 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 21473 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
21460 Instance::PrintJSONImpl(stream, ref); 21474 Instance::PrintJSONImpl(stream, ref);
21461 } 21475 }
21462 21476
21463 21477
21464 } // namespace dart 21478 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/weak_code.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698