v8::Persistent<Context> context;
v8::Persistent<Context> other_context;
int gc_count;
+ bool snapshot_enabled = i::Snapshot::IsEnabled();
// Create a context used to keep the code from aging in the compilation
// cache.
CompileRun(source_simple);
other_context->Exit();
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
- if (GetGlobalObjectsCount() == 1) break;
+ if (GetGlobalObjectsCount() == (snapshot_enabled ? 2 : 1)) break;
}
CHECK_GE(2, gc_count);
- CHECK_EQ(1, GetGlobalObjectsCount());
+ CHECK_EQ((snapshot_enabled ? 2 : 1), GetGlobalObjectsCount());
// Eval in a function creates reference from the compilation cache to the
// global object.
CompileRun(source_eval);
other_context->Exit();
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
- if (GetGlobalObjectsCount() == 1) break;
+ if (GetGlobalObjectsCount() == (snapshot_enabled ? 2 : 1)) break;
}
CHECK_GE(2, gc_count);
- CHECK_EQ(1, GetGlobalObjectsCount());
+ CHECK_EQ((snapshot_enabled ? 2 : 1), GetGlobalObjectsCount());
// Looking up the line number for an exception creates reference from the
// compilation cache to the global object.
CompileRun(source_exception);
other_context->Exit();
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
- if (GetGlobalObjectsCount() == 1) break;
+ if (GetGlobalObjectsCount() == (snapshot_enabled ? 2 : 1)) break;
}
CHECK_GE(2, gc_count);
- CHECK_EQ(1, GetGlobalObjectsCount());
+ CHECK_EQ((snapshot_enabled ? 2 : 1), GetGlobalObjectsCount());
other_context.Dispose();
}
static const v8::HeapGraphNode* GetGlobalObject(
const v8::HeapSnapshot* snapshot) {
- CHECK_EQ(2, snapshot->GetRoot()->GetChildrenCount());
+ bool snapshot_enabled = i::Snapshot::IsEnabled();
+
+ CHECK_EQ((snapshot_enabled ? 3 : 2), snapshot->GetRoot()->GetChildrenCount());
const v8::HeapGraphNode* global_obj =
- snapshot->GetRoot()->GetChild(0)->GetToNode();
+ snapshot->GetRoot()->GetChild(snapshot_enabled ? 1 : 0)->GetToNode();
CHECK_EQ(0, strncmp("Object", const_cast<i::HeapEntry*>(
reinterpret_cast<const i::HeapEntry*>(global_obj))->name(), 6));
return global_obj;
" return null;\n"
"}\n");
// Get the string index using the path: <root> -> <global>.b.x.s
- v8::Local<v8::Value> string_obj_pos_val = CompileRun(
- "GetChildPosByProperty(\n"
- " GetChildPosByProperty(\n"
- " GetChildPosByProperty("
- " parsed.nodes[1 + children_offset + child_to_node_offset],"
- " \"b\",shortcut_type),\n"
- " \"x\", property_type),"
- " \"s\", property_type)");
+ v8::Local<v8::Value> string_obj_pos_val;
+ if (i::Snapshot::IsEnabled()) {
+ string_obj_pos_val = CompileRun(
+ "GetChildPosByProperty(\n"
+ " GetChildPosByProperty(\n"
+ " GetChildPosByProperty("
+ " parsed.nodes[1 + children_offset + child_to_node_offset + child_fields_count],"
+ " \"b\",shortcut_type),\n"
+ " \"x\", property_type),"
+ " \"s\", property_type)");
+ } else {
+ string_obj_pos_val = CompileRun(
+ "GetChildPosByProperty(\n"
+ " GetChildPosByProperty(\n"
+ " GetChildPosByProperty("
+ " parsed.nodes[1 + children_offset + child_to_node_offset],"
+ " \"b\",shortcut_type),\n"
+ " \"x\", property_type),"
+ " \"s\", property_type)");
+ }
CHECK(!string_obj_pos_val.IsEmpty());
int string_obj_pos =
static_cast<int>(string_obj_pos_val->ToNumber()->Value());
#include "macro-assembler.h"
#include "global-handles.h"
#include "cctest.h"
+#include "snapshot.h"
using namespace v8::internal;
// optimized code.
TEST(LeakGlobalContextViaMap) {
i::FLAG_allow_natives_syntax = true;
+ bool snapshot_enabled = i::Snapshot::IsEnabled();
v8::HandleScope outer_scope;
v8::Persistent<v8::Context> ctx1 = v8::Context::New();
v8::Persistent<v8::Context> ctx2 = v8::Context::New();
ctx1->Enter();
HEAP->CollectAllAvailableGarbage();
- CHECK_EQ(4, NumberOfGlobalObjects());
+ CHECK_EQ((snapshot_enabled ? 6 : 4), NumberOfGlobalObjects());
{
v8::HandleScope inner_scope;
ctx1.Dispose();
}
HEAP->CollectAllAvailableGarbage();
- CHECK_EQ(2, NumberOfGlobalObjects());
+ CHECK_EQ((snapshot_enabled ? 3 : 2), NumberOfGlobalObjects());
ctx2.Dispose();
HEAP->CollectAllAvailableGarbage();
CHECK_EQ(0, NumberOfGlobalObjects());
// optimized code.
TEST(LeakGlobalContextViaFunction) {
i::FLAG_allow_natives_syntax = true;
+ bool snapshot_enabled = i::Snapshot::IsEnabled();
v8::HandleScope outer_scope;
v8::Persistent<v8::Context> ctx1 = v8::Context::New();
v8::Persistent<v8::Context> ctx2 = v8::Context::New();
ctx1->Enter();
HEAP->CollectAllAvailableGarbage();
- CHECK_EQ(4, NumberOfGlobalObjects());
+ CHECK_EQ((snapshot_enabled ? 6 : 4), NumberOfGlobalObjects());
{
v8::HandleScope inner_scope;
ctx1.Dispose();
}
HEAP->CollectAllAvailableGarbage();
- CHECK_EQ(2, NumberOfGlobalObjects());
+ CHECK_EQ((snapshot_enabled ? 3 : 2), NumberOfGlobalObjects());
ctx2.Dispose();
HEAP->CollectAllAvailableGarbage();
CHECK_EQ(0, NumberOfGlobalObjects());
TEST(LeakGlobalContextViaMapKeyed) {
i::FLAG_allow_natives_syntax = true;
+ bool snapshot_enabled = i::Snapshot::IsEnabled();
v8::HandleScope outer_scope;
v8::Persistent<v8::Context> ctx1 = v8::Context::New();
v8::Persistent<v8::Context> ctx2 = v8::Context::New();
ctx1->Enter();
HEAP->CollectAllAvailableGarbage();
- CHECK_EQ(4, NumberOfGlobalObjects());
+ CHECK_EQ((snapshot_enabled ? 6 : 4), NumberOfGlobalObjects());
{
v8::HandleScope inner_scope;
ctx1.Dispose();
}
HEAP->CollectAllAvailableGarbage();
- CHECK_EQ(2, NumberOfGlobalObjects());
+ CHECK_EQ((snapshot_enabled ? 3 : 2), NumberOfGlobalObjects());
ctx2.Dispose();
HEAP->CollectAllAvailableGarbage();
CHECK_EQ(0, NumberOfGlobalObjects());
TEST(LeakGlobalContextViaMapProto) {
i::FLAG_allow_natives_syntax = true;
+ bool snapshot_enabled = i::Snapshot::IsEnabled();
v8::HandleScope outer_scope;
v8::Persistent<v8::Context> ctx1 = v8::Context::New();
v8::Persistent<v8::Context> ctx2 = v8::Context::New();
ctx1->Enter();
HEAP->CollectAllAvailableGarbage();
- CHECK_EQ(4, NumberOfGlobalObjects());
+ CHECK_EQ((snapshot_enabled ? 6 : 4), NumberOfGlobalObjects());
{
v8::HandleScope inner_scope;
ctx1.Dispose();
}
HEAP->CollectAllAvailableGarbage();
- CHECK_EQ(2, NumberOfGlobalObjects());
+ CHECK_EQ((snapshot_enabled ? 3 : 2), NumberOfGlobalObjects());
ctx2.Dispose();
HEAP->CollectAllAvailableGarbage();
CHECK_EQ(0, NumberOfGlobalObjects());