| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a052c03 commit 004137e
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,7 +36,7 @@ | |||
| 36 | 36 | ||
| 37 | 37 | # Reset this number to 0 on major V8 upgrades. | |
| 38 | 38 | # Increment by one for each non-official patch applied to deps/v8. | |
| 39 | - 'v8_embedder_string': '-node.10', | ||
| 39 | + 'v8_embedder_string': '-node.11', | ||
| 40 | 40 | ||
| 41 | 41 | ##### V8 defaults for Node.js ##### | |
| 42 | 42 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4283,6 +4283,9 @@ void Heap::AutomaticallyRestoreInitialHeapLimit(double threshold_percent) { | |||
| 4283 | 4283 | ||
| 4284 | 4284 | bool Heap::InvokeNearHeapLimitCallback() { | |
| 4285 | 4285 | if (near_heap_limit_callbacks_.size() > 0) { | |
| 4286 | + AllowGarbageCollection allow_gc; | ||
| 4287 | + TRACE_GC(tracer(), GCTracer::Scope::HEAP_EXTERNAL_NEAR_HEAP_LIMIT); | ||
| 4288 | + VMState<EXTERNAL> callback_state(isolate()); | ||
| 4286 | 4289 | HandleScope scope(isolate()); | |
| 4287 | 4290 | v8::NearHeapLimitCallback callback = | |
| 4288 | 4291 | near_heap_limit_callbacks_.back().first; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -527,6 +527,7 @@ | |||
| 527 | 527 | F(HEAP_EPILOGUE_REDUCE_NEW_SPACE) \ | |
| 528 | 528 | F(HEAP_EPILOGUE_SAFEPOINT) \ | |
| 529 | 529 | F(HEAP_EXTERNAL_EPILOGUE) \ | |
| 530 | + F(HEAP_EXTERNAL_NEAR_HEAP_LIMIT) \ | ||
| 530 | 531 | F(HEAP_EXTERNAL_PROLOGUE) \ | |
| 531 | 532 | F(HEAP_EXTERNAL_WEAK_GLOBAL_HANDLES) \ | |
| 532 | 533 | F(HEAP_PROLOGUE) \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1271,6 +1271,62 @@ UNINITIALIZED_TEST(Regress10843) { | |||
| 1271 | 1271 | isolate->Dispose(); | |
| 1272 | 1272 | } | |
| 1273 | 1273 | ||
| 1274 | + size_t near_heap_limit_invocation_count = 0; | ||
| 1275 | + size_t InvokeGCNearHeapLimitCallback(void* data, size_t current_heap_limit, | ||
| 1276 | + size_t initial_heap_limit) { | ||
| 1277 | + near_heap_limit_invocation_count++; | ||
| 1278 | + if (near_heap_limit_invocation_count > 1) { | ||
| 1279 | + // We are already in a GC triggered in this callback, raise the limit | ||
| 1280 | + // to avoid an OOM. | ||
| 1281 | + return current_heap_limit * 5; | ||
| 1282 | + } | ||
| 1283 | + | ||
| 1284 | + DCHECK_EQ(near_heap_limit_invocation_count, 1); | ||
| 1285 | + // Operations that may cause GC (e.g. taking heap snapshots) in the | ||
| 1286 | + // near heap limit callback should not hit the AllowGarbageCollection | ||
| 1287 | + // assertion. | ||
| 1288 | + static_cast<v8::Isolate*>(data)->GetHeapProfiler()->TakeHeapSnapshot(); | ||
| 1289 | + return current_heap_limit * 5; | ||
| 1290 | + } | ||
| 1291 | + | ||
| 1292 | + UNINITIALIZED_TEST(Regress12777) { | ||
| 1293 | + v8::Isolate::CreateParams create_params; | ||
| 1294 | + create_params.constraints.set_max_old_generation_size_in_bytes(10 * i::MB); | ||
| 1295 | + create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); | ||
| 1296 | + v8::Isolate* isolate = v8::Isolate::New(create_params); | ||
| 1297 | + | ||
| 1298 | + isolate->AddNearHeapLimitCallback(InvokeGCNearHeapLimitCallback, isolate); | ||
| 1299 | + | ||
| 1300 | + { | ||
| 1301 | + v8::Isolate::Scope isolate_scope(isolate); | ||
| 1302 | + | ||
| 1303 | + Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate); | ||
| 1304 | + // Allocate data to trigger the NearHeapLimitCallback. | ||
| 1305 | + HandleScope scope(i_isolate); | ||
| 1306 | + int length = 2 * i::MB / i::kTaggedSize; | ||
| 1307 | + std::vector<Handle<FixedArray>> arrays; | ||
| 1308 | + for (int i = 0; i < 5; i++) { | ||
| 1309 | + arrays.push_back(i_isolate->factory()->NewFixedArray(length)); | ||
| 1310 | + } | ||
| 1311 | + CcTest::CollectAllGarbage(i_isolate); | ||
| 1312 | + for (int i = 0; i < 5; i++) { | ||
| 1313 | + arrays.push_back(i_isolate->factory()->NewFixedArray(length)); | ||
| 1314 | + } | ||
| 1315 | + CcTest::CollectAllGarbage(i_isolate); | ||
| 1316 | + for (int i = 0; i < 5; i++) { | ||
| 1317 | + arrays.push_back(i_isolate->factory()->NewFixedArray(length)); | ||
| 1318 | + } | ||
| 1319 | + | ||
| 1320 | + // The work done above should trigger the heap limit callback at least | ||
| 1321 | + // twice to prove that the callback can raise the limit in the second | ||
| 1322 | + // or later calls to avoid an OOM. | ||
| 1323 | + CHECK_GE(near_heap_limit_invocation_count, 2); | ||
| 1324 | + } | ||
| 1325 | + | ||
| 1326 | + isolate->GetHeapProfiler()->DeleteAllHeapSnapshots(); | ||
| 1327 | + isolate->Dispose(); | ||
| 1328 | + } | ||
| 1329 | + | ||
| 1274 | 1330 | #ifndef V8_LITE_MODE | |
| 1275 | 1331 | ||
| 1276 | 1332 | TEST(TestOptimizeAfterBytecodeFlushingCandidate) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments