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

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

Issue 1999753002: [heap] Harden heap-related cctests (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix for win Created 4 years, 7 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 | « test/cctest/heap/utils-inl.h ('k') | test/cctest/test-dictionary.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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "src/compilation-cache.h" 44 #include "src/compilation-cache.h"
45 #include "src/debug/debug.h" 45 #include "src/debug/debug.h"
46 #include "src/execution.h" 46 #include "src/execution.h"
47 #include "src/futex-emulation.h" 47 #include "src/futex-emulation.h"
48 #include "src/objects.h" 48 #include "src/objects.h"
49 #include "src/parsing/parser.h" 49 #include "src/parsing/parser.h"
50 #include "src/unicode-inl.h" 50 #include "src/unicode-inl.h"
51 #include "src/utils.h" 51 #include "src/utils.h"
52 #include "src/vm-state.h" 52 #include "src/vm-state.h"
53 #include "test/cctest/heap/heap-tester.h" 53 #include "test/cctest/heap/heap-tester.h"
54 #include "test/cctest/heap/utils-inl.h" 54 #include "test/cctest/heap/heap-utils.h"
55 55
56 static const bool kLogThreading = false; 56 static const bool kLogThreading = false;
57 57
58 using ::v8::Boolean; 58 using ::v8::Boolean;
59 using ::v8::BooleanObject; 59 using ::v8::BooleanObject;
60 using ::v8::Context; 60 using ::v8::Context;
61 using ::v8::Extension; 61 using ::v8::Extension;
62 using ::v8::Function; 62 using ::v8::Function;
63 using ::v8::FunctionTemplate; 63 using ::v8::FunctionTemplate;
64 using ::v8::HandleScope; 64 using ::v8::HandleScope;
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 CompileRun("function cons(a, b) { return a + b; }" 627 CompileRun("function cons(a, b) { return a + b; }"
628 "function slice(a) { return a.substring(1); }"); 628 "function slice(a) { return a.substring(1); }");
629 // Create a cons string that will land in old pointer space. 629 // Create a cons string that will land in old pointer space.
630 Local<String> cons = Local<String>::Cast(CompileRun( 630 Local<String> cons = Local<String>::Cast(CompileRun(
631 "cons('abcdefghijklm', 'nopqrstuvwxyz');")); 631 "cons('abcdefghijklm', 'nopqrstuvwxyz');"));
632 // Create a sliced string that will land in old pointer space. 632 // Create a sliced string that will land in old pointer space.
633 Local<String> slice = Local<String>::Cast(CompileRun( 633 Local<String> slice = Local<String>::Cast(CompileRun(
634 "slice('abcdefghijklmnopqrstuvwxyz');")); 634 "slice('abcdefghijklmnopqrstuvwxyz');"));
635 635
636 // Trigger GCs so that the newly allocated string moves to old gen. 636 // Trigger GCs so that the newly allocated string moves to old gen.
637 SimulateFullSpace(CcTest::heap()->old_space()); 637 i::heap::SimulateFullSpace(CcTest::heap()->old_space());
638 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now 638 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
639 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now 639 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
640 640
641 // Turn into external string with unaligned resource data. 641 // Turn into external string with unaligned resource data.
642 const char* c_cons = "_abcdefghijklmnopqrstuvwxyz"; 642 const char* c_cons = "_abcdefghijklmnopqrstuvwxyz";
643 bool success = 643 bool success =
644 cons->MakeExternal(new TestOneByteResource(i::StrDup(c_cons), NULL, 1)); 644 cons->MakeExternal(new TestOneByteResource(i::StrDup(c_cons), NULL, 1));
645 CHECK(success); 645 CHECK(success);
646 const char* c_slice = "_bcdefghijklmnopqrstuvwxyz"; 646 const char* c_slice = "_bcdefghijklmnopqrstuvwxyz";
647 success = 647 success =
(...skipping 14143 matching lines...) Expand 10 before | Expand all | Expand 10 after
14791 move_events = 0; 14791 move_events = 0;
14792 14792
14793 isolate->SetJitCodeEventHandler(v8::kJitCodeEventDefault, event_handler); 14793 isolate->SetJitCodeEventHandler(v8::kJitCodeEventDefault, event_handler);
14794 14794
14795 // Generate new code objects sparsely distributed across several 14795 // Generate new code objects sparsely distributed across several
14796 // different fragmented code-space pages. 14796 // different fragmented code-space pages.
14797 const int kIterations = 10; 14797 const int kIterations = 10;
14798 for (int i = 0; i < kIterations; ++i) { 14798 for (int i = 0; i < kIterations; ++i) {
14799 LocalContext env(isolate); 14799 LocalContext env(isolate);
14800 i::AlwaysAllocateScope always_allocate(i_isolate); 14800 i::AlwaysAllocateScope always_allocate(i_isolate);
14801 SimulateFullSpace(i::FLAG_ignition ? heap->old_space() 14801 i::heap::SimulateFullSpace(i::FLAG_ignition ? heap->old_space()
14802 : heap->code_space()); 14802 : heap->code_space());
14803 CompileRun(script); 14803 CompileRun(script);
14804 14804
14805 // Keep a strong reference to the code object in the handle scope. 14805 // Keep a strong reference to the code object in the handle scope.
14806 i::Handle<i::Code> bar_code( 14806 i::Handle<i::Code> bar_code(
14807 i::Handle<i::JSFunction>::cast( 14807 i::Handle<i::JSFunction>::cast(
14808 v8::Utils::OpenHandle(*env->Global() 14808 v8::Utils::OpenHandle(*env->Global()
14809 ->Get(env.local(), v8_str("bar")) 14809 ->Get(env.local(), v8_str("bar"))
14810 .ToLocalChecked())) 14810 .ToLocalChecked()))
14811 ->code()); 14811 ->code());
14812 i::Handle<i::Code> foo_code( 14812 i::Handle<i::Code> foo_code(
(...skipping 4181 matching lines...) Expand 10 before | Expand all | Expand 10 after
18994 void PrologueCallbackAlloc(v8::Isolate* isolate, 18994 void PrologueCallbackAlloc(v8::Isolate* isolate,
18995 v8::GCType, 18995 v8::GCType,
18996 v8::GCCallbackFlags flags) { 18996 v8::GCCallbackFlags flags) {
18997 v8::HandleScope scope(isolate); 18997 v8::HandleScope scope(isolate);
18998 18998
18999 CHECK_EQ(flags, v8::kNoGCCallbackFlags); 18999 CHECK_EQ(flags, v8::kNoGCCallbackFlags);
19000 CHECK_EQ(gc_callbacks_isolate, isolate); 19000 CHECK_EQ(gc_callbacks_isolate, isolate);
19001 ++prologue_call_count_alloc; 19001 ++prologue_call_count_alloc;
19002 19002
19003 // Simulate full heap to see if we will reenter this callback 19003 // Simulate full heap to see if we will reenter this callback
19004 SimulateFullSpace(CcTest::heap()->new_space()); 19004 i::heap::SimulateFullSpace(CcTest::heap()->new_space());
19005 19005
19006 Local<Object> obj = Object::New(isolate); 19006 Local<Object> obj = Object::New(isolate);
19007 CHECK(!obj.IsEmpty()); 19007 CHECK(!obj.IsEmpty());
19008 19008
19009 CcTest::heap()->CollectAllGarbage( 19009 CcTest::heap()->CollectAllGarbage(
19010 i::Heap::kAbortIncrementalMarkingMask); 19010 i::Heap::kAbortIncrementalMarkingMask);
19011 } 19011 }
19012 19012
19013 19013
19014 void EpilogueCallbackAlloc(v8::Isolate* isolate, 19014 void EpilogueCallbackAlloc(v8::Isolate* isolate,
19015 v8::GCType, 19015 v8::GCType,
19016 v8::GCCallbackFlags flags) { 19016 v8::GCCallbackFlags flags) {
19017 v8::HandleScope scope(isolate); 19017 v8::HandleScope scope(isolate);
19018 19018
19019 CHECK_EQ(flags, v8::kNoGCCallbackFlags); 19019 CHECK_EQ(flags, v8::kNoGCCallbackFlags);
19020 CHECK_EQ(gc_callbacks_isolate, isolate); 19020 CHECK_EQ(gc_callbacks_isolate, isolate);
19021 ++epilogue_call_count_alloc; 19021 ++epilogue_call_count_alloc;
19022 19022
19023 // Simulate full heap to see if we will reenter this callback 19023 // Simulate full heap to see if we will reenter this callback
19024 SimulateFullSpace(CcTest::heap()->new_space()); 19024 i::heap::SimulateFullSpace(CcTest::heap()->new_space());
19025 19025
19026 Local<Object> obj = Object::New(isolate); 19026 Local<Object> obj = Object::New(isolate);
19027 CHECK(!obj.IsEmpty()); 19027 CHECK(!obj.IsEmpty());
19028 19028
19029 CcTest::heap()->CollectAllGarbage( 19029 CcTest::heap()->CollectAllGarbage(
19030 i::Heap::kAbortIncrementalMarkingMask); 19030 i::Heap::kAbortIncrementalMarkingMask);
19031 } 19031 }
19032 19032
19033 19033
19034 TEST(GCCallbacksOld) { 19034 TEST(GCCallbacksOld) {
(...skipping 6205 matching lines...) Expand 10 before | Expand all | Expand 10 after
25240 } 25240 }
25241 25241
25242 TEST(PrivateForApiIsNumber) { 25242 TEST(PrivateForApiIsNumber) {
25243 LocalContext context; 25243 LocalContext context;
25244 v8::Isolate* isolate = CcTest::isolate(); 25244 v8::Isolate* isolate = CcTest::isolate();
25245 v8::HandleScope scope(isolate); 25245 v8::HandleScope scope(isolate);
25246 25246
25247 // Shouldn't crash. 25247 // Shouldn't crash.
25248 v8::Private::ForApi(isolate, v8_str("42")); 25248 v8::Private::ForApi(isolate, v8_str("42"));
25249 } 25249 }
OLDNEW
« no previous file with comments | « test/cctest/heap/utils-inl.h ('k') | test/cctest/test-dictionary.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698