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

Side by Side Diff: src/d8.cc

Issue 302543004: Revert "Add a flag to d8 to invoke weak callbacks" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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 | « src/d8.h ('k') | tools/run-tests.py » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 // Defined when linking against shared lib on Windows. 6 // Defined when linking against shared lib on Windows.
7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) 7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED)
8 #define V8_SHARED 8 #define V8_SHARED
9 #endif 9 #endif
10 10
(...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 #ifndef V8_SHARED 1183 #ifndef V8_SHARED
1184 i::Thread::Options SourceGroup::GetThreadOptions() { 1184 i::Thread::Options SourceGroup::GetThreadOptions() {
1185 // On some systems (OSX 10.6) the stack size default is 0.5Mb or less 1185 // On some systems (OSX 10.6) the stack size default is 0.5Mb or less
1186 // which is not enough to parse the big literal expressions used in tests. 1186 // which is not enough to parse the big literal expressions used in tests.
1187 // The stack size should be at least StackGuard::kLimitSize + some 1187 // The stack size should be at least StackGuard::kLimitSize + some
1188 // OS-specific padding for thread startup code. 2Mbytes seems to be enough. 1188 // OS-specific padding for thread startup code. 2Mbytes seems to be enough.
1189 return i::Thread::Options("IsolateThread", 2 * MB); 1189 return i::Thread::Options("IsolateThread", 2 * MB);
1190 } 1190 }
1191 1191
1192 1192
1193 void SuggestivelyAskForAggressiveGC() {
1194 if (Shell::options.send_idle_notification) {
1195 const int kLongIdlePauseInMs = 1000;
1196 V8::ContextDisposedNotification();
1197 V8::IdleNotification(kLongIdlePauseInMs);
1198 }
1199 if (Shell::options.invoke_weak_callbacks) {
1200 // By sending a low memory notifications, we will try hard to collect
1201 // all garbage and will therefore also invoke all weak callbacks of
1202 // actually unreachable persistent handles.
1203 V8::LowMemoryNotification();
1204 }
1205 }
1206
1207
1208 void SourceGroup::ExecuteInThread() { 1193 void SourceGroup::ExecuteInThread() {
1209 Isolate* isolate = Isolate::New(); 1194 Isolate* isolate = Isolate::New();
1210 do { 1195 do {
1211 next_semaphore_.Wait(); 1196 next_semaphore_.Wait();
1212 { 1197 {
1213 Isolate::Scope iscope(isolate); 1198 Isolate::Scope iscope(isolate);
1214 { 1199 {
1215 HandleScope scope(isolate); 1200 HandleScope scope(isolate);
1216 PerIsolateData data(isolate); 1201 PerIsolateData data(isolate);
1217 Local<Context> context = Shell::CreateEvaluationContext(isolate); 1202 Local<Context> context = Shell::CreateEvaluationContext(isolate);
1218 { 1203 {
1219 Context::Scope cscope(context); 1204 Context::Scope cscope(context);
1220 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate)); 1205 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate));
1221 Execute(isolate); 1206 Execute(isolate);
1222 } 1207 }
1223 } 1208 }
1224 SuggestivelyAskForAggressiveGC(); 1209 if (Shell::options.send_idle_notification) {
1210 const int kLongIdlePauseInMs = 1000;
1211 V8::ContextDisposedNotification();
1212 V8::IdleNotification(kLongIdlePauseInMs);
1213 }
1225 } 1214 }
1226 done_semaphore_.Signal(); 1215 done_semaphore_.Signal();
1227 } while (!Shell::options.last_run); 1216 } while (!Shell::options.last_run);
1228
1229 isolate->Dispose(); 1217 isolate->Dispose();
1230 } 1218 }
1231 1219
1232 1220
1233 void SourceGroup::StartExecuteInThread() { 1221 void SourceGroup::StartExecuteInThread() {
1234 if (thread_ == NULL) { 1222 if (thread_ == NULL) {
1235 thread_ = new IsolateThread(this); 1223 thread_ = new IsolateThread(this);
1236 thread_->Start(); 1224 thread_->Start();
1237 } 1225 }
1238 next_semaphore_.Signal(); 1226 next_semaphore_.Signal();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 argv[i] = NULL; 1267 argv[i] = NULL;
1280 } else if (strcmp(argv[i], "--shell") == 0) { 1268 } else if (strcmp(argv[i], "--shell") == 0) {
1281 options.interactive_shell = true; 1269 options.interactive_shell = true;
1282 argv[i] = NULL; 1270 argv[i] = NULL;
1283 } else if (strcmp(argv[i], "--test") == 0) { 1271 } else if (strcmp(argv[i], "--test") == 0) {
1284 options.test_shell = true; 1272 options.test_shell = true;
1285 argv[i] = NULL; 1273 argv[i] = NULL;
1286 } else if (strcmp(argv[i], "--send-idle-notification") == 0) { 1274 } else if (strcmp(argv[i], "--send-idle-notification") == 0) {
1287 options.send_idle_notification = true; 1275 options.send_idle_notification = true;
1288 argv[i] = NULL; 1276 argv[i] = NULL;
1289 } else if (strcmp(argv[i], "--invoke-weak-callbacks") == 0) {
1290 options.invoke_weak_callbacks = true;
1291 // TODO(jochen) See issue 3351
1292 options.send_idle_notification = true;
1293 argv[i] = NULL;
1294 } else if (strcmp(argv[i], "-f") == 0) { 1277 } else if (strcmp(argv[i], "-f") == 0) {
1295 // Ignore any -f flags for compatibility with other stand-alone 1278 // Ignore any -f flags for compatibility with other stand-alone
1296 // JavaScript engines. 1279 // JavaScript engines.
1297 continue; 1280 continue;
1298 } else if (strcmp(argv[i], "--isolate") == 0) { 1281 } else if (strcmp(argv[i], "--isolate") == 0) {
1299 #ifdef V8_SHARED 1282 #ifdef V8_SHARED
1300 printf("D8 with shared library does not support multi-threading\n"); 1283 printf("D8 with shared library does not support multi-threading\n");
1301 return false; 1284 return false;
1302 #endif // V8_SHARED 1285 #endif // V8_SHARED
1303 options.num_isolates++; 1286 options.num_isolates++;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 InstallUtilityScript(isolate); 1355 InstallUtilityScript(isolate);
1373 } 1356 }
1374 #endif // !V8_SHARED 1357 #endif // !V8_SHARED
1375 } 1358 }
1376 { 1359 {
1377 Context::Scope cscope(context); 1360 Context::Scope cscope(context);
1378 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate)); 1361 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate));
1379 options.isolate_sources[0].Execute(isolate); 1362 options.isolate_sources[0].Execute(isolate);
1380 } 1363 }
1381 } 1364 }
1382 SuggestivelyAskForAggressiveGC(); 1365 if (options.send_idle_notification) {
1366 const int kLongIdlePauseInMs = 1000;
1367 V8::ContextDisposedNotification();
1368 V8::IdleNotification(kLongIdlePauseInMs);
1369 }
1383 1370
1384 #ifndef V8_SHARED 1371 #ifndef V8_SHARED
1385 for (int i = 1; i < options.num_isolates; ++i) { 1372 for (int i = 1; i < options.num_isolates; ++i) {
1386 options.isolate_sources[i].WaitForThread(); 1373 options.isolate_sources[i].WaitForThread();
1387 } 1374 }
1388 #endif // !V8_SHARED 1375 #endif // !V8_SHARED
1389 return 0; 1376 return 0;
1390 } 1377 }
1391 1378
1392 1379
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 } 1542 }
1556 1543
1557 } // namespace v8 1544 } // namespace v8
1558 1545
1559 1546
1560 #ifndef GOOGLE3 1547 #ifndef GOOGLE3
1561 int main(int argc, char* argv[]) { 1548 int main(int argc, char* argv[]) {
1562 return v8::Shell::Main(argc, argv); 1549 return v8::Shell::Main(argc, argv);
1563 } 1550 }
1564 #endif 1551 #endif
OLDNEW
« no previous file with comments | « src/d8.h ('k') | tools/run-tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698