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

Unified Diff: test/cctest/test-debug.cc

Issue 2621873003: [heap, debugger] Introduce out-of-memory listener for debugger. (Closed)
Patch Set: remove isolate parameter of the callback Created 3 years, 11 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 | « src/heap/heap.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-debug.cc
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index 5af65cb1082e52a1e21c630d39d764084d2b22eb..e7c2d23c35f27891b81a65014ae382a12137ff4e 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -6665,3 +6665,31 @@ TEST(DebugStepOverFunctionWithCaughtException) {
v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
CHECK_EQ(break_point_hit_count, 4);
}
+
+bool out_of_memory_callback_called = false;
+void OutOfMemoryCallback(void* data) {
+ out_of_memory_callback_called = true;
+ reinterpret_cast<v8::Isolate*>(data)->IncreaseHeapLimitForDebugging();
+}
+
+UNINITIALIZED_TEST(DebugSetOutOfMemoryListener) {
+ v8::Isolate::CreateParams create_params;
+ create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
+ create_params.constraints.set_max_old_space_size(10);
+ v8::Isolate* isolate = v8::Isolate::New(create_params);
+ i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ {
+ v8::Isolate::Scope i_scope(isolate);
+ v8::HandleScope scope(isolate);
+ LocalContext context(isolate);
+ v8::debug::SetOutOfMemoryCallback(isolate, OutOfMemoryCallback,
+ reinterpret_cast<void*>(isolate));
+ CHECK(!out_of_memory_callback_called);
+ // The following allocation fails unless the out-of-memory callback
+ // increases the heap limit.
+ int length = 10 * i::MB / i::kPointerSize;
+ i_isolate->factory()->NewFixedArray(length, i::TENURED);
+ CHECK(out_of_memory_callback_called);
+ }
+ isolate->Dispose();
+}
« no previous file with comments | « src/heap/heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698