OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 | 2 |
3 // Redistribution and use in source and binary forms, with or without | 3 // Redistribution and use in source and binary forms, with or without |
4 // modification, are permitted provided that the following conditions are | 4 // modification, are permitted provided that the following conditions are |
5 // met: | 5 // met: |
6 // | 6 // |
7 // * Redistributions of source code must retain the above copyright | 7 // * Redistributions of source code must retain the above copyright |
8 // notice, this list of conditions and the following disclaimer. | 8 // notice, this list of conditions and the following disclaimer. |
9 // * Redistributions in binary form must reproduce the above | 9 // * Redistributions in binary form must reproduce the above |
10 // copyright notice, this list of conditions and the following | 10 // copyright notice, this list of conditions and the following |
(...skipping 14568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14579 { | 14579 { |
14580 v8::HandleScope scope; | 14580 v8::HandleScope scope; |
14581 | 14581 |
14582 context->Enter(); | 14582 context->Enter(); |
14583 Local<v8::String> obj = v8::String::New(""); | 14583 Local<v8::String> obj = v8::String::New(""); |
14584 context->SetData(obj); | 14584 context->SetData(obj); |
14585 CompileRun(source_simple); | 14585 CompileRun(source_simple); |
14586 context->Exit(); | 14586 context->Exit(); |
14587 } | 14587 } |
14588 context.Dispose(); | 14588 context.Dispose(); |
| 14589 v8::V8::ContextDisposedNotification(); |
14589 for (gc_count = 1; gc_count < 10; gc_count++) { | 14590 for (gc_count = 1; gc_count < 10; gc_count++) { |
14590 other_context->Enter(); | 14591 other_context->Enter(); |
14591 CompileRun(source_simple); | 14592 CompileRun(source_simple); |
14592 other_context->Exit(); | 14593 other_context->Exit(); |
14593 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 14594 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
14594 if (GetGlobalObjectsCount() == 1) break; | 14595 if (GetGlobalObjectsCount() == 1) break; |
14595 } | 14596 } |
14596 CHECK_GE(2, gc_count); | 14597 CHECK_GE(2, gc_count); |
14597 CHECK_EQ(1, GetGlobalObjectsCount()); | 14598 CHECK_EQ(1, GetGlobalObjectsCount()); |
14598 | 14599 |
14599 // Eval in a function creates reference from the compilation cache to the | 14600 // Eval in a function creates reference from the compilation cache to the |
14600 // global object. | 14601 // global object. |
14601 const char* source_eval = "function f(){eval('1')}; f()"; | 14602 const char* source_eval = "function f(){eval('1')}; f()"; |
14602 context = Context::New(); | 14603 context = Context::New(); |
14603 { | 14604 { |
14604 v8::HandleScope scope; | 14605 v8::HandleScope scope; |
14605 | 14606 |
14606 context->Enter(); | 14607 context->Enter(); |
14607 CompileRun(source_eval); | 14608 CompileRun(source_eval); |
14608 context->Exit(); | 14609 context->Exit(); |
14609 } | 14610 } |
14610 context.Dispose(); | 14611 context.Dispose(); |
| 14612 v8::V8::ContextDisposedNotification(); |
14611 for (gc_count = 1; gc_count < 10; gc_count++) { | 14613 for (gc_count = 1; gc_count < 10; gc_count++) { |
14612 other_context->Enter(); | 14614 other_context->Enter(); |
14613 CompileRun(source_eval); | 14615 CompileRun(source_eval); |
14614 other_context->Exit(); | 14616 other_context->Exit(); |
14615 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 14617 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
14616 if (GetGlobalObjectsCount() == 1) break; | 14618 if (GetGlobalObjectsCount() == 1) break; |
14617 } | 14619 } |
14618 CHECK_GE(2, gc_count); | 14620 CHECK_GE(2, gc_count); |
14619 CHECK_EQ(1, GetGlobalObjectsCount()); | 14621 CHECK_EQ(1, GetGlobalObjectsCount()); |
14620 | 14622 |
(...skipping 19 matching lines...) Expand all Loading... |
14640 other_context->Enter(); | 14642 other_context->Enter(); |
14641 CompileRun(source_exception); | 14643 CompileRun(source_exception); |
14642 other_context->Exit(); | 14644 other_context->Exit(); |
14643 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 14645 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
14644 if (GetGlobalObjectsCount() == 1) break; | 14646 if (GetGlobalObjectsCount() == 1) break; |
14645 } | 14647 } |
14646 CHECK_GE(2, gc_count); | 14648 CHECK_GE(2, gc_count); |
14647 CHECK_EQ(1, GetGlobalObjectsCount()); | 14649 CHECK_EQ(1, GetGlobalObjectsCount()); |
14648 | 14650 |
14649 other_context.Dispose(); | 14651 other_context.Dispose(); |
| 14652 v8::V8::ContextDisposedNotification(); |
14650 } | 14653 } |
14651 | 14654 |
14652 | 14655 |
14653 THREADED_TEST(ScriptOrigin) { | 14656 THREADED_TEST(ScriptOrigin) { |
14654 v8::HandleScope scope; | 14657 v8::HandleScope scope; |
14655 LocalContext env; | 14658 LocalContext env; |
14656 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); | 14659 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); |
14657 v8::Handle<v8::String> script = v8::String::New( | 14660 v8::Handle<v8::String> script = v8::String::New( |
14658 "function f() {}\n\nfunction g() {}"); | 14661 "function f() {}\n\nfunction g() {}"); |
14659 v8::Script::Compile(script, &origin)->Run(); | 14662 v8::Script::Compile(script, &origin)->Run(); |
(...skipping 2494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17154 v8::HandleScope scope; | 17157 v8::HandleScope scope; |
17155 LocalContext context; | 17158 LocalContext context; |
17156 | 17159 |
17157 // Compile a try-finally clause where the finally block causes a GC | 17160 // Compile a try-finally clause where the finally block causes a GC |
17158 // while there still is a message pending for external reporting. | 17161 // while there still is a message pending for external reporting. |
17159 TryCatch try_catch; | 17162 TryCatch try_catch; |
17160 try_catch.SetVerbose(true); | 17163 try_catch.SetVerbose(true); |
17161 CompileRun("try { throw new Error(); } finally { gc(); }"); | 17164 CompileRun("try { throw new Error(); } finally { gc(); }"); |
17162 CHECK(try_catch.HasCaught()); | 17165 CHECK(try_catch.HasCaught()); |
17163 } | 17166 } |
OLD | NEW |