43 using ::v8::AccessorInfo;
45 using ::v8::Extension;
47 using ::v8::HandleScope;
50 using ::v8::ObjectTemplate;
51 using ::v8::Persistent;
63 :
Thread(
"KangarooThread"),
64 isolate_(isolate), context_(context), value_(value) {
71 CHECK_EQ(isolate_, v8::internal::Isolate::Current());
74 Local<Value> v = CompileRun(
"getValue()");
76 CHECK_EQ(30, static_cast<int>(v->NumberValue()));
83 Local<Value> v = CompileRun(
"getValue()");
85 CHECK_EQ(30, static_cast<int>(v->NumberValue()));
92 Persistent<v8::Context> context_;
99 Persistent<v8::Context> context;
106 CHECK_EQ(isolate, v8::internal::Isolate::Current());
107 CompileRun(
"function getValue() { return 30; }");
114 static void CalcFibAndCheck() {
115 Local<Value> v = CompileRun(
"function fib(n) {"
116 " if (n <= 2) return 1;"
117 " return fib(n-1) + fib(n-2);"
120 CHECK(v->IsNumber());
121 CHECK_EQ(55, static_cast<int>(v->NumberValue()));
128 semaphore_(i::OS::CreateSemaphore(0)),
144 virtual void Run() = 0;
150 : Thread(joinable_thread->name_),
151 joinable_thread_(joinable_thread) {
155 joinable_thread_->Run();
156 joinable_thread_->semaphore_->Signal();
185 CHECK_EQ(isolate_, v8::internal::Isolate::Current());
193 for (
int i = 0; i < threads.length(); i++) {
196 for (
int i = 0; i < threads.length(); i++) {
199 for (
int i = 0; i < threads.length(); i++) {
207 #ifdef V8_TARGET_ARCH_MIPS
208 const int kNThreads = 50;
210 const int kNThreads = 100;
214 for (
int i = 0; i < kNThreads; i++) {
217 StartJoinAndDeleteThreads(threads);
234 CHECK_EQ(isolate, v8::internal::Isolate::Current());
243 TEST(MultithreadedParallelIsolates) {
244 #if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS)
245 const int kNThreads = 10;
247 const int kNThreads = 50;
250 for (
int i = 0; i < kNThreads; i++) {
253 StartJoinAndDeleteThreads(threads);
282 #ifdef V8_TARGET_ARCH_MIPS
283 const int kNThreads = 50;
285 const int kNThreads = 100;
289 for (
int i = 0; i < kNThreads; i++) {
292 StartJoinAndDeleteThreads(threads);
301 isolate1_(isolate1), isolate2_(isolate2) {
321 TEST(SeparateIsolatesLocksNonexclusive) {
322 #if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS)
323 const int kNThreads = 50;
325 const int kNThreads = 100;
330 for (
int i = 0; i < kNThreads; i++) {
334 StartJoinAndDeleteThreads(threads);
351 HandleScope handle_scope;
357 Persistent<v8::Context> context_;
396 #if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS)
397 const int kNThreads = 50;
399 const int kNThreads = 100;
403 for (
int i = 0; i < kNThreads; i++) {
406 StartJoinAndDeleteThreads(threads);
449 #if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS)
450 const int kNThreads = 50;
452 const int kNThreads = 100;
456 for (
int i = 0; i < kNThreads; i++) {
459 StartJoinAndDeleteThreads(threads);
469 isolate2_(isolate2) {
473 Persistent<v8::Context> context1;
474 Persistent<v8::Context> context2;
519 TEST(LockAndUnlockDifferentIsolates) {
569 TEST(LockUnlockLockMultithreaded) {
570 #ifdef V8_TARGET_ARCH_MIPS
571 const int kNThreads = 50;
573 const int kNThreads = 100;
576 Persistent<v8::Context> context;
584 for (
int i = 0; i < kNThreads; i++) {
587 StartJoinAndDeleteThreads(threads);
620 TEST(LockUnlockLockDefaultIsolateMultithreaded) {
621 #ifdef V8_TARGET_ARCH_MIPS
622 const int kNThreads = 50;
624 const int kNThreads = 100;
626 Persistent<v8::Context> context;
633 for (
int i = 0; i < kNThreads; i++) {
636 StartJoinAndDeleteThreads(threads);
641 for (
int i = 0; i < 10; i++) {
660 static const char* kSimpleExtensionSource =
670 extension_names_(extension_names)
677 CHECK(!i::Isolate::Current()->has_installed_extensions());
680 CHECK(i::Isolate::Current()->has_installed_extensions());
687 const char** extension_names_;
693 #if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS)
694 const int kNThreads = 10;
696 const int kNThreads = 40;
699 kSimpleExtensionSource));
701 kSimpleExtensionSource));
703 kSimpleExtensionSource));
705 kSimpleExtensionSource));
707 kSimpleExtensionSource));
709 kSimpleExtensionSource));
711 kSimpleExtensionSource));
713 kSimpleExtensionSource));
714 const char* extension_names[] = {
"test0",
"test1",
715 "test2",
"test3",
"test4",
716 "test5",
"test6",
"test7" };
718 for (
int i = 0; i < kNThreads; i++) {
721 StartJoinAndDeleteThreads(threads);
static Local< Script > Compile(Handle< String > source, ScriptOrigin *origin=NULL, ScriptData *pre_data=NULL, Handle< String > script_data=Handle< String >())
#define CHECK_EQ(expected, value)
Thread(const Options &options)
LockIsolateAndCalculateFibSharedContextThread(v8::Isolate *isolate, v8::Handle< v8::Context > context)
void V8EXPORT RegisterExtension(Extension *extension)
static V8EXPORT Local< String > New(const char *data, int length=-1)
IsolateNestedLockingThread(v8::Isolate *isolate)
virtual ~JoinableThread()
LockAndUnlockDifferentIsolatesThread(v8::Isolate *isolate1, v8::Isolate *isolate2)
IsolateLockingThreadWithLocalContext(v8::Isolate *isolate)
LockerUnlockerThread(v8::Isolate *isolate)
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
friend class ThreadWithSemaphore
KangarooThread(v8::Isolate *isolate, v8::Handle< v8::Context > context, int value)
LockUnlockLockDefaultIsolateThread(v8::Handle< v8::Context > context)
IsolateNonlockingThread()
SeparateIsolatesLocksNonexclusiveThread(v8::Isolate *isolate1, v8::Isolate *isolate2)
JoinableThread(const char *name)
LockTwiceAndUnlockThread(v8::Isolate *isolate)
LockUnlockLockThread(v8::Isolate *isolate, v8::Handle< v8::Context > context)
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
static Persistent< Context > New(ExtensionConfiguration *extensions=NULL, Handle< ObjectTemplate > global_template=Handle< ObjectTemplate >(), Handle< Value > global_object=Handle< Value >())
IsolateGenesisThread(int count, const char *extension_names[])
static bool IsLocked(Isolate *isolate=NULL)