OLD | NEW |
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 6611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6622 break_point_hit_count = 0; | 6622 break_point_hit_count = 0; |
6623 CompileRun( | 6623 CompileRun( |
6624 "function foo() {\n" | 6624 "function foo() {\n" |
6625 " try { throw new Error(); } catch (e) {}\n" | 6625 " try { throw new Error(); } catch (e) {}\n" |
6626 "}\n" | 6626 "}\n" |
6627 "debugger;\n" | 6627 "debugger;\n" |
6628 "foo();\n" | 6628 "foo();\n" |
6629 "foo();\n"); | 6629 "foo();\n"); |
6630 | 6630 |
6631 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 6631 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); |
6632 CHECK_EQ(break_point_hit_count, 4); | 6632 CHECK_EQ(4, break_point_hit_count); |
6633 } | 6633 } |
6634 | 6634 |
6635 bool out_of_memory_callback_called = false; | 6635 bool out_of_memory_callback_called = false; |
6636 void OutOfMemoryCallback(void* data) { | 6636 void OutOfMemoryCallback(void* data) { |
6637 out_of_memory_callback_called = true; | 6637 out_of_memory_callback_called = true; |
6638 reinterpret_cast<v8::Isolate*>(data)->IncreaseHeapLimitForDebugging(); | 6638 reinterpret_cast<v8::Isolate*>(data)->IncreaseHeapLimitForDebugging(); |
6639 } | 6639 } |
6640 | 6640 |
6641 UNINITIALIZED_TEST(DebugSetOutOfMemoryListener) { | 6641 UNINITIALIZED_TEST(DebugSetOutOfMemoryListener) { |
6642 v8::Isolate::CreateParams create_params; | 6642 v8::Isolate::CreateParams create_params; |
6643 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); | 6643 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); |
6644 create_params.constraints.set_max_old_space_size(10); | 6644 create_params.constraints.set_max_old_space_size(10); |
6645 v8::Isolate* isolate = v8::Isolate::New(create_params); | 6645 v8::Isolate* isolate = v8::Isolate::New(create_params); |
6646 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6646 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6647 { | 6647 { |
6648 v8::Isolate::Scope i_scope(isolate); | 6648 v8::Isolate::Scope i_scope(isolate); |
6649 v8::HandleScope scope(isolate); | 6649 v8::HandleScope scope(isolate); |
6650 LocalContext context(isolate); | 6650 LocalContext context(isolate); |
6651 v8::debug::SetOutOfMemoryCallback(isolate, OutOfMemoryCallback, | 6651 v8::debug::SetOutOfMemoryCallback(isolate, OutOfMemoryCallback, |
6652 reinterpret_cast<void*>(isolate)); | 6652 reinterpret_cast<void*>(isolate)); |
6653 CHECK(!out_of_memory_callback_called); | 6653 CHECK(!out_of_memory_callback_called); |
6654 // The following allocation fails unless the out-of-memory callback | 6654 // The following allocation fails unless the out-of-memory callback |
6655 // increases the heap limit. | 6655 // increases the heap limit. |
6656 int length = 10 * i::MB / i::kPointerSize; | 6656 int length = 10 * i::MB / i::kPointerSize; |
6657 i_isolate->factory()->NewFixedArray(length, i::TENURED); | 6657 i_isolate->factory()->NewFixedArray(length, i::TENURED); |
6658 CHECK(out_of_memory_callback_called); | 6658 CHECK(out_of_memory_callback_called); |
6659 } | 6659 } |
6660 isolate->Dispose(); | 6660 isolate->Dispose(); |
6661 } | 6661 } |
OLD | NEW |