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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/heap/heap.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 6647 matching lines...) Expand 10 before | Expand all | Expand 10 after
6658 "function foo() {\n" 6658 "function foo() {\n"
6659 " try { throw new Error(); } catch (e) {}\n" 6659 " try { throw new Error(); } catch (e) {}\n"
6660 "}\n" 6660 "}\n"
6661 "debugger;\n" 6661 "debugger;\n"
6662 "foo();\n" 6662 "foo();\n"
6663 "foo();\n"); 6663 "foo();\n");
6664 6664
6665 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 6665 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
6666 CHECK_EQ(break_point_hit_count, 4); 6666 CHECK_EQ(break_point_hit_count, 4);
6667 } 6667 }
6668
6669 bool out_of_memory_callback_called = false;
6670 void OutOfMemoryCallback(void* data) {
6671 out_of_memory_callback_called = true;
6672 reinterpret_cast<v8::Isolate*>(data)->IncreaseHeapLimitForDebugging();
6673 }
6674
6675 UNINITIALIZED_TEST(DebugSetOutOfMemoryListener) {
6676 v8::Isolate::CreateParams create_params;
6677 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
6678 create_params.constraints.set_max_old_space_size(10);
6679 v8::Isolate* isolate = v8::Isolate::New(create_params);
6680 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6681 {
6682 v8::Isolate::Scope i_scope(isolate);
6683 v8::HandleScope scope(isolate);
6684 LocalContext context(isolate);
6685 v8::debug::SetOutOfMemoryCallback(isolate, OutOfMemoryCallback,
6686 reinterpret_cast<void*>(isolate));
6687 CHECK(!out_of_memory_callback_called);
6688 // The following allocation fails unless the out-of-memory callback
6689 // increases the heap limit.
6690 int length = 10 * i::MB / i::kPointerSize;
6691 i_isolate->factory()->NewFixedArray(length, i::TENURED);
6692 CHECK(out_of_memory_callback_called);
6693 }
6694 isolate->Dispose();
6695 }
OLDNEW
« 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