Chromium Code Reviews| 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 3185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3196 // OS so that other processes can seize the memory. If we get a failure here | 3196 // OS so that other processes can seize the memory. If we get a failure here |
| 3197 // where there are 2 pages left instead of 1, then we should increase the | 3197 // where there are 2 pages left instead of 1, then we should increase the |
| 3198 // size of the first page a little in SizeOfFirstPage in spaces.cc. The | 3198 // size of the first page a little in SizeOfFirstPage in spaces.cc. The |
| 3199 // first page should be small in order to reduce memory used when the VM | 3199 // first page should be small in order to reduce memory used when the VM |
| 3200 // boots, but if the 20 small arrays don't fit on the first page then that's | 3200 // boots, but if the 20 small arrays don't fit on the first page then that's |
| 3201 // an indication that it is too small. | 3201 // an indication that it is too small. |
| 3202 heap->CollectAllAvailableGarbage("triggered really hard"); | 3202 heap->CollectAllAvailableGarbage("triggered really hard"); |
| 3203 CHECK_EQ(1, old_space->CountTotalPages()); | 3203 CHECK_EQ(1, old_space->CountTotalPages()); |
| 3204 } | 3204 } |
| 3205 | 3205 |
| 3206 static int forced_gc_counter = 0; | |
| 3207 | |
| 3208 void MockUseCounterCallback(v8::Isolate* isolate, | |
| 3209 v8::Isolate::UseCounterFeature feature) { | |
| 3210 isolate->GetCallingContext(); | |
| 3211 if (feature == v8::Isolate::kForcedGC) { | |
| 3212 forced_gc_counter++; | |
| 3213 } | |
| 3214 } | |
| 3215 | |
| 3216 | |
| 3217 TEST(CountForcedGC) { | |
| 3218 i::FLAG_expose_gc = true; | |
| 3219 CcTest::InitializeVM(); | |
| 3220 Isolate* isolate = CcTest::i_isolate(); | |
| 3221 v8::HandleScope scope(CcTest::isolate()); | |
| 3222 | |
| 3223 isolate->SetUseCounterCallback(MockUseCounterCallback); | |
| 3224 | |
| 3225 forced_gc_counter = 0; | |
| 3226 const char* source = "gc();"; | |
| 3227 CompileRun(source); | |
| 3228 CHECK_GT(forced_gc_counter, 0); | |
|
Jakob Kummerow
2015/05/11 08:27:37
Why so conservative? Can this ever be != 1, and st
Erik Corry
2015/05/11 09:56:12
An emergency out-of-memory GC is also implemented
| |
| 3229 } | |
| 3230 | |
| 3206 | 3231 |
| 3207 TEST(Regress2237) { | 3232 TEST(Regress2237) { |
| 3208 i::FLAG_stress_compaction = false; | 3233 i::FLAG_stress_compaction = false; |
| 3209 CcTest::InitializeVM(); | 3234 CcTest::InitializeVM(); |
| 3210 Isolate* isolate = CcTest::i_isolate(); | 3235 Isolate* isolate = CcTest::i_isolate(); |
| 3211 Factory* factory = isolate->factory(); | 3236 Factory* factory = isolate->factory(); |
| 3212 v8::HandleScope scope(CcTest::isolate()); | 3237 v8::HandleScope scope(CcTest::isolate()); |
| 3213 Handle<String> slice(CcTest::heap()->empty_string()); | 3238 Handle<String> slice(CcTest::heap()->empty_string()); |
| 3214 | 3239 |
| 3215 { | 3240 { |
| (...skipping 2182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5398 CHECK(pos->IsSmi()); | 5423 CHECK(pos->IsSmi()); |
| 5399 | 5424 |
| 5400 Handle<JSArray> stack_trace_array = Handle<JSArray>::cast(stack_trace); | 5425 Handle<JSArray> stack_trace_array = Handle<JSArray>::cast(stack_trace); |
| 5401 int array_length = Smi::cast(stack_trace_array->length())->value(); | 5426 int array_length = Smi::cast(stack_trace_array->length())->value(); |
| 5402 for (int i = 0; i < array_length; i++) { | 5427 for (int i = 0; i < array_length; i++) { |
| 5403 Handle<Object> element = | 5428 Handle<Object> element = |
| 5404 Object::GetElement(isolate, stack_trace, i).ToHandleChecked(); | 5429 Object::GetElement(isolate, stack_trace, i).ToHandleChecked(); |
| 5405 CHECK(!element->IsCode()); | 5430 CHECK(!element->IsCode()); |
| 5406 } | 5431 } |
| 5407 } | 5432 } |
| OLD | NEW |