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 2802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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. |
2828 CcTest::InitializeVM(); | 2829 CcTest::InitializeVM(); |
2829 v8::HandleScope scope(CcTest::isolate()); | 2830 v8::HandleScope scope(CcTest::isolate()); |
2830 SourceResource* resource = new SourceResource(i::StrDup(source)); | 2831 SourceResource* resource = new SourceResource(i::StrDup(source)); |
2831 { | 2832 { |
2832 v8::HandleScope scope(CcTest::isolate()); | 2833 v8::HandleScope scope(CcTest::isolate()); |
2833 v8::Handle<v8::String> source_string = v8::String::NewExternal(resource); | 2834 v8::Handle<v8::String> source_string = v8::String::NewExternal(resource); |
| 2835 HEAP->CollectAllAvailableGarbage(); |
2834 v8::Script::Compile(source_string)->Run(); | 2836 v8::Script::Compile(source_string)->Run(); |
2835 CHECK(!resource->IsDisposed()); | 2837 CHECK(!resource->IsDisposed()); |
2836 } | 2838 } |
| 2839 // HEAP->CollectAllAvailableGarbage(); |
| 2840 CHECK(!resource->IsDisposed()); |
| 2841 |
| 2842 CompileRun(accessor); |
2837 HEAP->CollectAllAvailableGarbage(); | 2843 HEAP->CollectAllAvailableGarbage(); |
2838 | 2844 |
2839 // External source has been released. | 2845 // External source has been released. |
2840 CHECK(resource->IsDisposed()); | 2846 CHECK(resource->IsDisposed()); |
2841 delete resource; | 2847 delete resource; |
2842 } | 2848 } |
2843 | 2849 |
2844 | 2850 |
2845 TEST(ReleaseStackTraceData) { | 2851 TEST(ReleaseStackTraceData) { |
2846 static const char* source1 = "var error = null; " | 2852 static const char* source1 = "var error = null; " |
2847 /* Normal Error */ "try { " | 2853 /* Normal Error */ "try { " |
2848 " throw new Error(); " | 2854 " throw new Error(); " |
2849 "} catch (e) { " | 2855 "} catch (e) { " |
2850 " error = e; " | 2856 " error = e; " |
2851 "} "; | 2857 "} "; |
2852 static const char* source2 = "var error = null; " | 2858 static const char* source2 = "var error = null; " |
2853 /* Stack overflow */ "try { " | 2859 /* Stack overflow */ "try { " |
2854 " (function f() { f(); })(); " | 2860 " (function f() { f(); })(); " |
2855 "} catch (e) { " | 2861 "} catch (e) { " |
2856 " error = e; " | 2862 " error = e; " |
2857 "} "; | 2863 "} "; |
2858 ReleaseStackTraceDataTest(source1); | 2864 static const char* source3 = "var error = null; " |
2859 ReleaseStackTraceDataTest(source2); | 2865 /* Normal Error */ "try { " |
| 2866 /* as prototype */ " throw new Error(); " |
| 2867 "} catch (e) { " |
| 2868 " error = {}; " |
| 2869 " error.__proto__ = e; " |
| 2870 "} "; |
| 2871 static const char* source4 = "var error = null; " |
| 2872 /* Stack overflow */ "try { " |
| 2873 /* as prototype */ " (function f() { f(); })(); " |
| 2874 "} catch (e) { " |
| 2875 " error = {}; " |
| 2876 " error.__proto__ = e; " |
| 2877 "} "; |
| 2878 static const char* getter = "error.stack"; |
| 2879 static const char* setter = "error.stack = 0"; |
| 2880 |
| 2881 ReleaseStackTraceDataTest(source1, setter); |
| 2882 ReleaseStackTraceDataTest(source2, setter); |
| 2883 // We do not test source3 and source4 with setter, since the setter is |
| 2884 // supposed to (untypically) write to the receiver, not the holder. This is |
| 2885 // to emulate the behavior of a data property. |
| 2886 |
| 2887 ReleaseStackTraceDataTest(source1, getter); |
| 2888 ReleaseStackTraceDataTest(source2, getter); |
| 2889 ReleaseStackTraceDataTest(source3, getter); |
| 2890 ReleaseStackTraceDataTest(source4, getter); |
2860 } | 2891 } |
2861 | 2892 |
2862 | 2893 |
2863 TEST(Regression144230) { | 2894 TEST(Regression144230) { |
2864 i::FLAG_stress_compaction = false; | 2895 i::FLAG_stress_compaction = false; |
2865 CcTest::InitializeVM(); | 2896 CcTest::InitializeVM(); |
2866 Isolate* isolate = Isolate::Current(); | 2897 Isolate* isolate = Isolate::Current(); |
2867 Heap* heap = isolate->heap(); | 2898 Heap* heap = isolate->heap(); |
2868 HandleScope scope(isolate); | 2899 HandleScope scope(isolate); |
2869 | 2900 |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3348 " var a = new Array(n);" | 3379 " var a = new Array(n);" |
3349 " for (var i = 0; i < n; i += 100) a[i] = i;" | 3380 " for (var i = 0; i < n; i += 100) a[i] = i;" |
3350 "};" | 3381 "};" |
3351 "f(10 * 1024 * 1024);"); | 3382 "f(10 * 1024 * 1024);"); |
3352 IncrementalMarking* marking = HEAP->incremental_marking(); | 3383 IncrementalMarking* marking = HEAP->incremental_marking(); |
3353 if (marking->IsStopped()) marking->Start(); | 3384 if (marking->IsStopped()) marking->Start(); |
3354 // This big step should be sufficient to mark the whole array. | 3385 // This big step should be sufficient to mark the whole array. |
3355 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); | 3386 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); |
3356 ASSERT(marking->IsComplete()); | 3387 ASSERT(marking->IsComplete()); |
3357 } | 3388 } |
OLD | NEW |