Commit 3e59faef authored by erik.corry@gmail.com's avatar erik.corry@gmail.com

Microoptimizations to the way we get the current heap.

Review URL: http://codereview.chromium.org/6759030

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7455 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 107d9dc5
...@@ -1158,12 +1158,9 @@ void HeapObject::VerifySmiField(int offset) { ...@@ -1158,12 +1158,9 @@ void HeapObject::VerifySmiField(int offset) {
Heap* HeapObject::GetHeap() { Heap* HeapObject::GetHeap() {
// During GC, the map pointer in HeapObject is used in various ways that uintptr_t addr = reinterpret_cast<uintptr_t>(this);
// prevent us from retrieving Heap from the map. addr >>= kHeapDescriptorGranularityBits;
// Assert that we are not in GC, implement GC code in a way that it doesn't return heap_descriptors[addr].heap;
// pull heap from the map.
ASSERT(HEAP->is_safe_to_read_maps());
return map()->heap();
} }
...@@ -2862,6 +2859,34 @@ Heap* Map::heap() { ...@@ -2862,6 +2859,34 @@ Heap* Map::heap() {
} }
Heap* Code::heap() {
// NOTE: address() helper is not used to save one instruction.
Heap* heap = Page::FromAddress(reinterpret_cast<Address>(this))->heap_;
ASSERT(heap != NULL);
ASSERT(heap->isolate() == Isolate::Current());
return heap;
}
Isolate* Code::isolate() {
return heap()->isolate();
}
Heap* JSGlobalPropertyCell::heap() {
// NOTE: address() helper is not used to save one instruction.
Heap* heap = Page::FromAddress(reinterpret_cast<Address>(this))->heap_;
ASSERT(heap != NULL);
ASSERT(heap->isolate() == Isolate::Current());
return heap;
}
Isolate* JSGlobalPropertyCell::isolate() {
return heap()->isolate();
}
Object* Code::GetObjectFromEntryAddress(Address location_of_address) { Object* Code::GetObjectFromEntryAddress(Address location_of_address) {
return HeapObject:: return HeapObject::
FromAddress(Memory::Address_at(location_of_address) - Code::kHeaderSize); FromAddress(Memory::Address_at(location_of_address) - Code::kHeaderSize);
......
This diff is collapsed.
...@@ -3487,6 +3487,10 @@ class Code: public HeapObject { ...@@ -3487,6 +3487,10 @@ class Code: public HeapObject {
void CodeVerify(); void CodeVerify();
#endif #endif
// Returns the isolate/heap this code object belongs to.
inline Isolate* isolate();
inline Heap* heap();
// Max loop nesting marker used to postpose OSR. We don't take loop // Max loop nesting marker used to postpose OSR. We don't take loop
// nesting that is deeper than 5 levels into account. // nesting that is deeper than 5 levels into account.
static const int kMaxLoopNestingMarker = 6; static const int kMaxLoopNestingMarker = 6;
...@@ -6009,6 +6013,10 @@ class JSGlobalPropertyCell: public HeapObject { ...@@ -6009,6 +6013,10 @@ class JSGlobalPropertyCell: public HeapObject {
kValueOffset + kPointerSize, kValueOffset + kPointerSize,
kSize> BodyDescriptor; kSize> BodyDescriptor;
// Returns the isolate/heap this cell object belongs to.
inline Isolate* isolate();
inline Heap* heap();
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalPropertyCell); DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalPropertyCell);
}; };
......
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