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

Unified Diff: vm/stack_frame.cc

Issue 9791048: - Wire the stack frame iterator to use stack maps for traversing objects if there are stack maps in… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 9 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
Index: vm/stack_frame.cc
===================================================================
--- vm/stack_frame.cc (revision 5921)
+++ vm/stack_frame.cc (working copy)
@@ -4,7 +4,6 @@
#include "vm/stack_frame.h"
-#include "vm/code_index_table.h"
#include "vm/isolate.h"
#include "vm/object.h"
#include "vm/object_store.h"
@@ -15,11 +14,35 @@
namespace dart {
+bool StackFrame::FindRawCodeVisitor::FindObject(RawObject* obj) {
+ return RawInstructions::ContainsPC(obj, pc_);
+}
+
+
void StackFrame::Print() const {
OS::Print("[%-8s : sp(%p) ]\n", GetName(), sp());
}
+RawCode* StackFrame::LookupCode(Isolate* isolate, uword pc) {
+ // TODO(asiva): Need to add a data structure for storing a (pc, code
+ // object) map in order to do a quick lookup and avoid having to
+ // traverse the code heap.
+ ASSERT(isolate != NULL);
+ // We add a no gc scope to ensure that the code below does not trigger
+ // a GC as we are handling raw object references here. It is possible
+ // that the code is called while a GC is in progress, that is ok.
+ NoGCScope no_gc;
+ FindRawCodeVisitor visitor(pc);
+ RawObject* obj = isolate->heap()->FindObjectInCodeSpace(&visitor);
+ if (obj != Object::null()) {
+ RawInstructions* instr = reinterpret_cast<RawInstructions*>(obj);
+ return instr->ptr()->code_;
+ }
+ return Code::null();
+}
+
+
void ExitFrame::VisitObjectPointers(ObjectPointerVisitor* visitor) {
// There are no objects to visit in this frame.
}
@@ -36,28 +59,57 @@
void DartFrame::VisitObjectPointers(ObjectPointerVisitor* visitor) {
- // Visit objects between SP and FP.
- ASSERT(visitor != NULL);
- visitor->VisitPointers(reinterpret_cast<RawObject**>(sp()),
- reinterpret_cast<RawObject**>(fp() - kWordSize));
+ RawCode* code = LookupDartCode();
+ ASSERT(code != Code::null());
+ RawStackmap* map = code->GetStackmap(pc());
+
+ // First visit the code object corresponding to this frame.
+ visitor->VisitPointer(reinterpret_cast<RawObject**>(&code));
+
+ // Now visit all objects on the frame.
+ if (map == Stackmap::null()) {
+ // No stack maps are present in the code object which means this
+ // frame relies on tagged pointers and hence we visit each entry
+ // on the frame between SP and FP.
+ ASSERT(visitor != NULL);
+ visitor->VisitPointers(reinterpret_cast<RawObject**>(sp()),
+ reinterpret_cast<RawObject**>(fp() - kWordSize));
+ return;
+ }
+ // A stack map is present in the code object, use the stack map to visit
+ // frame slots which are marked as having objects.
srdjan 2012/03/28 21:56:36 Can this part be tested?
siva 2012/03/29 19:01:27 Added a unit test case for this by generating a st
+ intptr_t size_in_bits = map->SizeInBits();
+ intptr_t bit_offset = 0;
+ uword addr = (fp() + (bit_offset * kWordSize));
+ while (bit_offset < size_in_bits) {
+ ASSERT(addr <= sp());
+ if (map->IsObject(bit_offset)) {
+ visitor->VisitPointer(reinterpret_cast<RawObject**>(addr));
+ }
+ bit_offset += 1;
+ addr = (fp() + (bit_offset * kWordSize));
+ }
}
RawFunction* DartFrame::LookupDartFunction() const {
- // Get access to the code index table.
- ASSERT(Isolate::Current() != NULL);
- CodeIndexTable* code_index_table = Isolate::Current()->code_index_table();
- ASSERT(code_index_table != NULL);
- return Code::Handle(code_index_table->LookupCode(pc())).function();
+ const Code& code = Code::Handle(LookupDartCode());
+ if (!code.IsNull()) {
+ return code.function();
+ }
+ return Function::null();
}
RawCode* DartFrame::LookupDartCode() const {
- // Get access to the code index table.
- ASSERT(Isolate::Current() != NULL);
- CodeIndexTable* code_index_table = Isolate::Current()->code_index_table();
- ASSERT(code_index_table != NULL);
- return code_index_table->LookupCode(pc());
+ // We add a no gc scope to ensure that the code below does not trigger
+ // a GC as we are handling raw object references here. It is possible
+ // that the code is called while a GC is in progress, that is ok.
+ NoGCScope no_gc;
+ Isolate* isolate = Isolate::Current();
+ RawCode* code = StackFrame::LookupCode(isolate, pc());
+ ASSERT(code != Code::null() && code->ptr()->function_ != Function::null());
+ return code;
}
@@ -93,11 +145,13 @@
bool StubFrame::IsValid() const {
- // Get access to the code index table.
- ASSERT(Isolate::Current() != NULL);
- CodeIndexTable* code_index_table = Isolate::Current()->code_index_table();
- ASSERT(code_index_table != NULL);
- return Code::Handle(code_index_table->LookupCode(pc())).IsNull();
+ // We add a no gc scope to ensure that the code below does not trigger
+ // a GC as we are handling raw object references here. It is possible
+ // that the code is called while a GC is in progress, that is ok.
+ NoGCScope no_gc;
+ Isolate* isolate = Isolate::Current();
+ RawCode* code = StackFrame::LookupCode(isolate, pc());
+ return (code != Code::null() && code->ptr()->function_ == Function::null());
}
« vm/raw_object.cc ('K') | « vm/stack_frame.h ('k') | vm/stack_frame_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698