Revision: 5481
Author: [email protected]
Date: Thu Sep 16 17:50:24 2010
Log: Improves splay.js by 7%.
Review URL: http://codereview.chromium.org/3382007
http://code.google.com/p/v8/source/detail?r=5481
Modified:
/branches/experimental/isolates/src/ast.cc
/branches/experimental/isolates/src/heap.cc
/branches/experimental/isolates/src/isolate.h
/branches/experimental/isolates/src/jsregexp.cc
/branches/experimental/isolates/src/mark-compact.cc
/branches/experimental/isolates/src/parser.cc
/branches/experimental/isolates/src/runtime.cc
/branches/experimental/isolates/src/scanner.cc
/branches/experimental/isolates/src/spaces-inl.h
/branches/experimental/isolates/src/spaces.cc
/branches/experimental/isolates/src/spaces.h
=======================================
--- /branches/experimental/isolates/src/ast.cc Wed Sep 1 10:01:38 2010
+++ /branches/experimental/isolates/src/ast.cc Thu Sep 16 17:50:24 2010
@@ -295,7 +295,7 @@
bool AstVisitor::CheckStackOverflow() {
if (stack_overflow_) return true;
- StackLimitCheck check;
+ StackLimitCheck check(Isolate::Current());
if (!check.HasOverflowed()) return false;
return (stack_overflow_ = true);
}
=======================================
--- /branches/experimental/isolates/src/heap.cc Fri Sep 10 11:52:02 2010
+++ /branches/experimental/isolates/src/heap.cc Thu Sep 16 17:50:24 2010
@@ -816,6 +816,8 @@
// Helper class for copying HeapObjects
class ScavengeVisitor: public ObjectVisitor {
public:
+ explicit ScavengeVisitor(Heap* heap) : heap_(heap) {}
+
void VisitPointer(Object** p) { ScavengePointer(p); }
void VisitPointers(Object** start, Object** end) {
@@ -826,10 +828,12 @@
private:
void ScavengePointer(Object** p) {
Object* object = *p;
- if (!HEAP->InNewSpace(object)) return;
+ if (!heap_->InNewSpace(object)) return;
Heap::ScavengeObject(reinterpret_cast<HeapObject**>(p),
reinterpret_cast<HeapObject*>(object));
}
+
+ Heap* heap_;
};
@@ -883,7 +887,7 @@
gc_state_ = SCAVENGE;
- Page::FlipMeaningOfInvalidatedWatermarkFlag();
+ Page::FlipMeaningOfInvalidatedWatermarkFlag(this);
#ifdef DEBUG
VerifyPageWatermarkValidity(old_pointer_space_, ALL_VALID);
VerifyPageWatermarkValidity(map_space_, ALL_VALID);
@@ -934,7 +938,7 @@
promotion_queue_.Initialize(new_space_.ToSpaceHigh());
is_safe_to_read_maps_ = false;
- ScavengeVisitor scavenge_visitor;
+ ScavengeVisitor scavenge_visitor(this);
// Copy roots.
IterateRoots(&scavenge_visitor, VISIT_ALL_IN_SCAVENGE);
=======================================
--- /branches/experimental/isolates/src/isolate.h Fri Sep 10 06:22:54 2010
+++ /branches/experimental/isolates/src/isolate.h Thu Sep 16 17:50:24 2010
@@ -1101,8 +1101,10 @@
// Support for checking for stack-overflows in C++ code.
class StackLimitCheck BASE_EMBEDDED {
public:
+ explicit StackLimitCheck(Isolate* isolate) : isolate_(isolate) { }
+
bool HasOverflowed() const {
- StackGuard* stack_guard = Isolate::Current()->stack_guard();
+ StackGuard* stack_guard = isolate_->stack_guard();
// Stack has overflowed in C++ code only if stack pointer exceeds the
C++
// stack guard and the limits are not set to interrupt values.
// TODO(214): Stack overflows are ignored if a interrupt is pending.
This
@@ -1110,6 +1112,8 @@
return (reinterpret_cast<uintptr_t>(this) < stack_guard->climit()) &&
stack_guard->IsStackOverflow();
}
+ private:
+ Isolate* isolate_;
};
=======================================
--- /branches/experimental/isolates/src/jsregexp.cc Wed Sep 15 08:20:49 2010
+++ /branches/experimental/isolates/src/jsregexp.cc Thu Sep 16 17:50:24 2010
@@ -4757,7 +4757,7 @@
void Analysis::EnsureAnalyzed(RegExpNode* that) {
- StackLimitCheck check;
+ StackLimitCheck check(Isolate::Current());
if (check.HasOverflowed()) {
fail("Stack overflow");
return;
=======================================
--- /branches/experimental/isolates/src/mark-compact.cc Fri Sep 10 15:31:32
2010
+++ /branches/experimental/isolates/src/mark-compact.cc Thu Sep 16 17:50:24
2010
@@ -380,7 +380,7 @@
// Returns false if the operation fails (lack of stack space).
static inline bool VisitUnmarkedObjects(Object** start, Object** end) {
// Return false is we are close to the stack limit.
- StackLimitCheck check;
+ StackLimitCheck check(Isolate::Current());
if (check.HasOverflowed()) return false;
// Visit the unmarked objects.
=======================================
--- /branches/experimental/isolates/src/parser.cc Thu Sep 9 17:53:48 2010
+++ /branches/experimental/isolates/src/parser.cc Thu Sep 16 17:50:24 2010
@@ -4471,10 +4471,11 @@
void RegExpParser::Advance() {
if (next_pos_ < in()->length()) {
- StackLimitCheck check;
+ Isolate* isolate = Isolate::Current();
+ StackLimitCheck check(isolate);
if (check.HasOverflowed()) {
ReportError(CStrVector(Isolate::kStackOverflowMessage));
- } else if (ZONE->excess_allocation()) {
+ } else if (isolate->zone()->excess_allocation()) {
ReportError(CStrVector("Regular expression too large"));
} else {
current_ = in()->Get(next_pos_);
=======================================
--- /branches/experimental/isolates/src/runtime.cc Thu Sep 9 17:53:48 2010
+++ /branches/experimental/isolates/src/runtime.cc Thu Sep 16 17:50:24 2010
@@ -103,7 +103,7 @@
MUST_USE_RESULT static Object* DeepCopyBoilerplate(Heap* heap,
JSObject* boilerplate) {
- StackLimitCheck check;
+ StackLimitCheck check(heap->isolate());
if (check.HasOverflowed()) return heap->isolate()->StackOverflow();
Object* result = heap->CopyJSObject(boilerplate);
@@ -164,8 +164,8 @@
switch (copy->GetElementsKind()) {
case JSObject::FAST_ELEMENTS: {
FixedArray* elements = FixedArray::cast(copy->elements());
- if (elements->map() == HEAP->fixed_cow_array_map()) {
- COUNTERS->cow_arrays_created_runtime()->Increment();
+ if (elements->map() == heap->fixed_cow_array_map()) {
+
heap->isolate()->counters()->cow_arrays_created_runtime()->Increment();
#ifdef DEBUG
for (int i = 0; i < elements->length(); i++) {
ASSERT(!elements->get(i)->IsJSObject());
=======================================
--- /branches/experimental/isolates/src/scanner.cc Thu Sep 9 17:53:48 2010
+++ /branches/experimental/isolates/src/scanner.cc Thu Sep 16 17:50:24 2010
@@ -416,7 +416,7 @@
// threads.
current_ = next_;
// Check for stack-overflow before returning any tokens.
- StackLimitCheck check;
+ StackLimitCheck check(Isolate::Current());
if (check.HasOverflowed()) {
stack_overflow_ = true;
next_.token = Token::ILLEGAL;
=======================================
--- /branches/experimental/isolates/src/spaces-inl.h Wed Sep 15 08:34:43
2010
+++ /branches/experimental/isolates/src/spaces-inl.h Thu Sep 16 17:50:24
2010
@@ -57,18 +57,18 @@
// Page
Page* Page::next_page() {
- return Isolate::Current()->memory_allocator()->GetNextPage(this);
+ return heap_->isolate()->memory_allocator()->GetNextPage(this);
}
Address Page::AllocationTop() {
- PagedSpace* owner =
Isolate::Current()->memory_allocator()->PageOwner(this);
+ PagedSpace* owner =
heap_->isolate()->memory_allocator()->PageOwner(this);
return owner->PageAllocationTop(this);
}
Address Page::AllocationWatermark() {
- PagedSpace* owner =
Isolate::Current()->memory_allocator()->PageOwner(this);
+ PagedSpace* owner =
heap_->isolate()->memory_allocator()->PageOwner(this);
if (this == owner->AllocationTopPage()) {
return owner->top();
}
@@ -83,7 +83,7 @@
void Page::SetAllocationWatermark(Address allocation_watermark) {
- if ((HEAP->gc_state() == Heap::SCAVENGE) && IsWatermarkValid()) {
+ if ((heap_->gc_state() == Heap::SCAVENGE) && IsWatermarkValid()) {
// When iterating intergenerational references during scavenge
// we might decide to promote an encountered young object.
// We will allocate a space for such an object and put it
@@ -220,25 +220,25 @@
}
-void Page::FlipMeaningOfInvalidatedWatermarkFlag() {
- HEAP->page_watermark_invalidated_mark_ ^= 1 << WATERMARK_INVALIDATED;
+void Page::FlipMeaningOfInvalidatedWatermarkFlag(Heap* heap) {
+ heap->page_watermark_invalidated_mark_ ^= 1 << WATERMARK_INVALIDATED;
}
bool Page::IsWatermarkValid() {
return (flags_ & (1 << WATERMARK_INVALIDATED)) !=
- HEAP->page_watermark_invalidated_mark_;
+ heap_->page_watermark_invalidated_mark_;
}
void Page::InvalidateWatermark(bool value) {
if (value) {
flags_ = (flags_ & ~(1 << WATERMARK_INVALIDATED)) |
- HEAP->page_watermark_invalidated_mark_;
+ heap_->page_watermark_invalidated_mark_;
} else {
flags_ =
(flags_ & ~(1 << WATERMARK_INVALIDATED)) |
- (HEAP->page_watermark_invalidated_mark_ ^ (1 <<
WATERMARK_INVALIDATED));
+ (heap_->page_watermark_invalidated_mark_ ^ (1 <<
WATERMARK_INVALIDATED));
}
ASSERT(IsWatermarkValid() == !value);
@@ -267,7 +267,7 @@
void Page::ClearGCFields() {
InvalidateWatermark(true);
SetAllocationWatermark(ObjectAreaStart());
- if (HEAP->gc_state() == Heap::SCAVENGE) {
+ if (heap_->gc_state() == Heap::SCAVENGE) {
SetCachedAllocationWatermark(ObjectAreaStart());
}
SetRegionMarks(kAllRegionsCleanMarks);
@@ -413,7 +413,7 @@
Page* p = Page::FromAddress(addr);
ASSERT(p->is_valid());
- return Isolate::Current()->memory_allocator()->IsPageInSpace(p, this);
+ return heap()->isolate()->memory_allocator()->IsPageInSpace(p, this);
}
@@ -496,7 +496,7 @@
int LargeObjectSpace::Available() {
return LargeObjectChunk::ObjectSizeFor(
- Isolate::Current()->memory_allocator()->Available());
+ heap()->isolate()->memory_allocator()->Available());
}
=======================================
--- /branches/experimental/isolates/src/spaces.cc Wed Sep 15 08:34:43 2010
+++ /branches/experimental/isolates/src/spaces.cc Thu Sep 16 17:50:24 2010
@@ -585,6 +585,7 @@
Address page_addr = low;
for (int i = 0; i < pages_in_chunk; i++) {
Page* p = Page::FromAddress(page_addr);
+ p->heap_ = owner->heap();
p->opaque_header = OffsetFrom(page_addr + Page::kPageSize) | chunk_id;
p->InvalidateWatermark(true);
p->SetIsLargeObjectPage(false);
=======================================
--- /branches/experimental/isolates/src/spaces.h Wed Sep 15 08:34:43 2010
+++ /branches/experimental/isolates/src/spaces.h Thu Sep 16 17:50:24 2010
@@ -243,7 +243,7 @@
static const intptr_t kPageAlignmentMask = (1 << kPageSizeBits) - 1;
static const int kPageHeaderSize = kPointerSize + kPointerSize +
kIntSize +
- kIntSize + kPointerSize;
+ kIntSize + kPointerSize + kPointerSize;
// The start offset of the object area in a page.
static const int kObjectStartOffset = MAP_POINTER_ALIGN(kPageHeaderSize);
@@ -286,7 +286,7 @@
// This invariant guarantees that after flipping flag meaning at the
// beginning of scavenge all pages in use will be marked as having valid
// watermark.
- static inline void FlipMeaningOfInvalidatedWatermarkFlag();
+ static inline void FlipMeaningOfInvalidatedWatermarkFlag(Heap* heap);
// Returns true if the page allocation watermark was not altered during
// scavenge.
@@ -348,6 +348,8 @@
// During scavenge collection this field is used to store allocation
watermark
// if it is altered during scavenge.
Address mc_first_forwarded;
+
+ Heap* heap_;
};
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev