Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2570)

Unified Diff: runtime/vm/zone_test.cc

Issue 2762323002: Reimplemented zone memory tracking to avoid race conditions that were causing crashes in the previo… (Closed)
Patch Set: Final change Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/zone.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/zone_test.cc
diff --git a/runtime/vm/zone_test.cc b/runtime/vm/zone_test.cc
index d491e1f6bfb92d4cb2d7ddf185ff115f1331d51a..b151d2d7957bae4e0430fbcacf55004558d4f7ce 100644
--- a/runtime/vm/zone_test.cc
+++ b/runtime/vm/zone_test.cc
@@ -22,7 +22,7 @@ VM_UNIT_TEST_CASE(AllocateZone) {
StackZone stack_zone(thread);
EXPECT(thread->zone() != NULL);
Zone* zone = stack_zone.GetZone();
- intptr_t allocated_size = 0;
+ uintptr_t allocated_size = 0;
// The loop is to make sure we overflow one segment and go on
// to the next segment.
@@ -83,7 +83,7 @@ VM_UNIT_TEST_CASE(AllocGeneric_Success) {
{
StackZone zone(thread);
EXPECT(thread->zone() != NULL);
- intptr_t allocated_size = 0;
+ uintptr_t allocated_size = 0;
const intptr_t kNumElements = 1000;
zone.GetZone()->Alloc<uint32_t>(kNumElements);
@@ -139,13 +139,13 @@ VM_UNIT_TEST_CASE(ZoneAllocated) {
// Create a few zone allocated objects.
{
StackZone zone(thread);
- EXPECT_EQ(0, zone.SizeInBytes());
+ EXPECT_EQ(0UL, zone.SizeInBytes());
SimpleZoneObject* first = new SimpleZoneObject();
EXPECT(first != NULL);
SimpleZoneObject* second = new SimpleZoneObject();
EXPECT(second != NULL);
EXPECT(first != second);
- intptr_t expected_size = (2 * sizeof(SimpleZoneObject));
+ uintptr_t expected_size = (2 * sizeof(SimpleZoneObject));
EXPECT_LE(expected_size, zone.SizeInBytes());
// Make sure the constructors were invoked.
@@ -170,69 +170,10 @@ TEST_CASE(PrintToString) {
}
-#ifndef PRODUCT
-VM_UNIT_TEST_CASE(PrintZoneMemoryInfoToJSON) {
-#if defined(DEBUG)
- FLAG_trace_zones = true;
-#endif
- Dart_CreateIsolate(NULL, NULL, bin::core_isolate_snapshot_data,
- bin::core_isolate_snapshot_instructions, NULL, NULL, NULL);
- Thread* thread = Thread::Current();
- EXPECT(thread->zone() == NULL);
- {
- StackZone zone(thread);
- StackZone string_stack_zone(thread);
- EXPECT(thread->zone() != NULL);
-
- intptr_t allocated_size = 0;
- const intptr_t kNumElements = 1000;
-
- zone.GetZone()->Alloc<uint32_t>(kNumElements);
- allocated_size += sizeof(uint32_t) * kNumElements;
-
- EXPECT_LE(allocated_size, zone.SizeInBytes());
- {
- JSONStream stream;
- // Get the JSON formated zone information.
- zone.GetZone()->PrintJSON(&stream);
- const char* json = stream.ToCString();
- // Ensure that matches actual values.
- char* size_buf =
- OS::SCreate(string_stack_zone.GetZone(), "\"capacity\":%" Pd
- ","
- "\"used\":%" Pd "",
- zone.CapacityInBytes(), zone.SizeInBytes());
- EXPECT_LE(zone.SizeInBytes(), zone.CapacityInBytes());
- EXPECT_SUBSTRING(size_buf, json);
- }
-
- // Expand the zone to ensure that JSON is updated accordingly.
- zone.GetZone()->Alloc<uint32_t>(kNumElements);
- allocated_size += sizeof(uint32_t) * kNumElements;
- EXPECT_LE(allocated_size, zone.SizeInBytes());
- {
- JSONStream stream;
- zone.GetZone()->PrintJSON(&stream);
- const char* json = stream.ToCString();
- char* size_buf =
- OS::SCreate(string_stack_zone.GetZone(), "\"capacity\":%" Pd
- ","
- "\"used\":%" Pd "",
- zone.CapacityInBytes(), zone.SizeInBytes());
- EXPECT_LE(zone.SizeInBytes(), zone.CapacityInBytes());
- EXPECT_SUBSTRING(size_buf, json);
- }
- }
- EXPECT(thread->zone() == NULL);
- Dart_ShutdownIsolate();
-}
-#endif
-
-
VM_UNIT_TEST_CASE(NativeScopeZoneAllocation) {
ASSERT(ApiNativeScope::Current() == NULL);
ASSERT(Thread::Current() == NULL);
- EXPECT_EQ(0, ApiNativeScope::current_memory_usage());
+ EXPECT_EQ(0UL, ApiNativeScope::current_memory_usage());
{
ApiNativeScope scope;
EXPECT_EQ(scope.zone()->CapacityInBytes(),
@@ -241,7 +182,7 @@ VM_UNIT_TEST_CASE(NativeScopeZoneAllocation) {
EXPECT_EQ(scope.zone()->CapacityInBytes(),
ApiNativeScope::current_memory_usage());
}
- EXPECT_EQ(0, ApiNativeScope::current_memory_usage());
+ EXPECT_EQ(0UL, ApiNativeScope::current_memory_usage());
}
} // namespace dart
« no previous file with comments | « runtime/vm/zone.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698