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 2945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2956 const char* data_; | 2956 const char* data_; |
2957 size_t length_; | 2957 size_t length_; |
2958 }; | 2958 }; |
2959 | 2959 |
2960 | 2960 |
2961 void ReleaseStackTraceDataTest(const char* source, const char* accessor) { | 2961 void ReleaseStackTraceDataTest(const char* source, const char* accessor) { |
2962 // Test that the data retained by the Error.stack accessor is released | 2962 // Test that the data retained by the Error.stack accessor is released |
2963 // after the first time the accessor is fired. We use external string | 2963 // after the first time the accessor is fired. We use external string |
2964 // to check whether the data is being released since the external string | 2964 // to check whether the data is being released since the external string |
2965 // resource's callback is fired when the external string is GC'ed. | 2965 // resource's callback is fired when the external string is GC'ed. |
2966 FLAG_use_ic = false; // ICs retain objects. | |
2967 FLAG_concurrent_recompilation = false; | |
2968 v8::HandleScope scope(CcTest::isolate()); | 2966 v8::HandleScope scope(CcTest::isolate()); |
2969 SourceResource* resource = new SourceResource(i::StrDup(source)); | 2967 SourceResource* resource = new SourceResource(i::StrDup(source)); |
2970 { | 2968 { |
2971 v8::HandleScope scope(CcTest::isolate()); | 2969 v8::HandleScope scope(CcTest::isolate()); |
2972 v8::Handle<v8::String> source_string = v8::String::NewExternal(resource); | 2970 v8::Handle<v8::String> source_string = v8::String::NewExternal(resource); |
2973 CcTest::heap()->CollectAllAvailableGarbage(); | 2971 CcTest::heap()->CollectAllAvailableGarbage(); |
2974 v8::Script::Compile(source_string)->Run(); | 2972 v8::Script::Compile(source_string)->Run(); |
2975 CHECK(!resource->IsDisposed()); | 2973 CHECK(!resource->IsDisposed()); |
2976 } | 2974 } |
2977 // CcTest::heap()->CollectAllAvailableGarbage(); | 2975 // CcTest::heap()->CollectAllAvailableGarbage(); |
2978 CHECK(!resource->IsDisposed()); | 2976 CHECK(!resource->IsDisposed()); |
2979 | 2977 |
2980 CompileRun(accessor); | 2978 CompileRun(accessor); |
2981 CcTest::heap()->CollectAllAvailableGarbage(); | 2979 CcTest::heap()->CollectAllAvailableGarbage(); |
2982 | 2980 |
2983 // External source has been released. | 2981 // External source has been released. |
2984 CHECK(resource->IsDisposed()); | 2982 CHECK(resource->IsDisposed()); |
2985 delete resource; | 2983 delete resource; |
2986 } | 2984 } |
2987 | 2985 |
2988 | 2986 |
2989 TEST(ReleaseStackTraceData) { | 2987 TEST(ReleaseStackTraceData) { |
| 2988 FLAG_use_ic = false; // ICs retain objects. |
| 2989 FLAG_concurrent_recompilation = false; |
2990 CcTest::InitializeVM(); | 2990 CcTest::InitializeVM(); |
2991 static const char* source1 = "var error = null; " | 2991 static const char* source1 = "var error = null; " |
2992 /* Normal Error */ "try { " | 2992 /* Normal Error */ "try { " |
2993 " throw new Error(); " | 2993 " throw new Error(); " |
2994 "} catch (e) { " | 2994 "} catch (e) { " |
2995 " error = e; " | 2995 " error = e; " |
2996 "} "; | 2996 "} "; |
2997 static const char* source2 = "var error = null; " | 2997 static const char* source2 = "var error = null; " |
2998 /* Stack overflow */ "try { " | 2998 /* Stack overflow */ "try { " |
2999 " (function f() { f(); })(); " | 2999 " (function f() { f(); })(); " |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3542 CompileRun("run()"); | 3542 CompileRun("run()"); |
3543 | 3543 |
3544 // Run test with inline allocation disabled and pretenuring. | 3544 // Run test with inline allocation disabled and pretenuring. |
3545 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); | 3545 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); |
3546 CompileRun("run()"); | 3546 CompileRun("run()"); |
3547 | 3547 |
3548 // Run test with inline allocation re-enabled. | 3548 // Run test with inline allocation re-enabled. |
3549 CcTest::heap()->EnableInlineAllocation(); | 3549 CcTest::heap()->EnableInlineAllocation(); |
3550 CompileRun("run()"); | 3550 CompileRun("run()"); |
3551 } | 3551 } |
OLD | NEW |