Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Side by Side Diff: test/cctest/test-threads.cc

Issue 12716010: Added a version of the v8::HandleScope constructor with an Isolate and use that consistently. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Feedback. Rebased Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-thread-termination.cc ('k') | test/cctest/test-weakmaps.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 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
29 29
30 #include "platform.h" 30 #include "platform.h"
31 #include "isolate.h" 31 #include "isolate.h"
32 32
33 #include "cctest.h" 33 #include "cctest.h"
34 34
35 35
36 TEST(Preemption) { 36 TEST(Preemption) {
37 v8::Locker locker(CcTest::default_isolate()); 37 v8::Locker locker(CcTest::default_isolate());
38 v8::V8::Initialize(); 38 v8::V8::Initialize();
39 v8::HandleScope scope; 39 v8::HandleScope scope(CcTest::default_isolate());
40 v8::Context::Scope context_scope(v8::Context::New()); 40 v8::Context::Scope context_scope(v8::Context::New());
41 41
42 v8::Locker::StartPreemption(100); 42 v8::Locker::StartPreemption(100);
43 43
44 v8::Handle<v8::Script> script = v8::Script::Compile( 44 v8::Handle<v8::Script> script = v8::Script::Compile(
45 v8::String::New("var count = 0; var obj = new Object(); count++;\n")); 45 v8::String::New("var count = 0; var obj = new Object(); count++;\n"));
46 46
47 script->Run(); 47 script->Run();
48 48
49 v8::Locker::StopPreemption(); 49 v8::Locker::StopPreemption();
(...skipping 11 matching lines...) Expand all
61 }; 61 };
62 62
63 static Turn turn = FILL_CACHE; 63 static Turn turn = FILL_CACHE;
64 64
65 65
66 class ThreadA : public v8::internal::Thread { 66 class ThreadA : public v8::internal::Thread {
67 public: 67 public:
68 ThreadA() : Thread("ThreadA") { } 68 ThreadA() : Thread("ThreadA") { }
69 void Run() { 69 void Run() {
70 v8::Locker locker(CcTest::default_isolate()); 70 v8::Locker locker(CcTest::default_isolate());
71 v8::HandleScope scope; 71 v8::HandleScope scope(CcTest::default_isolate());
72 v8::Context::Scope context_scope(v8::Context::New()); 72 v8::Context::Scope context_scope(v8::Context::New());
73 73
74 CHECK_EQ(FILL_CACHE, turn); 74 CHECK_EQ(FILL_CACHE, turn);
75 75
76 // Fill String.search cache. 76 // Fill String.search cache.
77 v8::Handle<v8::Script> script = v8::Script::Compile( 77 v8::Handle<v8::Script> script = v8::Script::Compile(
78 v8::String::New( 78 v8::String::New(
79 "for (var i = 0; i < 3; i++) {" 79 "for (var i = 0; i < 3; i++) {"
80 " var result = \"a\".search(\"a\");" 80 " var result = \"a\".search(\"a\");"
81 " if (result != 0) throw \"result: \" + result + \" @\" + i;" 81 " if (result != 0) throw \"result: \" + result + \" @\" + i;"
(...skipping 18 matching lines...) Expand all
100 100
101 101
102 class ThreadB : public v8::internal::Thread { 102 class ThreadB : public v8::internal::Thread {
103 public: 103 public:
104 ThreadB() : Thread("ThreadB") { } 104 ThreadB() : Thread("ThreadB") { }
105 void Run() { 105 void Run() {
106 do { 106 do {
107 { 107 {
108 v8::Locker locker(CcTest::default_isolate()); 108 v8::Locker locker(CcTest::default_isolate());
109 if (turn == CLEAN_CACHE) { 109 if (turn == CLEAN_CACHE) {
110 v8::HandleScope scope; 110 v8::HandleScope scope(CcTest::default_isolate());
111 v8::Context::Scope context_scope(v8::Context::New()); 111 v8::Context::Scope context_scope(v8::Context::New());
112 112
113 // Clear the caches by forcing major GC. 113 // Clear the caches by forcing major GC.
114 HEAP->CollectAllGarbage(v8::internal::Heap::kNoGCFlags); 114 HEAP->CollectAllGarbage(v8::internal::Heap::kNoGCFlags);
115 turn = SECOND_TIME_FILL_CACHE; 115 turn = SECOND_TIME_FILL_CACHE;
116 break; 116 break;
117 } 117 }
118 } 118 }
119 119
120 Thread::YieldCPU(); 120 Thread::YieldCPU();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 Join(); 199 Join();
200 } 200 }
201 }; 201 };
202 202
203 203
204 TEST(ThreadJoinSelf) { 204 TEST(ThreadJoinSelf) {
205 ThreadC thread; 205 ThreadC thread;
206 thread.Start(); 206 thread.Start();
207 thread.Join(); 207 thread.Join();
208 } 208 }
OLDNEW
« no previous file with comments | « test/cctest/test-thread-termination.cc ('k') | test/cctest/test-weakmaps.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698