Move FindCodeObject from Heap to Isolate.

This removes the isolate=>heap=>isolate nonsense and has the additional bonus
that it re-enables printing of code objects in GDB. NOT: To make the latter
work, one has to adapt GDB any macros using FindCodeObject! Keeping things as it
is and outlining Isolate::heap() was not really an option...

Side note: Currently we are lucky that we still have Isolate::Current()
available in GDB, although it is marked as INLINE. :-}

R=verwaest@chromium.org

Review URL: https://codereview.chromium.org/19785004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15770 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 260af16e
......@@ -849,7 +849,7 @@ void RelocInfo::Verify() {
CHECK(addr != NULL);
// Check that we can find the right code object.
Code* code = Code::GetCodeFromTargetAddress(addr);
Object* found = HEAP->FindCodeObject(addr);
Object* found = code->GetIsolate()->FindCodeObject(addr);
CHECK(found->IsCode());
CHECK(code->address() == HeapObject::cast(found)->address());
break;
......
......@@ -584,7 +584,7 @@ Code* Deoptimizer::FindOptimizedCode(JSFunction* function,
Code* compiled_code =
isolate_->deoptimizer_data()->FindDeoptimizingCode(from_);
return (compiled_code == NULL)
? static_cast<Code*>(isolate_->heap()->FindCodeObject(from_))
? static_cast<Code*>(isolate_->FindCodeObject(from_))
: compiled_code;
}
case Deoptimizer::OSR: {
......@@ -3068,7 +3068,7 @@ DeoptimizedFrameInfo::DeoptimizedFrameInfo(Deoptimizer* deoptimizer,
expression_stack_ = new Object*[expression_count_];
// Get the source position using the unoptimized code.
Address pc = reinterpret_cast<Address>(output_frame->GetPc());
Code* code = Code::cast(deoptimizer->isolate()->heap()->FindCodeObject(pc));
Code* code = Code::cast(deoptimizer->isolate()->FindCodeObject(pc));
source_position_ = code->SourcePosition(pc);
for (int i = 0; i < expression_count_; i++) {
......
......@@ -673,7 +673,7 @@ void StubFrame::Iterate(ObjectVisitor* v) const {
Code* StubFrame::unchecked_code() const {
return static_cast<Code*>(isolate()->heap()->FindCodeObject(pc()));
return static_cast<Code*>(isolate()->FindCodeObject(pc()));
}
......@@ -783,7 +783,7 @@ void JavaScriptFrame::PrintTop(Isolate* isolate,
SharedFunctionInfo* shared = fun->shared();
if (print_line_number) {
Code* code = Code::cast(
v8::internal::Isolate::Current()->heap()->FindCodeObject(pc));
v8::internal::Isolate::Current()->FindCodeObject(pc));
int source_pos = code->SourcePosition(pc);
Object* maybe_script = shared->script();
if (maybe_script->IsScript()) {
......
......@@ -1111,12 +1111,6 @@ void Heap::MarkCompactPrologue() {
}
Object* Heap::FindCodeObject(Address a) {
return isolate()->inner_pointer_to_code_cache()->
GcSafeFindCodeForInnerPointer(a);
}
// Helper class for copying HeapObjects
class ScavengeVisitor: public ObjectVisitor {
public:
......
......@@ -1520,9 +1520,6 @@ class Heap {
// Write barrier support for address[start : start + len[ = o.
INLINE(void RecordWrites(Address address, int start, int len));
// Given an address occupied by a live code object, return that object.
Object* FindCodeObject(Address a);
enum HeapState { NOT_IN_GC, SCAVENGE, MARK_COMPACT };
inline HeapState gc_state() { return gc_state_; }
......
......@@ -293,7 +293,7 @@ IC::State IC::StateFrom(Code* target, Object* receiver, Object* name) {
RelocInfo::Mode IC::ComputeMode() {
Address addr = address();
Code* code = Code::cast(isolate()->heap()->FindCodeObject(addr));
Code* code = Code::cast(isolate()->FindCodeObject(addr));
for (RelocIterator it(code, RelocInfo::kCodeTargetMask);
!it.done(); it.next()) {
RelocInfo* info = it.rinfo();
......
......@@ -2510,6 +2510,11 @@ CodeStubInterfaceDescriptor*
}
Object* Isolate::FindCodeObject(Address a) {
return inner_pointer_to_code_cache()->GcSafeFindCodeForInnerPointer(a);
}
#ifdef DEBUG
#define ISOLATE_FIELD_OFFSET(type, name, ignored) \
const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_);
......
......@@ -1132,6 +1132,9 @@ class Isolate {
void* stress_deopt_count_address() { return &stress_deopt_count_; }
// Given an address occupied by a live code object, return that object.
Object* FindCodeObject(Address a);
private:
Isolate();
......
......@@ -127,7 +127,7 @@ static void CheckFindCodeObject(Isolate* isolate) {
Address obj_addr = obj->address();
for (int i = 0; i < obj->Size(); i += kPointerSize) {
Object* found = heap->FindCodeObject(obj_addr + i);
Object* found = isolate->FindCodeObject(obj_addr + i);
CHECK_EQ(code, found);
}
......@@ -137,8 +137,8 @@ static void CheckFindCodeObject(Isolate* isolate) {
Handle<Code>())->ToObjectChecked();
CHECK(copy->IsCode());
HeapObject* obj_copy = HeapObject::cast(copy);
Object* not_right = heap->FindCodeObject(obj_copy->address() +
obj_copy->Size() / 2);
Object* not_right = isolate->FindCodeObject(obj_copy->address() +
obj_copy->Size() / 2);
CHECK(not_right != code);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment