Commit 64c96ad9 authored by loislo@chromium.org's avatar loislo@chromium.org

There is a trick for speed up array shift operation.

This trick is confusing a bit the heap snapshoting code.
Such a shiffted array will be interpreted as a new array in the second snapshot.

BUG=none
TEST=HeapEntryIdsAndArrayShift

Review URL: https://chromiumcodereview.appspot.com/9748007

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11096 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c7c3f8d5
......@@ -33,6 +33,7 @@
#include "builtins.h"
#include "gdb-jit.h"
#include "ic-inl.h"
#include "heap-profiler.h"
#include "mark-compact.h"
#include "vm-state-inl.h"
......@@ -380,6 +381,8 @@ static FixedArray* LeftTrimFixedArray(Heap* heap,
MemoryChunk::IncrementLiveBytesFromMutator(elms->address(), -size_delta);
}
HEAP_PROFILE(heap, ObjectMoveEvent(elms->address(),
elms->address() + size_delta));
return FixedArray::cast(HeapObject::FromAddress(
elms->address() + to_trim * kPointerSize));
}
......
......@@ -352,6 +352,59 @@ TEST(HeapSnapshotInternalReferences) {
#define CHECK_NE_UINT64_T(a, b) \
CHECK((a) != (b)) // NOLINT
TEST(HeapEntryIdsAndArrayShift) {
v8::HandleScope scope;
LocalContext env;
CompileRun(
"function AnObject() {\n"
" this.first = 'first';\n"
" this.second = 'second';\n"
"}\n"
"var a = new Array();\n"
"for (var i = 0; i < 10; ++i)\n"
" a.push(new AnObject());\n");
const v8::HeapSnapshot* snapshot1 =
v8::HeapProfiler::TakeSnapshot(v8_str("s1"));
CompileRun(
"for (var i = 0; i < 1; ++i)\n"
" a.shift();\n");
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
const v8::HeapSnapshot* snapshot2 =
v8::HeapProfiler::TakeSnapshot(v8_str("s2"));
const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1);
const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2);
CHECK_NE_UINT64_T(0, global1->GetId());
CHECK_EQ_UINT64_T(global1->GetId(), global2->GetId());
const v8::HeapGraphNode* a1 =
GetProperty(global1, v8::HeapGraphEdge::kProperty, "a");
CHECK_NE(NULL, a1);
const v8::HeapGraphNode* e1 =
GetProperty(a1, v8::HeapGraphEdge::kHidden, "1");
CHECK_NE(NULL, e1);
const v8::HeapGraphNode* k1 =
GetProperty(e1, v8::HeapGraphEdge::kInternal, "elements");
CHECK_NE(NULL, k1);
const v8::HeapGraphNode* a2 =
GetProperty(global2, v8::HeapGraphEdge::kProperty, "a");
CHECK_NE(NULL, a2);
const v8::HeapGraphNode* e2 =
GetProperty(a2, v8::HeapGraphEdge::kHidden, "1");
CHECK_NE(NULL, e2);
const v8::HeapGraphNode* k2 =
GetProperty(e2, v8::HeapGraphEdge::kInternal, "elements");
CHECK_NE(NULL, k2);
CHECK_EQ_UINT64_T(a1->GetId(), a2->GetId());
CHECK_EQ_UINT64_T(e1->GetId(), e2->GetId());
CHECK_EQ_UINT64_T(k1->GetId(), k2->GetId());
}
TEST(HeapEntryIdsAndGC) {
v8::HandleScope scope;
LocalContext env;
......
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