| OLD | NEW | 
|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. | 
| 2 |  | 
| 3 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without | 
| 4 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are | 
| 5 // met: | 4 // met: | 
| 6 // | 5 // | 
| 7 //     * Redistributions of source code must retain the above copyright | 6 //     * Redistributions of source code must retain the above copyright | 
| 8 //       notice, this list of conditions and the following disclaimer. | 7 //       notice, this list of conditions and the following disclaimer. | 
| 9 //     * Redistributions in binary form must reproduce the above | 8 //     * Redistributions in binary form must reproduce the above | 
| 10 //       copyright notice, this list of conditions and the following | 9 //       copyright notice, this list of conditions and the following | 
| 11 //       disclaimer in the documentation and/or other materials provided | 10 //       disclaimer in the documentation and/or other materials provided | 
| 12 //       with the distribution. | 11 //       with the distribution. | 
| (...skipping 3722 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3735   for (int i = 0; i < 10; i++) { | 3734   for (int i = 0; i < 10; i++) { | 
| 3736     CHECK(xValue.IsEmpty()); | 3735     CHECK(xValue.IsEmpty()); | 
| 3737     script->Run(); | 3736     script->Run(); | 
| 3738     CHECK_EQ(v8_num(4), xValue); | 3737     CHECK_EQ(v8_num(4), xValue); | 
| 3739     xValue.Dispose(); | 3738     xValue.Dispose(); | 
| 3740     xValue = v8::Persistent<Value>(); | 3739     xValue = v8::Persistent<Value>(); | 
| 3741   } | 3740   } | 
| 3742 } | 3741 } | 
| 3743 | 3742 | 
| 3744 | 3743 | 
| 3745 THREADED_TEST(SetterOnly) { |  | 
| 3746   v8::HandleScope scope; |  | 
| 3747   Local<ObjectTemplate> templ = ObjectTemplate::New(); |  | 
| 3748   templ->SetAccessor(v8_str("x"), NULL, SetXValue, v8_str("donut")); |  | 
| 3749   LocalContext context; |  | 
| 3750   context->Global()->Set(v8_str("obj"), templ->NewInstance()); |  | 
| 3751   Local<Script> script = Script::Compile(v8_str("obj.x = 4; obj.x")); |  | 
| 3752   for (int i = 0; i < 10; i++) { |  | 
| 3753     CHECK(xValue.IsEmpty()); |  | 
| 3754     script->Run(); |  | 
| 3755     CHECK_EQ(v8_num(4), xValue); |  | 
| 3756     xValue.Dispose(); |  | 
| 3757     xValue = v8::Persistent<Value>(); |  | 
| 3758   } |  | 
| 3759 } |  | 
| 3760 |  | 
| 3761 |  | 
| 3762 THREADED_TEST(NoAccessors) { |  | 
| 3763   v8::HandleScope scope; |  | 
| 3764   Local<ObjectTemplate> templ = ObjectTemplate::New(); |  | 
| 3765   templ->SetAccessor(v8_str("x"), NULL, NULL, v8_str("donut")); |  | 
| 3766   LocalContext context; |  | 
| 3767   context->Global()->Set(v8_str("obj"), templ->NewInstance()); |  | 
| 3768   Local<Script> script = Script::Compile(v8_str("obj.x = 4; obj.x")); |  | 
| 3769   for (int i = 0; i < 10; i++) { |  | 
| 3770     script->Run(); |  | 
| 3771   } |  | 
| 3772 } |  | 
| 3773 |  | 
| 3774 |  | 
| 3775 static v8::Handle<Value> XPropertyGetter(Local<String> property, | 3744 static v8::Handle<Value> XPropertyGetter(Local<String> property, | 
| 3776                                          const AccessorInfo& info) { | 3745                                          const AccessorInfo& info) { | 
| 3777   ApiTestFuzzer::Fuzz(); | 3746   ApiTestFuzzer::Fuzz(); | 
| 3778   CHECK(info.Data()->IsUndefined()); | 3747   CHECK(info.Data()->IsUndefined()); | 
| 3779   return property; | 3748   return property; | 
| 3780 } | 3749 } | 
| 3781 | 3750 | 
| 3782 | 3751 | 
| 3783 THREADED_TEST(NamedInterceptorPropertyRead) { | 3752 THREADED_TEST(NamedInterceptorPropertyRead) { | 
| 3784   v8::HandleScope scope; | 3753   v8::HandleScope scope; | 
| (...skipping 7016 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 10801 | 10770 | 
| 10802 TEST(DontLeakGlobalObjects) { | 10771 TEST(DontLeakGlobalObjects) { | 
| 10803   // Regression test for issues 1139850 and 1174891. | 10772   // Regression test for issues 1139850 and 1174891. | 
| 10804 | 10773 | 
| 10805   v8::V8::Initialize(); | 10774   v8::V8::Initialize(); | 
| 10806 | 10775 | 
| 10807   for (int i = 0; i < 5; i++) { | 10776   for (int i = 0; i < 5; i++) { | 
| 10808     { v8::HandleScope scope; | 10777     { v8::HandleScope scope; | 
| 10809       LocalContext context; | 10778       LocalContext context; | 
| 10810     } | 10779     } | 
| 10811     // Fire context disposed notification to force clearing monomorphic ICs. |  | 
| 10812     v8::V8::ContextDisposedNotification(); |  | 
| 10813     CheckSurvivingGlobalObjectsCount(0); | 10780     CheckSurvivingGlobalObjectsCount(0); | 
| 10814 | 10781 | 
| 10815     { v8::HandleScope scope; | 10782     { v8::HandleScope scope; | 
| 10816       LocalContext context; | 10783       LocalContext context; | 
| 10817       v8_compile("Date")->Run(); | 10784       v8_compile("Date")->Run(); | 
| 10818     } | 10785     } | 
| 10819     // Fire context disposed notification to force clearing monomorphic ICs. |  | 
| 10820     v8::V8::ContextDisposedNotification(); |  | 
| 10821     CheckSurvivingGlobalObjectsCount(0); | 10786     CheckSurvivingGlobalObjectsCount(0); | 
| 10822 | 10787 | 
| 10823     { v8::HandleScope scope; | 10788     { v8::HandleScope scope; | 
| 10824       LocalContext context; | 10789       LocalContext context; | 
| 10825       v8_compile("/aaa/")->Run(); | 10790       v8_compile("/aaa/")->Run(); | 
| 10826     } | 10791     } | 
| 10827     // Fire context disposed notification to force clearing monomorphic ICs. |  | 
| 10828     v8::V8::ContextDisposedNotification(); |  | 
| 10829     CheckSurvivingGlobalObjectsCount(0); | 10792     CheckSurvivingGlobalObjectsCount(0); | 
| 10830 | 10793 | 
| 10831     { v8::HandleScope scope; | 10794     { v8::HandleScope scope; | 
| 10832       const char* extension_list[] = { "v8/gc" }; | 10795       const char* extension_list[] = { "v8/gc" }; | 
| 10833       v8::ExtensionConfiguration extensions(1, extension_list); | 10796       v8::ExtensionConfiguration extensions(1, extension_list); | 
| 10834       LocalContext context(&extensions); | 10797       LocalContext context(&extensions); | 
| 10835       v8_compile("gc();")->Run(); | 10798       v8_compile("gc();")->Run(); | 
| 10836     } | 10799     } | 
| 10837     // Fire context disposed notification to force clearing monomorphic ICs. |  | 
| 10838     v8::V8::ContextDisposedNotification(); |  | 
| 10839     CheckSurvivingGlobalObjectsCount(0); | 10800     CheckSurvivingGlobalObjectsCount(0); | 
| 10840   } | 10801   } | 
| 10841 } | 10802 } | 
| 10842 | 10803 | 
| 10843 | 10804 | 
| 10844 v8::Persistent<v8::Object> some_object; | 10805 v8::Persistent<v8::Object> some_object; | 
| 10845 v8::Persistent<v8::Object> bad_handle; | 10806 v8::Persistent<v8::Object> bad_handle; | 
| 10846 | 10807 | 
| 10847 void NewPersistentHandleCallback(v8::Persistent<v8::Value> handle, void*) { | 10808 void NewPersistentHandleCallback(v8::Persistent<v8::Value> handle, void*) { | 
| 10848   v8::HandleScope scope; | 10809   v8::HandleScope scope; | 
| (...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 12232     } | 12193     } | 
| 12233     two_byte_content_[14] = 'b'; | 12194     two_byte_content_[14] = 'b'; | 
| 12234 | 12195 | 
| 12235     // Create the input string for the regexp - the one we are going to change | 12196     // Create the input string for the regexp - the one we are going to change | 
| 12236     // properties of. | 12197     // properties of. | 
| 12237     input_ = FACTORY->NewExternalStringFromAscii(&ascii_resource_); | 12198     input_ = FACTORY->NewExternalStringFromAscii(&ascii_resource_); | 
| 12238 | 12199 | 
| 12239     // Inject the input as a global variable. | 12200     // Inject the input as a global variable. | 
| 12240     i::Handle<i::String> input_name = | 12201     i::Handle<i::String> input_name = | 
| 12241         FACTORY->NewStringFromAscii(i::Vector<const char>("input", 5)); | 12202         FACTORY->NewStringFromAscii(i::Vector<const char>("input", 5)); | 
| 12242     i::Isolate::Current()->native_context()->global_object()->SetProperty( | 12203     i::Isolate::Current()->global_context()->global()->SetProperty( | 
| 12243         *input_name, | 12204         *input_name, | 
| 12244         *input_, | 12205         *input_, | 
| 12245         NONE, | 12206         NONE, | 
| 12246         i::kNonStrictMode)->ToObjectChecked(); | 12207         i::kNonStrictMode)->ToObjectChecked(); | 
| 12247 | 12208 | 
| 12248     MorphThread morph_thread(this); | 12209     MorphThread morph_thread(this); | 
| 12249     morph_thread.Start(); | 12210     morph_thread.Start(); | 
| 12250     v8::Locker::StartPreemption(1); | 12211     v8::Locker::StartPreemption(1); | 
| 12251     LongRunningRegExp(); | 12212     LongRunningRegExp(); | 
| 12252     { | 12213     { | 
| (...skipping 2356 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 14609   { | 14570   { | 
| 14610     v8::HandleScope scope; | 14571     v8::HandleScope scope; | 
| 14611 | 14572 | 
| 14612     context->Enter(); | 14573     context->Enter(); | 
| 14613     Local<v8::String> obj = v8::String::New(""); | 14574     Local<v8::String> obj = v8::String::New(""); | 
| 14614     context->SetData(obj); | 14575     context->SetData(obj); | 
| 14615     CompileRun(source_simple); | 14576     CompileRun(source_simple); | 
| 14616     context->Exit(); | 14577     context->Exit(); | 
| 14617   } | 14578   } | 
| 14618   context.Dispose(); | 14579   context.Dispose(); | 
| 14619   v8::V8::ContextDisposedNotification(); |  | 
| 14620   for (gc_count = 1; gc_count < 10; gc_count++) { | 14580   for (gc_count = 1; gc_count < 10; gc_count++) { | 
| 14621     other_context->Enter(); | 14581     other_context->Enter(); | 
| 14622     CompileRun(source_simple); | 14582     CompileRun(source_simple); | 
| 14623     other_context->Exit(); | 14583     other_context->Exit(); | 
| 14624     HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 14584     HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 
| 14625     if (GetGlobalObjectsCount() == 1) break; | 14585     if (GetGlobalObjectsCount() == 1) break; | 
| 14626   } | 14586   } | 
| 14627   CHECK_GE(2, gc_count); | 14587   CHECK_GE(2, gc_count); | 
| 14628   CHECK_EQ(1, GetGlobalObjectsCount()); | 14588   CHECK_EQ(1, GetGlobalObjectsCount()); | 
| 14629 | 14589 | 
| 14630   // Eval in a function creates reference from the compilation cache to the | 14590   // Eval in a function creates reference from the compilation cache to the | 
| 14631   // global object. | 14591   // global object. | 
| 14632   const char* source_eval = "function f(){eval('1')}; f()"; | 14592   const char* source_eval = "function f(){eval('1')}; f()"; | 
| 14633   context = Context::New(); | 14593   context = Context::New(); | 
| 14634   { | 14594   { | 
| 14635     v8::HandleScope scope; | 14595     v8::HandleScope scope; | 
| 14636 | 14596 | 
| 14637     context->Enter(); | 14597     context->Enter(); | 
| 14638     CompileRun(source_eval); | 14598     CompileRun(source_eval); | 
| 14639     context->Exit(); | 14599     context->Exit(); | 
| 14640   } | 14600   } | 
| 14641   context.Dispose(); | 14601   context.Dispose(); | 
| 14642   v8::V8::ContextDisposedNotification(); |  | 
| 14643   for (gc_count = 1; gc_count < 10; gc_count++) { | 14602   for (gc_count = 1; gc_count < 10; gc_count++) { | 
| 14644     other_context->Enter(); | 14603     other_context->Enter(); | 
| 14645     CompileRun(source_eval); | 14604     CompileRun(source_eval); | 
| 14646     other_context->Exit(); | 14605     other_context->Exit(); | 
| 14647     HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 14606     HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 
| 14648     if (GetGlobalObjectsCount() == 1) break; | 14607     if (GetGlobalObjectsCount() == 1) break; | 
| 14649   } | 14608   } | 
| 14650   CHECK_GE(2, gc_count); | 14609   CHECK_GE(2, gc_count); | 
| 14651   CHECK_EQ(1, GetGlobalObjectsCount()); | 14610   CHECK_EQ(1, GetGlobalObjectsCount()); | 
| 14652 | 14611 | 
| 14653   // Looking up the line number for an exception creates reference from the | 14612   // Looking up the line number for an exception creates reference from the | 
| 14654   // compilation cache to the global object. | 14613   // compilation cache to the global object. | 
| 14655   const char* source_exception = "function f(){throw 1;} f()"; | 14614   const char* source_exception = "function f(){throw 1;} f()"; | 
| 14656   context = Context::New(); | 14615   context = Context::New(); | 
| 14657   { | 14616   { | 
| 14658     v8::HandleScope scope; | 14617     v8::HandleScope scope; | 
| 14659 | 14618 | 
| 14660     context->Enter(); | 14619     context->Enter(); | 
| 14661     v8::TryCatch try_catch; | 14620     v8::TryCatch try_catch; | 
| 14662     CompileRun(source_exception); | 14621     CompileRun(source_exception); | 
| 14663     CHECK(try_catch.HasCaught()); | 14622     CHECK(try_catch.HasCaught()); | 
| 14664     v8::Handle<v8::Message> message = try_catch.Message(); | 14623     v8::Handle<v8::Message> message = try_catch.Message(); | 
| 14665     CHECK(!message.IsEmpty()); | 14624     CHECK(!message.IsEmpty()); | 
| 14666     CHECK_EQ(1, message->GetLineNumber()); | 14625     CHECK_EQ(1, message->GetLineNumber()); | 
| 14667     context->Exit(); | 14626     context->Exit(); | 
| 14668   } | 14627   } | 
| 14669   context.Dispose(); | 14628   context.Dispose(); | 
| 14670   v8::V8::ContextDisposedNotification(); |  | 
| 14671   for (gc_count = 1; gc_count < 10; gc_count++) { | 14629   for (gc_count = 1; gc_count < 10; gc_count++) { | 
| 14672     other_context->Enter(); | 14630     other_context->Enter(); | 
| 14673     CompileRun(source_exception); | 14631     CompileRun(source_exception); | 
| 14674     other_context->Exit(); | 14632     other_context->Exit(); | 
| 14675     HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 14633     HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 
| 14676     if (GetGlobalObjectsCount() == 1) break; | 14634     if (GetGlobalObjectsCount() == 1) break; | 
| 14677   } | 14635   } | 
| 14678   CHECK_GE(2, gc_count); | 14636   CHECK_GE(2, gc_count); | 
| 14679   CHECK_EQ(1, GetGlobalObjectsCount()); | 14637   CHECK_EQ(1, GetGlobalObjectsCount()); | 
| 14680 | 14638 | 
| 14681   other_context.Dispose(); | 14639   other_context.Dispose(); | 
| 14682   v8::V8::ContextDisposedNotification(); |  | 
| 14683 } | 14640 } | 
| 14684 | 14641 | 
| 14685 | 14642 | 
| 14686 THREADED_TEST(ScriptOrigin) { | 14643 THREADED_TEST(ScriptOrigin) { | 
| 14687   v8::HandleScope scope; | 14644   v8::HandleScope scope; | 
| 14688   LocalContext env; | 14645   LocalContext env; | 
| 14689   v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); | 14646   v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); | 
| 14690   v8::Handle<v8::String> script = v8::String::New( | 14647   v8::Handle<v8::String> script = v8::String::New( | 
| 14691       "function f() {}\n\nfunction g() {}"); | 14648       "function f() {}\n\nfunction g() {}"); | 
| 14692   v8::Script::Compile(script, &origin)->Run(); | 14649   v8::Script::Compile(script, &origin)->Run(); | 
| (...skipping 2494 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 17187   v8::HandleScope scope; | 17144   v8::HandleScope scope; | 
| 17188   LocalContext context; | 17145   LocalContext context; | 
| 17189 | 17146 | 
| 17190   // Compile a try-finally clause where the finally block causes a GC | 17147   // Compile a try-finally clause where the finally block causes a GC | 
| 17191   // while there still is a message pending for external reporting. | 17148   // while there still is a message pending for external reporting. | 
| 17192   TryCatch try_catch; | 17149   TryCatch try_catch; | 
| 17193   try_catch.SetVerbose(true); | 17150   try_catch.SetVerbose(true); | 
| 17194   CompileRun("try { throw new Error(); } finally { gc(); }"); | 17151   CompileRun("try { throw new Error(); } finally { gc(); }"); | 
| 17195   CHECK(try_catch.HasCaught()); | 17152   CHECK(try_catch.HasCaught()); | 
| 17196 } | 17153 } | 
| OLD | NEW | 
|---|