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

Unified Diff: runtime/vm/object.cc

Issue 1343373003: Revert "VM: New calling convention for generated code." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 6c55119e675c30a87464bae57869f251ede9af39..d95e73d1ab4fde2156e11c45950f869317bcfc1b 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -3707,9 +3707,7 @@ void Class::DisableAllocationStub() const {
}
ASSERT(!CodePatcher::IsEntryPatched(existing_stub));
// Patch the stub so that the next caller will regenerate the stub.
- CodePatcher::PatchEntry(
- existing_stub,
- Code::Handle(StubCode::FixAllocationStubTarget_entry()->code()));
+ CodePatcher::PatchEntry(existing_stub);
// Disassociate the existing stub from class.
StorePointer(&raw_ptr()->allocation_stub_, Code::null());
}
@@ -5227,7 +5225,7 @@ bool Function::HasBreakpoint() const {
void Function::SetInstructions(const Code& value) const {
- StorePointer(&raw_ptr()->code_, value.raw());
+ StorePointer(&raw_ptr()->instructions_, value.instructions());
StoreNonPointer(&raw_ptr()->entry_point_, value.EntryPoint());
}
@@ -5240,8 +5238,9 @@ void Function::AttachCode(const Code& value) const {
bool Function::HasCode() const {
- ASSERT(raw_ptr()->code_ != Code::null());
- return raw_ptr()->code_ != StubCode::LazyCompile_entry()->code();
+ ASSERT(raw_ptr()->instructions_ != Instructions::null());
+ return raw_ptr()->instructions_ !=
+ StubCode::LazyCompile_entry()->code()->ptr()->instructions_;
}
@@ -5265,8 +5264,7 @@ void Function::SwitchToUnoptimizedCode() const {
current_code.EntryPoint());
}
// Patch entry of the optimized code.
- CodePatcher::PatchEntry(
- current_code, Code::Handle(StubCode::FixCallersTarget_entry()->code()));
+ CodePatcher::PatchEntry(current_code);
const Error& error = Error::Handle(zone,
Compiler::EnsureUnoptimizedCode(thread, *this));
if (!error.IsNull()) {
@@ -6730,7 +6728,8 @@ RawScript* Function::script() const {
bool Function::HasOptimizedCode() const {
- return HasCode() && Code::Handle(CurrentCode()).is_optimized();
+ return HasCode() && Code::Handle(Instructions::Handle(
+ raw_ptr()->instructions_).code()).is_optimized();
}
@@ -10921,9 +10920,11 @@ void Instructions::PrintJSONImpl(JSONStream* stream, bool ref) const {
JSONObject jsobj(stream);
AddCommonObjectProperties(&jsobj, "Object", ref);
jsobj.AddServiceId(*this);
+ jsobj.AddProperty("_code", Code::Handle(code()));
if (ref) {
return;
}
+ jsobj.AddProperty("_objectPool", ObjectPool::Handle(object_pool()));
}
@@ -12857,6 +12858,13 @@ void Code::SetStubCallTargetCodeAt(uword pc, const Code& code) const {
void Code::Disassemble(DisassemblyFormatter* formatter) const {
+ const bool fix_patch = CodePatcher::CodeIsPatchable(*this) &&
+ CodePatcher::IsEntryPatched(*this);
+ if (fix_patch) {
+ // The disassembler may choke on illegal instructions if the code has been
+ // patched, un-patch the code before disassembling and re-patch after.
+ CodePatcher::RestoreEntry(*this);
+ }
const Instructions& instr = Instructions::Handle(instructions());
uword start = instr.EntryPoint();
if (formatter == NULL) {
@@ -12864,6 +12872,10 @@ void Code::Disassemble(DisassemblyFormatter* formatter) const {
} else {
Disassembler::Disassemble(start, start + instr.size(), formatter, *this);
}
+ if (fix_patch) {
+ // Redo the patch.
+ CodePatcher::PatchEntry(*this);
+ }
}
@@ -12985,6 +12997,8 @@ RawCode* Code::New(intptr_t pointer_offsets_length) {
result.set_is_alive(false);
result.set_comments(Comments::New(0));
result.set_compile_timestamp(0);
+ result.set_entry_patch_pc_offset(kInvalidPc);
+ result.set_patch_code_pc_offset(kInvalidPc);
result.set_lazy_deopt_pc_offset(kInvalidPc);
result.set_pc_descriptors(Object::empty_descriptors());
}
@@ -13009,9 +13023,6 @@ RawCode* Code::FinalizeCode(const char* name,
// pages read-only.
intptr_t pointer_offset_count = assembler->CountPointerOffsets();
Code& code = Code::ZoneHandle(Code::New(pointer_offset_count));
-#ifdef TARGET_ARCH_IA32
- assembler->set_code_object(code);
-#endif
Instructions& instrs =
Instructions::ZoneHandle(Instructions::New(assembler->CodeSize()));
INC_STAT(Thread::Current(), total_instr_size, assembler->CodeSize());
@@ -13050,14 +13061,14 @@ RawCode* Code::FinalizeCode(const char* name,
}
// Hook up Code and Instructions objects.
- code.set_active_instructions(instrs.raw());
+ instrs.set_code(code.raw());
code.set_instructions(instrs.raw());
code.set_is_alive(true);
// Set object pool in Instructions object.
INC_STAT(Thread::Current(),
total_code_size, object_pool.Length() * sizeof(uintptr_t));
- code.set_object_pool(object_pool.raw());
+ instrs.set_object_pool(object_pool.raw());
if (FLAG_write_protect_code) {
uword address = RawObject::ToAddr(instrs.raw());
@@ -13099,7 +13110,7 @@ RawCode* Code::FinalizeCode(const Function& function,
// Check if object matches find condition.
bool Code::FindRawCodeVisitor::FindObject(RawObject* obj) const {
- return RawCode::ContainsPC(obj, pc_);
+ return RawInstructions::ContainsPC(obj, pc_);
}
@@ -13107,13 +13118,13 @@ RawCode* Code::LookupCodeInIsolate(Isolate* isolate, uword pc) {
ASSERT((isolate == Isolate::Current()) || (isolate == Dart::vm_isolate()));
NoSafepointScope no_safepoint;
FindRawCodeVisitor visitor(pc);
- RawObject* instr;
+ RawInstructions* instr;
if (isolate->heap() == NULL) {
return Code::null();
}
- instr = isolate->heap()->FindOldObject(&visitor);
- if (instr != Code::null()) {
- return static_cast<RawCode*>(instr);
+ instr = isolate->heap()->FindObjectInCodeSpace(&visitor);
+ if (instr != Instructions::null()) {
+ return instr->ptr()->code_;
}
return Code::null();
}
@@ -13354,6 +13365,18 @@ void Code::PrintJSONImpl(JSONStream* stream, bool ref) const {
}
+uword Code::GetEntryPatchPc() const {
+ return (entry_patch_pc_offset() != kInvalidPc)
+ ? EntryPoint() + entry_patch_pc_offset() : 0;
+}
+
+
+uword Code::GetPatchCodePc() const {
+ return (patch_code_pc_offset() != kInvalidPc)
+ ? EntryPoint() + patch_code_pc_offset() : 0;
+}
+
+
uword Code::GetLazyDeoptPc() const {
return (lazy_deopt_pc_offset() != kInvalidPc)
? EntryPoint() + lazy_deopt_pc_offset() : 0;
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698