| 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 18 matching lines...) Expand all Loading... |
| 29 #include <csignal> | 29 #include <csignal> |
| 30 #include <map> | 30 #include <map> |
| 31 #include <string> | 31 #include <string> |
| 32 | 32 |
| 33 #include "test/cctest/test-api.h" | 33 #include "test/cctest/test-api.h" |
| 34 | 34 |
| 35 #if V8_OS_POSIX | 35 #if V8_OS_POSIX |
| 36 #include <unistd.h> // NOLINT | 36 #include <unistd.h> // NOLINT |
| 37 #endif | 37 #endif |
| 38 | 38 |
| 39 #include "include/libplatform/libplatform.h" |
| 39 #include "include/v8-util.h" | 40 #include "include/v8-util.h" |
| 40 #include "src/api.h" | 41 #include "src/api.h" |
| 41 #include "src/arguments.h" | 42 #include "src/arguments.h" |
| 42 #include "src/base/platform/platform.h" | 43 #include "src/base/platform/platform.h" |
| 43 #include "src/compilation-cache.h" | 44 #include "src/compilation-cache.h" |
| 44 #include "src/debug.h" | 45 #include "src/debug.h" |
| 45 #include "src/execution.h" | 46 #include "src/execution.h" |
| 46 #include "src/objects.h" | 47 #include "src/objects.h" |
| 47 #include "src/parser.h" | 48 #include "src/parser.h" |
| 48 #include "src/smart-pointers.h" | 49 #include "src/smart-pointers.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 using ::v8::Value; | 82 using ::v8::Value; |
| 82 | 83 |
| 83 | 84 |
| 84 #define THREADED_PROFILED_TEST(Name) \ | 85 #define THREADED_PROFILED_TEST(Name) \ |
| 85 static void Test##Name(); \ | 86 static void Test##Name(); \ |
| 86 TEST(Name##WithProfiler) { \ | 87 TEST(Name##WithProfiler) { \ |
| 87 RunWithProfiler(&Test##Name); \ | 88 RunWithProfiler(&Test##Name); \ |
| 88 } \ | 89 } \ |
| 89 THREADED_TEST(Name) | 90 THREADED_TEST(Name) |
| 90 | 91 |
| 92 #define ENSURE_TASKS_HAVE_BEEN_RUN(isolate) \ |
| 93 while (v8::platform::PumpMessageLoop(v8::internal::V8::GetCurrentPlatform(), \ |
| 94 (isolate))) \ |
| 95 ; |
| 96 |
| 91 | 97 |
| 92 void RunWithProfiler(void (*test)()) { | 98 void RunWithProfiler(void (*test)()) { |
| 93 LocalContext env; | 99 LocalContext env; |
| 94 v8::HandleScope scope(env->GetIsolate()); | 100 v8::HandleScope scope(env->GetIsolate()); |
| 95 v8::Local<v8::String> profile_name = | 101 v8::Local<v8::String> profile_name = |
| 96 v8::String::NewFromUtf8(env->GetIsolate(), "my_profile1"); | 102 v8::String::NewFromUtf8(env->GetIsolate(), "my_profile1"); |
| 97 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); | 103 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); |
| 98 | 104 |
| 99 cpu_profiler->StartProfiling(profile_name); | 105 cpu_profiler->StartProfiling(profile_name); |
| 100 (*test)(); | 106 (*test)(); |
| (...skipping 3167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3268 TEST(TwoPassPhantomCallbacks) { | 3274 TEST(TwoPassPhantomCallbacks) { |
| 3269 auto isolate = CcTest::isolate(); | 3275 auto isolate = CcTest::isolate(); |
| 3270 const size_t kLength = 20; | 3276 const size_t kLength = 20; |
| 3271 int instance_counter = 0; | 3277 int instance_counter = 0; |
| 3272 for (size_t i = 0; i < kLength; ++i) { | 3278 for (size_t i = 0; i < kLength; ++i) { |
| 3273 auto data = new TwoPassCallbackData(isolate, &instance_counter); | 3279 auto data = new TwoPassCallbackData(isolate, &instance_counter); |
| 3274 data->SetWeak(); | 3280 data->SetWeak(); |
| 3275 } | 3281 } |
| 3276 CHECK_EQ(static_cast<int>(kLength), instance_counter); | 3282 CHECK_EQ(static_cast<int>(kLength), instance_counter); |
| 3277 CcTest::heap()->CollectAllGarbage(); | 3283 CcTest::heap()->CollectAllGarbage(); |
| 3284 ENSURE_TASKS_HAVE_BEEN_RUN(isolate); |
| 3278 CHECK_EQ(0, instance_counter); | 3285 CHECK_EQ(0, instance_counter); |
| 3279 } | 3286 } |
| 3280 | 3287 |
| 3281 | 3288 |
| 3282 TEST(TwoPassPhantomCallbacksNestedGc) { | 3289 TEST(TwoPassPhantomCallbacksNestedGc) { |
| 3283 auto isolate = CcTest::isolate(); | 3290 auto isolate = CcTest::isolate(); |
| 3284 const size_t kLength = 20; | 3291 const size_t kLength = 20; |
| 3285 TwoPassCallbackData* array[kLength]; | 3292 TwoPassCallbackData* array[kLength]; |
| 3286 int instance_counter = 0; | 3293 int instance_counter = 0; |
| 3287 for (size_t i = 0; i < kLength; ++i) { | 3294 for (size_t i = 0; i < kLength; ++i) { |
| 3288 array[i] = new TwoPassCallbackData(isolate, &instance_counter); | 3295 array[i] = new TwoPassCallbackData(isolate, &instance_counter); |
| 3289 array[i]->SetWeak(); | 3296 array[i]->SetWeak(); |
| 3290 } | 3297 } |
| 3291 array[5]->MarkTriggerGc(); | 3298 array[5]->MarkTriggerGc(); |
| 3292 array[10]->MarkTriggerGc(); | 3299 array[10]->MarkTriggerGc(); |
| 3293 array[15]->MarkTriggerGc(); | 3300 array[15]->MarkTriggerGc(); |
| 3294 CHECK_EQ(static_cast<int>(kLength), instance_counter); | 3301 CHECK_EQ(static_cast<int>(kLength), instance_counter); |
| 3295 CcTest::heap()->CollectAllGarbage(); | 3302 CcTest::heap()->CollectAllGarbage(); |
| 3303 ENSURE_TASKS_HAVE_BEEN_RUN(isolate); |
| 3296 CHECK_EQ(0, instance_counter); | 3304 CHECK_EQ(0, instance_counter); |
| 3297 } | 3305 } |
| 3298 | 3306 |
| 3299 | 3307 |
| 3300 namespace { | 3308 namespace { |
| 3301 | 3309 |
| 3302 void* IntKeyToVoidPointer(int key) { return reinterpret_cast<void*>(key << 1); } | 3310 void* IntKeyToVoidPointer(int key) { return reinterpret_cast<void*>(key << 1); } |
| 3303 | 3311 |
| 3304 | 3312 |
| 3305 Local<v8::Object> NewObjectForIntKey( | 3313 Local<v8::Object> NewObjectForIntKey( |
| (...skipping 3493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6799 FlagAndPersistent object; | 6807 FlagAndPersistent object; |
| 6800 { | 6808 { |
| 6801 v8::HandleScope handle_scope(isolate); | 6809 v8::HandleScope handle_scope(isolate); |
| 6802 object.handle.Reset(isolate, v8::Object::New(isolate)); | 6810 object.handle.Reset(isolate, v8::Object::New(isolate)); |
| 6803 } | 6811 } |
| 6804 object.flag = false; | 6812 object.flag = false; |
| 6805 object.handle.SetWeak(&object, gc_forcing_callback[inner_gc], | 6813 object.handle.SetWeak(&object, gc_forcing_callback[inner_gc], |
| 6806 v8::WeakCallbackType::kParameter); | 6814 v8::WeakCallbackType::kParameter); |
| 6807 object.handle.MarkIndependent(); | 6815 object.handle.MarkIndependent(); |
| 6808 invoke_gc[outer_gc](); | 6816 invoke_gc[outer_gc](); |
| 6817 ENSURE_TASKS_HAVE_BEEN_RUN(isolate); |
| 6809 CHECK(object.flag); | 6818 CHECK(object.flag); |
| 6810 } | 6819 } |
| 6811 } | 6820 } |
| 6812 } | 6821 } |
| 6813 | 6822 |
| 6814 | 6823 |
| 6815 v8::Handle<Function> args_fun; | 6824 v8::Handle<Function> args_fun; |
| 6816 | 6825 |
| 6817 | 6826 |
| 6818 static void ArgumentsTestCallback( | 6827 static void ArgumentsTestCallback( |
| (...skipping 14836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21655 CHECK(set->Has(env.local(), set).FromJust()); | 21664 CHECK(set->Has(env.local(), set).FromJust()); |
| 21656 | 21665 |
| 21657 CHECK(set->Delete(env.local(), set).FromJust()); | 21666 CHECK(set->Delete(env.local(), set).FromJust()); |
| 21658 CHECK_EQ(2U, set->Size()); | 21667 CHECK_EQ(2U, set->Size()); |
| 21659 CHECK(!set->Has(env.local(), set).FromJust()); | 21668 CHECK(!set->Has(env.local(), set).FromJust()); |
| 21660 CHECK(!set->Delete(env.local(), set).FromJust()); | 21669 CHECK(!set->Delete(env.local(), set).FromJust()); |
| 21661 | 21670 |
| 21662 set->Clear(); | 21671 set->Clear(); |
| 21663 CHECK_EQ(0U, set->Size()); | 21672 CHECK_EQ(0U, set->Size()); |
| 21664 } | 21673 } |
| OLD | NEW |