Chromium Code Reviews| 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 11673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11684 // Regression test for issues 1139850 and 1174891. | 11684 // Regression test for issues 1139850 and 1174891. |
| 11685 | 11685 |
| 11686 i::FLAG_expose_gc = true; | 11686 i::FLAG_expose_gc = true; |
| 11687 v8::V8::Initialize(); | 11687 v8::V8::Initialize(); |
| 11688 | 11688 |
| 11689 for (int i = 0; i < 5; i++) { | 11689 for (int i = 0; i < 5; i++) { |
| 11690 { v8::HandleScope scope(CcTest::isolate()); | 11690 { v8::HandleScope scope(CcTest::isolate()); |
| 11691 LocalContext context; | 11691 LocalContext context; |
| 11692 } | 11692 } |
| 11693 CcTest::isolate()->ContextDisposedNotification(); | 11693 CcTest::isolate()->ContextDisposedNotification(); |
| 11694 CheckSurvivingGlobalObjectsCount(0); | 11694 CheckSurvivingGlobalObjectsCount(1); |
|
Michael Starzinger
2015/07/10 13:26:30
Can we move this off-by-one into the GetGlobalObje
danno
2015/07/13 09:43:37
Done
| |
| 11695 | 11695 |
| 11696 { v8::HandleScope scope(CcTest::isolate()); | 11696 { v8::HandleScope scope(CcTest::isolate()); |
| 11697 LocalContext context; | 11697 LocalContext context; |
| 11698 v8_compile("Date")->Run(); | 11698 v8_compile("Date")->Run(); |
| 11699 } | 11699 } |
| 11700 CcTest::isolate()->ContextDisposedNotification(); | 11700 CcTest::isolate()->ContextDisposedNotification(); |
| 11701 CheckSurvivingGlobalObjectsCount(0); | 11701 CheckSurvivingGlobalObjectsCount(1); |
| 11702 | 11702 |
| 11703 { v8::HandleScope scope(CcTest::isolate()); | 11703 { v8::HandleScope scope(CcTest::isolate()); |
| 11704 LocalContext context; | 11704 LocalContext context; |
| 11705 v8_compile("/aaa/")->Run(); | 11705 v8_compile("/aaa/")->Run(); |
| 11706 } | 11706 } |
| 11707 CcTest::isolate()->ContextDisposedNotification(); | 11707 CcTest::isolate()->ContextDisposedNotification(); |
| 11708 CheckSurvivingGlobalObjectsCount(0); | 11708 CheckSurvivingGlobalObjectsCount(1); |
| 11709 | 11709 |
| 11710 { v8::HandleScope scope(CcTest::isolate()); | 11710 { v8::HandleScope scope(CcTest::isolate()); |
| 11711 const char* extension_list[] = { "v8/gc" }; | 11711 const char* extension_list[] = { "v8/gc" }; |
| 11712 v8::ExtensionConfiguration extensions(1, extension_list); | 11712 v8::ExtensionConfiguration extensions(1, extension_list); |
| 11713 LocalContext context(&extensions); | 11713 LocalContext context(&extensions); |
| 11714 v8_compile("gc();")->Run(); | 11714 v8_compile("gc();")->Run(); |
| 11715 } | 11715 } |
| 11716 CcTest::isolate()->ContextDisposedNotification(); | 11716 CcTest::isolate()->ContextDisposedNotification(); |
| 11717 CheckSurvivingGlobalObjectsCount(0); | 11717 CheckSurvivingGlobalObjectsCount(1); |
| 11718 } | 11718 } |
| 11719 } | 11719 } |
| 11720 | 11720 |
| 11721 | 11721 |
| 11722 TEST(CopyablePersistent) { | 11722 TEST(CopyablePersistent) { |
| 11723 LocalContext context; | 11723 LocalContext context; |
| 11724 v8::Isolate* isolate = context->GetIsolate(); | 11724 v8::Isolate* isolate = context->GetIsolate(); |
| 11725 i::GlobalHandles* globals = | 11725 i::GlobalHandles* globals = |
| 11726 reinterpret_cast<i::Isolate*>(isolate)->global_handles(); | 11726 reinterpret_cast<i::Isolate*>(isolate)->global_handles(); |
| 11727 int initial_handles = globals->global_handles_count(); | 11727 int initial_handles = globals->global_handles_count(); |
| (...skipping 4128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 15856 context->SetEmbedderData(0, obj); | 15856 context->SetEmbedderData(0, obj); |
| 15857 CompileRun(source_simple); | 15857 CompileRun(source_simple); |
| 15858 context->Exit(); | 15858 context->Exit(); |
| 15859 } | 15859 } |
| 15860 isolate->ContextDisposedNotification(); | 15860 isolate->ContextDisposedNotification(); |
| 15861 for (gc_count = 1; gc_count < 10; gc_count++) { | 15861 for (gc_count = 1; gc_count < 10; gc_count++) { |
| 15862 other_context->Enter(); | 15862 other_context->Enter(); |
| 15863 CompileRun(source_simple); | 15863 CompileRun(source_simple); |
| 15864 other_context->Exit(); | 15864 other_context->Exit(); |
| 15865 CcTest::heap()->CollectAllGarbage(); | 15865 CcTest::heap()->CollectAllGarbage(); |
| 15866 if (GetGlobalObjectsCount() == 1) break; | 15866 if (GetGlobalObjectsCount() == 2) break; |
| 15867 } | 15867 } |
| 15868 CHECK_GE(2, gc_count); | 15868 CHECK_GE(2, gc_count); |
| 15869 CHECK_EQ(1, GetGlobalObjectsCount()); | 15869 CHECK_EQ(2, GetGlobalObjectsCount()); |
| 15870 | 15870 |
| 15871 // Eval in a function creates reference from the compilation cache to the | 15871 // Eval in a function creates reference from the compilation cache to the |
| 15872 // global object. | 15872 // global object. |
| 15873 const char* source_eval = "function f(){eval('1')}; f()"; | 15873 const char* source_eval = "function f(){eval('1')}; f()"; |
| 15874 { | 15874 { |
| 15875 v8::HandleScope scope(isolate); | 15875 v8::HandleScope scope(isolate); |
| 15876 v8::Local<Context> context = Context::New(isolate); | 15876 v8::Local<Context> context = Context::New(isolate); |
| 15877 | 15877 |
| 15878 context->Enter(); | 15878 context->Enter(); |
| 15879 CompileRun(source_eval); | 15879 CompileRun(source_eval); |
| 15880 context->Exit(); | 15880 context->Exit(); |
| 15881 } | 15881 } |
| 15882 isolate->ContextDisposedNotification(); | 15882 isolate->ContextDisposedNotification(); |
| 15883 for (gc_count = 1; gc_count < 10; gc_count++) { | 15883 for (gc_count = 1; gc_count < 10; gc_count++) { |
| 15884 other_context->Enter(); | 15884 other_context->Enter(); |
| 15885 CompileRun(source_eval); | 15885 CompileRun(source_eval); |
| 15886 other_context->Exit(); | 15886 other_context->Exit(); |
| 15887 CcTest::heap()->CollectAllGarbage(); | 15887 CcTest::heap()->CollectAllGarbage(); |
| 15888 if (GetGlobalObjectsCount() == 1) break; | 15888 printf("D: %d\n", GetGlobalObjectsCount()); |
| 15889 if (GetGlobalObjectsCount() == 2) break; | |
| 15889 } | 15890 } |
| 15890 CHECK_GE(2, gc_count); | 15891 CHECK_GE(2, gc_count); |
| 15891 CHECK_EQ(1, GetGlobalObjectsCount()); | 15892 CHECK_EQ(2, GetGlobalObjectsCount()); |
| 15892 | 15893 |
| 15893 // Looking up the line number for an exception creates reference from the | 15894 // Looking up the line number for an exception creates reference from the |
| 15894 // compilation cache to the global object. | 15895 // compilation cache to the global object. |
| 15895 const char* source_exception = "function f(){throw 1;} f()"; | 15896 const char* source_exception = "function f(){throw 1;} f()"; |
| 15896 { | 15897 { |
| 15897 v8::HandleScope scope(isolate); | 15898 v8::HandleScope scope(isolate); |
| 15898 v8::Local<Context> context = Context::New(isolate); | 15899 v8::Local<Context> context = Context::New(isolate); |
| 15899 | 15900 |
| 15900 context->Enter(); | 15901 context->Enter(); |
| 15901 v8::TryCatch try_catch(isolate); | 15902 v8::TryCatch try_catch(isolate); |
| 15902 CompileRun(source_exception); | 15903 CompileRun(source_exception); |
| 15903 CHECK(try_catch.HasCaught()); | 15904 CHECK(try_catch.HasCaught()); |
| 15904 v8::Handle<v8::Message> message = try_catch.Message(); | 15905 v8::Handle<v8::Message> message = try_catch.Message(); |
| 15905 CHECK(!message.IsEmpty()); | 15906 CHECK(!message.IsEmpty()); |
| 15906 CHECK_EQ(1, message->GetLineNumber()); | 15907 CHECK_EQ(1, message->GetLineNumber()); |
| 15907 context->Exit(); | 15908 context->Exit(); |
| 15908 } | 15909 } |
| 15909 isolate->ContextDisposedNotification(); | 15910 isolate->ContextDisposedNotification(); |
| 15910 for (gc_count = 1; gc_count < 10; gc_count++) { | 15911 for (gc_count = 1; gc_count < 10; gc_count++) { |
| 15911 other_context->Enter(); | 15912 other_context->Enter(); |
| 15912 CompileRun(source_exception); | 15913 CompileRun(source_exception); |
| 15913 other_context->Exit(); | 15914 other_context->Exit(); |
| 15914 CcTest::heap()->CollectAllGarbage(); | 15915 CcTest::heap()->CollectAllGarbage(); |
| 15915 if (GetGlobalObjectsCount() == 1) break; | 15916 if (GetGlobalObjectsCount() == 2) break; |
| 15916 } | 15917 } |
| 15917 CHECK_GE(2, gc_count); | 15918 CHECK_GE(2, gc_count); |
| 15918 CHECK_EQ(1, GetGlobalObjectsCount()); | 15919 CHECK_EQ(2, GetGlobalObjectsCount()); |
| 15919 | 15920 |
| 15920 isolate->ContextDisposedNotification(); | 15921 isolate->ContextDisposedNotification(); |
| 15921 } | 15922 } |
| 15922 | 15923 |
| 15923 | 15924 |
| 15924 THREADED_TEST(ScriptOrigin) { | 15925 THREADED_TEST(ScriptOrigin) { |
| 15925 LocalContext env; | 15926 LocalContext env; |
| 15926 v8::HandleScope scope(env->GetIsolate()); | 15927 v8::HandleScope scope(env->GetIsolate()); |
| 15927 v8::ScriptOrigin origin = v8::ScriptOrigin( | 15928 v8::ScriptOrigin origin = v8::ScriptOrigin( |
| 15928 v8::String::NewFromUtf8(env->GetIsolate(), "test"), | 15929 v8::String::NewFromUtf8(env->GetIsolate(), "test"), |
| (...skipping 5919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 21848 " fake.age;\n" | 21849 " fake.age;\n" |
| 21849 " result = 1;\n" | 21850 " result = 1;\n" |
| 21850 " } catch (e) {\n" | 21851 " } catch (e) {\n" |
| 21851 " }\n" | 21852 " }\n" |
| 21852 " test(d+1);\n" | 21853 " test(d+1);\n" |
| 21853 "}\n" | 21854 "}\n" |
| 21854 "test(0);\n" | 21855 "test(0);\n" |
| 21855 "result;\n", | 21856 "result;\n", |
| 21856 0); | 21857 0); |
| 21857 } | 21858 } |
| OLD | NEW |