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

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

Issue 131363008: A64: Synchronize with r15922. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-disasm-arm.cc ('k') | test/cctest/test-log.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 966 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 Handle<Map> my_map = factory->CopyMap(object_map, 1); 977 Handle<Map> my_map = factory->CopyMap(object_map, 1);
978 int n_properties = my_map->inobject_properties(); 978 int n_properties = my_map->inobject_properties();
979 CHECK_GT(n_properties, 0); 979 CHECK_GT(n_properties, 0);
980 980
981 int object_size = my_map->instance_size(); 981 int object_size = my_map->instance_size();
982 982
983 // Step 2: allocate a lot of objects so to almost fill new space: we need 983 // Step 2: allocate a lot of objects so to almost fill new space: we need
984 // just enough room to allocate JSObject and thus fill the newspace. 984 // just enough room to allocate JSObject and thus fill the newspace.
985 985
986 int allocation_amount = Min(FixedArray::kMaxSize, 986 int allocation_amount = Min(FixedArray::kMaxSize,
987 HEAP->MaxObjectSizeInNewSpace()); 987 Page::kMaxNonCodeHeapObjectSize);
988 int allocation_len = LenFromSize(allocation_amount); 988 int allocation_len = LenFromSize(allocation_amount);
989 NewSpace* new_space = HEAP->new_space(); 989 NewSpace* new_space = HEAP->new_space();
990 Address* top_addr = new_space->allocation_top_address(); 990 Address* top_addr = new_space->allocation_top_address();
991 Address* limit_addr = new_space->allocation_limit_address(); 991 Address* limit_addr = new_space->allocation_limit_address();
992 while ((*limit_addr - *top_addr) > allocation_amount) { 992 while ((*limit_addr - *top_addr) > allocation_amount) {
993 CHECK(!HEAP->always_allocate()); 993 CHECK(!HEAP->always_allocate());
994 Object* array = HEAP->AllocateFixedArray(allocation_len)->ToObjectChecked(); 994 Object* array = HEAP->AllocateFixedArray(allocation_len)->ToObjectChecked();
995 CHECK(!array->IsFailure()); 995 CHECK(!array->IsFailure());
996 CHECK(new_space->Contains(array)); 996 CHECK(new_space->Contains(array));
997 } 997 }
(...skipping 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after
2813 size_t length() const { return length_; } 2813 size_t length() const { return length_; }
2814 2814
2815 bool IsDisposed() { return data_ == NULL; } 2815 bool IsDisposed() { return data_ == NULL; }
2816 2816
2817 private: 2817 private:
2818 const char* data_; 2818 const char* data_;
2819 size_t length_; 2819 size_t length_;
2820 }; 2820 };
2821 2821
2822 2822
2823 void ReleaseStackTraceDataTest(const char* source) { 2823 void ReleaseStackTraceDataTest(const char* source, const char* accessor) {
2824 // Test that the data retained by the Error.stack accessor is released 2824 // Test that the data retained by the Error.stack accessor is released
2825 // after the first time the accessor is fired. We use external string 2825 // after the first time the accessor is fired. We use external string
2826 // to check whether the data is being released since the external string 2826 // to check whether the data is being released since the external string
2827 // resource's callback is fired when the external string is GC'ed. 2827 // resource's callback is fired when the external string is GC'ed.
2828 FLAG_use_ic = false; // ICs retain objects.
2829 FLAG_parallel_recompilation = false;
2828 CcTest::InitializeVM(); 2830 CcTest::InitializeVM();
2829 v8::HandleScope scope(CcTest::isolate()); 2831 v8::HandleScope scope(CcTest::isolate());
2830 SourceResource* resource = new SourceResource(i::StrDup(source)); 2832 SourceResource* resource = new SourceResource(i::StrDup(source));
2831 { 2833 {
2832 v8::HandleScope scope(CcTest::isolate()); 2834 v8::HandleScope scope(CcTest::isolate());
2833 v8::Handle<v8::String> source_string = v8::String::NewExternal(resource); 2835 v8::Handle<v8::String> source_string = v8::String::NewExternal(resource);
2836 HEAP->CollectAllAvailableGarbage();
2834 v8::Script::Compile(source_string)->Run(); 2837 v8::Script::Compile(source_string)->Run();
2835 CHECK(!resource->IsDisposed()); 2838 CHECK(!resource->IsDisposed());
2836 } 2839 }
2840 // HEAP->CollectAllAvailableGarbage();
2841 CHECK(!resource->IsDisposed());
2842
2843 CompileRun(accessor);
2837 HEAP->CollectAllAvailableGarbage(); 2844 HEAP->CollectAllAvailableGarbage();
2838 2845
2839 // External source has been released. 2846 // External source has been released.
2840 CHECK(resource->IsDisposed()); 2847 CHECK(resource->IsDisposed());
2841 delete resource; 2848 delete resource;
2842 } 2849 }
2843 2850
2844 2851
2845 TEST(ReleaseStackTraceData) { 2852 TEST(ReleaseStackTraceData) {
2846 static const char* source1 = "var error = null; " 2853 static const char* source1 = "var error = null; "
2847 /* Normal Error */ "try { " 2854 /* Normal Error */ "try { "
2848 " throw new Error(); " 2855 " throw new Error(); "
2849 "} catch (e) { " 2856 "} catch (e) { "
2850 " error = e; " 2857 " error = e; "
2851 "} "; 2858 "} ";
2852 static const char* source2 = "var error = null; " 2859 static const char* source2 = "var error = null; "
2853 /* Stack overflow */ "try { " 2860 /* Stack overflow */ "try { "
2854 " (function f() { f(); })(); " 2861 " (function f() { f(); })(); "
2855 "} catch (e) { " 2862 "} catch (e) { "
2856 " error = e; " 2863 " error = e; "
2857 "} "; 2864 "} ";
2858 ReleaseStackTraceDataTest(source1); 2865 static const char* source3 = "var error = null; "
2859 ReleaseStackTraceDataTest(source2); 2866 /* Normal Error */ "try { "
2867 /* as prototype */ " throw new Error(); "
2868 "} catch (e) { "
2869 " error = {}; "
2870 " error.__proto__ = e; "
2871 "} ";
2872 static const char* source4 = "var error = null; "
2873 /* Stack overflow */ "try { "
2874 /* as prototype */ " (function f() { f(); })(); "
2875 "} catch (e) { "
2876 " error = {}; "
2877 " error.__proto__ = e; "
2878 "} ";
2879 static const char* getter = "error.stack";
2880 static const char* setter = "error.stack = 0";
2881
2882 ReleaseStackTraceDataTest(source1, setter);
2883 ReleaseStackTraceDataTest(source2, setter);
2884 // We do not test source3 and source4 with setter, since the setter is
2885 // supposed to (untypically) write to the receiver, not the holder. This is
2886 // to emulate the behavior of a data property.
2887
2888 ReleaseStackTraceDataTest(source1, getter);
2889 ReleaseStackTraceDataTest(source2, getter);
2890 ReleaseStackTraceDataTest(source3, getter);
2891 ReleaseStackTraceDataTest(source4, getter);
2860 } 2892 }
2861 2893
2862 2894
2863 TEST(Regression144230) { 2895 TEST(Regression144230) {
2864 i::FLAG_stress_compaction = false; 2896 i::FLAG_stress_compaction = false;
2865 CcTest::InitializeVM(); 2897 CcTest::InitializeVM();
2866 Isolate* isolate = Isolate::Current(); 2898 Isolate* isolate = Isolate::Current();
2867 Heap* heap = isolate->heap(); 2899 Heap* heap = isolate->heap();
2868 HandleScope scope(isolate); 2900 HandleScope scope(isolate);
2869 2901
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
3348 " var a = new Array(n);" 3380 " var a = new Array(n);"
3349 " for (var i = 0; i < n; i += 100) a[i] = i;" 3381 " for (var i = 0; i < n; i += 100) a[i] = i;"
3350 "};" 3382 "};"
3351 "f(10 * 1024 * 1024);"); 3383 "f(10 * 1024 * 1024);");
3352 IncrementalMarking* marking = HEAP->incremental_marking(); 3384 IncrementalMarking* marking = HEAP->incremental_marking();
3353 if (marking->IsStopped()) marking->Start(); 3385 if (marking->IsStopped()) marking->Start();
3354 // This big step should be sufficient to mark the whole array. 3386 // This big step should be sufficient to mark the whole array.
3355 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); 3387 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
3356 ASSERT(marking->IsComplete()); 3388 ASSERT(marking->IsComplete());
3357 } 3389 }
OLDNEW
« no previous file with comments | « test/cctest/test-disasm-arm.cc ('k') | test/cctest/test-log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698