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

Side by Side Diff: test/cctest/test-heap.cc

Issue 1506753002: [test] Test expectations in cctest should use CHECK and not DCHECK. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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 | « test/cctest/test-global-handles.cc ('k') | test/cctest/test-heap-profiler.cc » ('j') | 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 1849 matching lines...) Expand 10 before | Expand all | Expand 10 after
1860 1860
1861 v8::V8::Initialize(); 1861 v8::V8::Initialize();
1862 1862
1863 Isolate* isolate = CcTest::i_isolate(); 1863 Isolate* isolate = CcTest::i_isolate();
1864 HandleScope scope(isolate); 1864 HandleScope scope(isolate);
1865 1865
1866 LocalContext context; 1866 LocalContext context;
1867 1867
1868 // Adjust source below and this check to match 1868 // Adjust source below and this check to match
1869 // RegExpImple::kRegExpTooLargeToOptimize. 1869 // RegExpImple::kRegExpTooLargeToOptimize.
1870 DCHECK_EQ(i::RegExpImpl::kRegExpTooLargeToOptimize, 20 * KB); 1870 CHECK_EQ(i::RegExpImpl::kRegExpTooLargeToOptimize, 20 * KB);
1871 1871
1872 // Compile a regexp that is much larger if we are using regexp optimizations. 1872 // Compile a regexp that is much larger if we are using regexp optimizations.
1873 CompileRun( 1873 CompileRun(
1874 "var reg_exp_source = '(?:a|bc|def|ghij|klmno|pqrstu)';" 1874 "var reg_exp_source = '(?:a|bc|def|ghij|klmno|pqrstu)';"
1875 "var half_size_reg_exp;" 1875 "var half_size_reg_exp;"
1876 "while (reg_exp_source.length < 20 * 1024) {" 1876 "while (reg_exp_source.length < 20 * 1024) {"
1877 " half_size_reg_exp = reg_exp_source;" 1877 " half_size_reg_exp = reg_exp_source;"
1878 " reg_exp_source = reg_exp_source + reg_exp_source;" 1878 " reg_exp_source = reg_exp_source + reg_exp_source;"
1879 "}" 1879 "}"
1880 // Flatten string. 1880 // Flatten string.
(...skipping 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after
3464 CompileRun("var root = new F;"); 3464 CompileRun("var root = new F;");
3465 Handle<JSObject> root = GetByName("root"); 3465 Handle<JSObject> root = GetByName("root");
3466 3466
3467 // Count number of live transitions before marking. 3467 // Count number of live transitions before marking.
3468 int transitions_before = CountMapTransitions(root->map()); 3468 int transitions_before = CountMapTransitions(root->map());
3469 CHECK_EQ(transitions_count, transitions_before); 3469 CHECK_EQ(transitions_count, transitions_before);
3470 3470
3471 CompileRun("o = new F;" 3471 CompileRun("o = new F;"
3472 "root = new F"); 3472 "root = new F");
3473 root = GetByName("root"); 3473 root = GetByName("root");
3474 DCHECK(TransitionArray::IsSimpleTransition(root->map()->raw_transitions())); 3474 CHECK(TransitionArray::IsSimpleTransition(root->map()->raw_transitions()));
3475 AddPropertyTo(2, root, "happy"); 3475 AddPropertyTo(2, root, "happy");
3476 3476
3477 // Count number of live transitions after marking. Note that one transition 3477 // Count number of live transitions after marking. Note that one transition
3478 // is left, because 'o' still holds an instance of one transition target. 3478 // is left, because 'o' still holds an instance of one transition target.
3479 int transitions_after = CountMapTransitions( 3479 int transitions_after = CountMapTransitions(
3480 Map::cast(root->map()->GetBackPointer())); 3480 Map::cast(root->map()->GetBackPointer()));
3481 CHECK_EQ(1, transitions_after); 3481 CHECK_EQ(1, transitions_after);
3482 } 3482 }
3483 #endif // DEBUG 3483 #endif // DEBUG
3484 3484
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after
4608 Isolate* isolate = CcTest::i_isolate(); 4608 Isolate* isolate = CcTest::i_isolate();
4609 Heap* heap = isolate->heap(); 4609 Heap* heap = isolate->heap();
4610 v8::HandleScope scope(reinterpret_cast<v8::Isolate*>(isolate)); 4610 v8::HandleScope scope(reinterpret_cast<v8::Isolate*>(isolate));
4611 HandleScopeData* data = isolate->handle_scope_data(); 4611 HandleScopeData* data = isolate->handle_scope_data();
4612 Handle<Object> init(heap->empty_string(), isolate); 4612 Handle<Object> init(heap->empty_string(), isolate);
4613 while (data->next < data->limit) { 4613 while (data->next < data->limit) {
4614 Handle<Object> obj(heap->empty_string(), isolate); 4614 Handle<Object> obj(heap->empty_string(), isolate);
4615 } 4615 }
4616 // An entire block of handles has been filled. 4616 // An entire block of handles has been filled.
4617 // Next handle would require a new block. 4617 // Next handle would require a new block.
4618 DCHECK(data->next == data->limit); 4618 CHECK(data->next == data->limit);
4619 4619
4620 DeferredHandleScope deferred(isolate); 4620 DeferredHandleScope deferred(isolate);
4621 DummyVisitor visitor; 4621 DummyVisitor visitor;
4622 isolate->handle_scope_implementer()->Iterate(&visitor); 4622 isolate->handle_scope_implementer()->Iterate(&visitor);
4623 delete deferred.Detach(); 4623 delete deferred.Detach();
4624 } 4624 }
4625 4625
4626 4626
4627 TEST(IncrementalMarkingStepMakesBigProgressWithLargeObjects) { 4627 TEST(IncrementalMarkingStepMakesBigProgressWithLargeObjects) {
4628 CcTest::InitializeVM(); 4628 CcTest::InitializeVM();
4629 v8::HandleScope scope(CcTest::isolate()); 4629 v8::HandleScope scope(CcTest::isolate());
4630 CompileRun("function f(n) {" 4630 CompileRun("function f(n) {"
4631 " var a = new Array(n);" 4631 " var a = new Array(n);"
4632 " for (var i = 0; i < n; i += 100) a[i] = i;" 4632 " for (var i = 0; i < n; i += 100) a[i] = i;"
4633 "};" 4633 "};"
4634 "f(10 * 1024 * 1024);"); 4634 "f(10 * 1024 * 1024);");
4635 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); 4635 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
4636 if (marking->IsStopped()) { 4636 if (marking->IsStopped()) {
4637 CcTest::heap()->StartIncrementalMarking(); 4637 CcTest::heap()->StartIncrementalMarking();
4638 } 4638 }
4639 // This big step should be sufficient to mark the whole array. 4639 // This big step should be sufficient to mark the whole array.
4640 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); 4640 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
4641 DCHECK(marking->IsComplete() || 4641 CHECK(marking->IsComplete() ||
4642 marking->IsReadyToOverApproximateWeakClosure()); 4642 marking->IsReadyToOverApproximateWeakClosure());
4643 } 4643 }
4644 4644
4645 4645
4646 TEST(DisableInlineAllocation) { 4646 TEST(DisableInlineAllocation) {
4647 i::FLAG_allow_natives_syntax = true; 4647 i::FLAG_allow_natives_syntax = true;
4648 CcTest::InitializeVM(); 4648 CcTest::InitializeVM();
4649 v8::HandleScope scope(CcTest::isolate()); 4649 v8::HandleScope scope(CcTest::isolate());
4650 CompileRun("function test() {" 4650 CompileRun("function test() {"
4651 " var x = [];" 4651 " var x = [];"
4652 " for (var i = 0; i < 10; i++) {" 4652 " for (var i = 0; i < 10; i++) {"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
4773 ->Get(context.local(), v8_str("bar")) 4773 ->Get(context.local(), v8_str("bar"))
4774 .ToLocalChecked()))); 4774 .ToLocalChecked())));
4775 code = scope.CloseAndEscape(Handle<Code>(bar->code())); 4775 code = scope.CloseAndEscape(Handle<Code>(bar->code()));
4776 } 4776 }
4777 4777
4778 // Now make sure that a gc should get rid of the function 4778 // Now make sure that a gc should get rid of the function
4779 for (int i = 0; i < 4; i++) { 4779 for (int i = 0; i < 4; i++) {
4780 heap->CollectAllGarbage(); 4780 heap->CollectAllGarbage();
4781 } 4781 }
4782 4782
4783 DCHECK(code->marked_for_deoptimization()); 4783 CHECK(code->marked_for_deoptimization());
4784 } 4784 }
4785 4785
4786 4786
4787 TEST(ObjectsInOptimizedCodeAreWeak) { 4787 TEST(ObjectsInOptimizedCodeAreWeak) {
4788 if (i::FLAG_always_opt || !i::FLAG_crankshaft) return; 4788 if (i::FLAG_always_opt || !i::FLAG_crankshaft) return;
4789 i::FLAG_weak_embedded_objects_in_optimized_code = true; 4789 i::FLAG_weak_embedded_objects_in_optimized_code = true;
4790 i::FLAG_allow_natives_syntax = true; 4790 i::FLAG_allow_natives_syntax = true;
4791 CcTest::InitializeVM(); 4791 CcTest::InitializeVM();
4792 Isolate* isolate = CcTest::i_isolate(); 4792 Isolate* isolate = CcTest::i_isolate();
4793 v8::internal::Heap* heap = CcTest::heap(); 4793 v8::internal::Heap* heap = CcTest::heap();
(...skipping 20 matching lines...) Expand all
4814 ->Get(context.local(), v8_str("bar")) 4814 ->Get(context.local(), v8_str("bar"))
4815 .ToLocalChecked()))); 4815 .ToLocalChecked())));
4816 code = scope.CloseAndEscape(Handle<Code>(bar->code())); 4816 code = scope.CloseAndEscape(Handle<Code>(bar->code()));
4817 } 4817 }
4818 4818
4819 // Now make sure that a gc should get rid of the function 4819 // Now make sure that a gc should get rid of the function
4820 for (int i = 0; i < 4; i++) { 4820 for (int i = 0; i < 4; i++) {
4821 heap->CollectAllGarbage(); 4821 heap->CollectAllGarbage();
4822 } 4822 }
4823 4823
4824 DCHECK(code->marked_for_deoptimization()); 4824 CHECK(code->marked_for_deoptimization());
4825 } 4825 }
4826 4826
4827 4827
4828 TEST(NoWeakHashTableLeakWithIncrementalMarking) { 4828 TEST(NoWeakHashTableLeakWithIncrementalMarking) {
4829 if (i::FLAG_always_opt || !i::FLAG_crankshaft) return; 4829 if (i::FLAG_always_opt || !i::FLAG_crankshaft) return;
4830 if (!i::FLAG_incremental_marking) return; 4830 if (!i::FLAG_incremental_marking) return;
4831 i::FLAG_weak_embedded_objects_in_optimized_code = true; 4831 i::FLAG_weak_embedded_objects_in_optimized_code = true;
4832 i::FLAG_allow_natives_syntax = true; 4832 i::FLAG_allow_natives_syntax = true;
4833 i::FLAG_compilation_cache = false; 4833 i::FLAG_compilation_cache = false;
4834 i::FLAG_retain_maps_for_n_gc = 0; 4834 i::FLAG_retain_maps_for_n_gc = 0;
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
5503 TEST(Regress357137) { 5503 TEST(Regress357137) {
5504 CcTest::InitializeVM(); 5504 CcTest::InitializeVM();
5505 v8::Isolate* isolate = CcTest::isolate(); 5505 v8::Isolate* isolate = CcTest::isolate();
5506 v8::HandleScope hscope(isolate); 5506 v8::HandleScope hscope(isolate);
5507 v8::Local<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate); 5507 v8::Local<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
5508 global->Set( 5508 global->Set(
5509 v8::String::NewFromUtf8(isolate, "interrupt", v8::NewStringType::kNormal) 5509 v8::String::NewFromUtf8(isolate, "interrupt", v8::NewStringType::kNormal)
5510 .ToLocalChecked(), 5510 .ToLocalChecked(),
5511 v8::FunctionTemplate::New(isolate, RequestInterrupt)); 5511 v8::FunctionTemplate::New(isolate, RequestInterrupt));
5512 v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global); 5512 v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);
5513 DCHECK(!context.IsEmpty()); 5513 CHECK(!context.IsEmpty());
5514 v8::Context::Scope cscope(context); 5514 v8::Context::Scope cscope(context);
5515 5515
5516 v8::Local<v8::Value> result = CompileRun( 5516 v8::Local<v8::Value> result = CompileRun(
5517 "var locals = '';" 5517 "var locals = '';"
5518 "for (var i = 0; i < 512; i++) locals += 'var v' + i + '= 42;';" 5518 "for (var i = 0; i < 512; i++) locals += 'var v' + i + '= 42;';"
5519 "eval('function f() {' + locals + 'return function() { return v0; }; }');" 5519 "eval('function f() {' + locals + 'return function() { return v0; }; }');"
5520 "interrupt();" // This triggers a fake stack overflow in f. 5520 "interrupt();" // This triggers a fake stack overflow in f.
5521 "f()()"); 5521 "f()()");
5522 CHECK_EQ(42.0, result->ToNumber(context).ToLocalChecked()->Value()); 5522 CHECK_EQ(42.0, result->ToNumber(context).ToLocalChecked()->Value());
5523 } 5523 }
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after
6441 isolate->IncrementJsCallsFromApiCounter(); 6441 isolate->IncrementJsCallsFromApiCounter();
6442 isolate->IncrementJsCallsFromApiCounter(); 6442 isolate->IncrementJsCallsFromApiCounter();
6443 isolate->IncrementJsCallsFromApiCounter(); 6443 isolate->IncrementJsCallsFromApiCounter();
6444 calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(4); 6444 calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(4);
6445 CheckDoubleEquals(2, calls_per_ms); 6445 CheckDoubleEquals(2, calls_per_ms);
6446 } 6446 }
6447 6447
6448 6448
6449 } // namespace internal 6449 } // namespace internal
6450 } // namespace v8 6450 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/test-global-handles.cc ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698