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

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: Cleanup 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
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 2674 matching lines...) Expand 10 before | Expand all | Expand 10 after
13267 return obj.IsNull(); 13263 return obj.IsNull();
13268 } 13264 }
13269 13265
13270 13266
13271 bool Code::IsFunctionCode() const { 13267 bool Code::IsFunctionCode() const {
13272 const Object& obj = Object::Handle(owner()); 13268 const Object& obj = Object::Handle(owner());
13273 return obj.IsFunction(); 13269 return obj.IsFunction();
13274 } 13270 }
13275 13271
13276 13272
13273 void Code::DisableDartCode() const {
13274 ASSERT(instructions() == active_instructions());
rmacnak 2015/09/29 23:30:57 ASSERT(IsFunctionCode())
srdjan 2015/09/30 16:36:18 Done.
13275 const Code& new_code =
13276 Code::Handle(StubCode::FixCallersTarget_entry()->code());
13277 set_active_instructions(new_code.instructions());
13278 }
13279
13280
13281 void Code::DisableStubCode() const {
13282 ASSERT(instructions() == active_instructions());
rmacnak 2015/09/29 23:30:57 ASSERT(IsAllocationStubCode())
srdjan 2015/09/30 16:36:18 Done.
13283 const Code& new_code =
13284 Code::Handle(StubCode::FixAllocationStubTarget_entry()->code());
13285 set_active_instructions(new_code.instructions());
13286 }
13287
13288
13277 void Code::PrintJSONImpl(JSONStream* stream, bool ref) const { 13289 void Code::PrintJSONImpl(JSONStream* stream, bool ref) const {
13278 JSONObject jsobj(stream); 13290 JSONObject jsobj(stream);
13279 AddCommonObjectProperties(&jsobj, "Code", ref); 13291 AddCommonObjectProperties(&jsobj, "Code", ref);
13280 jsobj.AddFixedServiceId("code/%" Px64"-%" Px "", 13292 jsobj.AddFixedServiceId("code/%" Px64"-%" Px "",
13281 compile_timestamp(), 13293 compile_timestamp(),
13282 EntryPoint()); 13294 EntryPoint());
13283 const String& user_name = String::Handle(PrettyName()); 13295 const String& user_name = String::Handle(PrettyName());
13284 const String& vm_name = String::Handle(Name()); 13296 const String& vm_name = String::Handle(Name());
13285 AddNameProperties(&jsobj, user_name, vm_name); 13297 AddNameProperties(&jsobj, user_name, vm_name);
13286 const bool is_stub = IsStubCode() || IsAllocationStubCode(); 13298 const bool is_stub = IsStubCode() || IsAllocationStubCode();
(...skipping 8157 matching lines...) Expand 10 before | Expand all | Expand 10 after
21444 return tag_label.ToCString(); 21456 return tag_label.ToCString();
21445 } 21457 }
21446 21458
21447 21459
21448 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 21460 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
21449 Instance::PrintJSONImpl(stream, ref); 21461 Instance::PrintJSONImpl(stream, ref);
21450 } 21462 }
21451 21463
21452 21464
21453 } // namespace dart 21465 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/weak_code.cc » ('j') | runtime/vm/weak_code.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698