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 22 matching lines...) Expand all Loading... | |
33 | 33 |
34 #ifdef COMPRESS_STARTUP_DATA_BZ2 | 34 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
35 #include <bzlib.h> | 35 #include <bzlib.h> |
36 #endif | 36 #endif |
37 | 37 |
38 #include <errno.h> | 38 #include <errno.h> |
39 #include <stdlib.h> | 39 #include <stdlib.h> |
40 #include <string.h> | 40 #include <string.h> |
41 #include <sys/stat.h> | 41 #include <sys/stat.h> |
42 | 42 |
43 // TODO(dcarney): remove | |
44 #define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW | |
45 #define V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR | |
46 #define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT | |
47 | |
43 #ifdef V8_SHARED | 48 #ifdef V8_SHARED |
44 #include <assert.h> | 49 #include <assert.h> |
45 #endif // V8_SHARED | 50 #endif // V8_SHARED |
46 | 51 |
47 #ifndef V8_SHARED | 52 #ifndef V8_SHARED |
48 #include <algorithm> | 53 #include <algorithm> |
49 #endif // !V8_SHARED | 54 #endif // !V8_SHARED |
50 | 55 |
51 #ifdef V8_SHARED | 56 #ifdef V8_SHARED |
52 #include "../include/v8-testing.h" | 57 #include "../include/v8-testing.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 FOR_EACH_STRING(DISPOSE_STRING) | 122 FOR_EACH_STRING(DISPOSE_STRING) |
118 #undef DISPOSE_STRING | 123 #undef DISPOSE_STRING |
119 isolate_->SetData(NULL); // Not really needed, just to be sure... | 124 isolate_->SetData(NULL); // Not really needed, just to be sure... |
120 } | 125 } |
121 | 126 |
122 inline static PerIsolateData* Get(Isolate* isolate) { | 127 inline static PerIsolateData* Get(Isolate* isolate) { |
123 return reinterpret_cast<PerIsolateData*>(isolate->GetData()); | 128 return reinterpret_cast<PerIsolateData*>(isolate->GetData()); |
124 } | 129 } |
125 | 130 |
126 #define DEFINE_STRING_GETTER(name, value) \ | 131 #define DEFINE_STRING_GETTER(name, value) \ |
127 static Persistent<String> name##_string(Isolate* isolate) { \ | 132 static Handle<String> name##_string(Isolate* isolate) { \ |
128 return Get(isolate)->name##_string_; \ | 133 return Handle<String>(*Get(isolate)->name##_string_); \ |
129 } | 134 } |
130 FOR_EACH_STRING(DEFINE_STRING_GETTER) | 135 FOR_EACH_STRING(DEFINE_STRING_GETTER) |
131 #undef DEFINE_STRING_GETTER | 136 #undef DEFINE_STRING_GETTER |
132 | 137 |
133 class RealmScope { | 138 class RealmScope { |
134 public: | 139 public: |
135 explicit RealmScope(PerIsolateData* data); | 140 explicit RealmScope(PerIsolateData* data); |
136 ~RealmScope(); | 141 ~RealmScope(); |
137 private: | 142 private: |
138 PerIsolateData* data_; | 143 PerIsolateData* data_; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 } | 243 } |
239 Handle<Script> script = Script::New(source, name); | 244 Handle<Script> script = Script::New(source, name); |
240 if (script.IsEmpty()) { | 245 if (script.IsEmpty()) { |
241 // Print errors that happened during compilation. | 246 // Print errors that happened during compilation. |
242 if (report_exceptions && !FLAG_debugger) | 247 if (report_exceptions && !FLAG_debugger) |
243 ReportException(isolate, &try_catch); | 248 ReportException(isolate, &try_catch); |
244 return false; | 249 return false; |
245 } else { | 250 } else { |
246 PerIsolateData* data = PerIsolateData::Get(isolate); | 251 PerIsolateData* data = PerIsolateData::Get(isolate); |
247 Local<Context> realm = | 252 Local<Context> realm = |
248 Local<Context>::New(data->realms_[data->realm_current_]); | 253 Local<Context>::New(isolate, data->realms_[data->realm_current_]); |
249 realm->Enter(); | 254 realm->Enter(); |
250 Handle<Value> result = script->Run(); | 255 Handle<Value> result = script->Run(); |
251 realm->Exit(); | 256 realm->Exit(); |
252 data->realm_current_ = data->realm_switch_; | 257 data->realm_current_ = data->realm_switch_; |
253 if (result.IsEmpty()) { | 258 if (result.IsEmpty()) { |
254 ASSERT(try_catch.HasCaught()); | 259 ASSERT(try_catch.HasCaught()); |
255 // Print errors that happened during execution. | 260 // Print errors that happened during execution. |
256 if (report_exceptions && !FLAG_debugger) | 261 if (report_exceptions && !FLAG_debugger) |
257 ReportException(isolate, &try_catch); | 262 ReportException(isolate, &try_catch); |
258 return false; | 263 return false; |
259 } else { | 264 } else { |
260 ASSERT(!try_catch.HasCaught()); | 265 ASSERT(!try_catch.HasCaught()); |
261 if (print_result) { | 266 if (print_result) { |
262 #if !defined(V8_SHARED) | 267 #if !defined(V8_SHARED) |
263 if (options.test_shell) { | 268 if (options.test_shell) { |
264 #endif | 269 #endif |
265 if (!result->IsUndefined()) { | 270 if (!result->IsUndefined()) { |
266 // If all went well and the result wasn't undefined then print | 271 // If all went well and the result wasn't undefined then print |
267 // the returned value. | 272 // the returned value. |
268 v8::String::Utf8Value str(result); | 273 v8::String::Utf8Value str(result); |
269 fwrite(*str, sizeof(**str), str.length(), stdout); | 274 fwrite(*str, sizeof(**str), str.length(), stdout); |
270 printf("\n"); | 275 printf("\n"); |
271 } | 276 } |
272 #if !defined(V8_SHARED) | 277 #if !defined(V8_SHARED) |
273 } else { | 278 } else { |
274 v8::TryCatch try_catch; | 279 v8::TryCatch try_catch; |
275 Context::Scope context_scope(utility_context_); | 280 Context::Scope context_scope(isolate, utility_context_); |
276 Handle<Object> global = utility_context_->Global(); | 281 Handle<Object> global = utility_context_->Global(); |
277 Handle<Value> fun = global->Get(String::New("Stringify")); | 282 Handle<Value> fun = global->Get(String::New("Stringify")); |
278 Handle<Value> argv[1] = { result }; | 283 Handle<Value> argv[1] = { result }; |
279 Handle<Value> s = Handle<Function>::Cast(fun)->Call(global, 1, argv); | 284 Handle<Value> s = Handle<Function>::Cast(fun)->Call(global, 1, argv); |
280 if (try_catch.HasCaught()) return true; | 285 if (try_catch.HasCaught()) return true; |
281 v8::String::Utf8Value str(s); | 286 v8::String::Utf8Value str(s); |
282 fwrite(*str, sizeof(**str), str.length(), stdout); | 287 fwrite(*str, sizeof(**str), str.length(), stdout); |
283 printf("\n"); | 288 printf("\n"); |
284 } | 289 } |
285 #endif | 290 #endif |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
414 PerIsolateData* data = PerIsolateData::Get(isolate); | 419 PerIsolateData* data = PerIsolateData::Get(isolate); |
415 if (args.Length() < 2 || !args[0]->IsNumber() || !args[1]->IsString()) { | 420 if (args.Length() < 2 || !args[0]->IsNumber() || !args[1]->IsString()) { |
416 return Throw("Invalid argument"); | 421 return Throw("Invalid argument"); |
417 } | 422 } |
418 int index = args[0]->Uint32Value(); | 423 int index = args[0]->Uint32Value(); |
419 if (index >= data->realm_count_ || data->realms_[index].IsEmpty()) { | 424 if (index >= data->realm_count_ || data->realms_[index].IsEmpty()) { |
420 return Throw("Invalid realm index"); | 425 return Throw("Invalid realm index"); |
421 } | 426 } |
422 Handle<Script> script = Script::New(args[1]->ToString()); | 427 Handle<Script> script = Script::New(args[1]->ToString()); |
423 if (script.IsEmpty()) return Undefined(isolate); | 428 if (script.IsEmpty()) return Undefined(isolate); |
424 Local<Context> realm = Local<Context>::New(data->realms_[index]); | 429 Local<Context> realm = Local<Context>::New(isolate, data->realms_[index]); |
425 realm->Enter(); | 430 realm->Enter(); |
426 Handle<Value> result = script->Run(); | 431 Handle<Value> result = script->Run(); |
427 realm->Exit(); | 432 realm->Exit(); |
428 return result; | 433 return result; |
429 } | 434 } |
430 | 435 |
431 | 436 |
432 // Realm.shared is an accessor for a single shared value across realms. | 437 // Realm.shared is an accessor for a single shared value across realms. |
433 Handle<Value> Shell::RealmSharedGet(Local<String> property, | 438 Handle<Value> Shell::RealmSharedGet(Local<String> property, |
434 const AccessorInfo& info) { | 439 const AccessorInfo& info) { |
435 Isolate* isolate = info.GetIsolate(); | 440 Isolate* isolate = info.GetIsolate(); |
436 PerIsolateData* data = PerIsolateData::Get(isolate); | 441 PerIsolateData* data = PerIsolateData::Get(isolate); |
437 if (data->realm_shared_.IsEmpty()) return Undefined(isolate); | 442 if (data->realm_shared_.IsEmpty()) return Undefined(isolate); |
438 return data->realm_shared_; | 443 return Local<Value>::New(isolate, data->realm_shared_); |
439 } | 444 } |
440 | 445 |
441 void Shell::RealmSharedSet(Local<String> property, | 446 void Shell::RealmSharedSet(Local<String> property, |
442 Local<Value> value, | 447 Local<Value> value, |
443 const AccessorInfo& info) { | 448 const AccessorInfo& info) { |
444 Isolate* isolate = info.GetIsolate(); | 449 Isolate* isolate = info.GetIsolate(); |
445 PerIsolateData* data = PerIsolateData::Get(isolate); | 450 PerIsolateData* data = PerIsolateData::Get(isolate); |
446 if (!data->realm_shared_.IsEmpty()) data->realm_shared_.Dispose(isolate); | 451 if (!data->realm_shared_.IsEmpty()) data->realm_shared_.Dispose(isolate); |
447 data->realm_shared_ = Persistent<Value>::New(isolate, value); | 452 data->realm_shared_ = Persistent<Value>::New(isolate, value); |
448 } | 453 } |
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1173 if (enter_context) utility_context_->Exit(); | 1178 if (enter_context) utility_context_->Exit(); |
1174 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT | 1179 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT |
1175 } | 1180 } |
1176 | 1181 |
1177 | 1182 |
1178 #ifndef V8_SHARED | 1183 #ifndef V8_SHARED |
1179 Handle<Array> Shell::GetCompletions(Isolate* isolate, | 1184 Handle<Array> Shell::GetCompletions(Isolate* isolate, |
1180 Handle<String> text, | 1185 Handle<String> text, |
1181 Handle<String> full) { | 1186 Handle<String> full) { |
1182 HandleScope handle_scope(isolate); | 1187 HandleScope handle_scope(isolate); |
1183 Context::Scope context_scope(utility_context_); | 1188 Context::Scope context_scope(isolate, utility_context_); |
1184 Handle<Object> global = utility_context_->Global(); | 1189 Handle<Object> global = utility_context_->Global(); |
1185 Handle<Value> fun = global->Get(String::New("GetCompletions")); | 1190 Handle<Value> fun = global->Get(String::New("GetCompletions")); |
1186 static const int kArgc = 3; | 1191 static const int kArgc = 3; |
1187 Handle<Value> argv[kArgc] = { evaluation_context_->Global(), text, full }; | 1192 Handle<Value> argv[kArgc] = { evaluation_context_->Global(), text, full }; |
1188 Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv); | 1193 Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv); |
1189 return handle_scope.Close(Handle<Array>::Cast(val)); | 1194 return handle_scope.Close(Handle<Array>::Cast(val)); |
1190 } | 1195 } |
1191 | 1196 |
1192 | 1197 |
1193 #ifdef ENABLE_DEBUGGER_SUPPORT | 1198 #ifdef ENABLE_DEBUGGER_SUPPORT |
1194 Handle<Object> Shell::DebugMessageDetails(Handle<String> message) { | 1199 Handle<Object> Shell::DebugMessageDetails(Handle<String> message) { |
Sven Panne
2013/04/30 07:31:22
Again, it might make sense to pass the Isolate as
| |
1195 Context::Scope context_scope(utility_context_); | 1200 Isolate* isolate = v8::Isolate::GetCurrent(); |
1201 HandleScope handle_scope(isolate); | |
1202 Context::Scope context_scope(isolate, utility_context_); | |
1196 Handle<Object> global = utility_context_->Global(); | 1203 Handle<Object> global = utility_context_->Global(); |
1197 Handle<Value> fun = global->Get(String::New("DebugMessageDetails")); | 1204 Handle<Value> fun = global->Get(String::New("DebugMessageDetails")); |
1198 static const int kArgc = 1; | 1205 static const int kArgc = 1; |
1199 Handle<Value> argv[kArgc] = { message }; | 1206 Handle<Value> argv[kArgc] = { message }; |
1200 Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv); | 1207 Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv); |
1201 return Handle<Object>::Cast(val); | 1208 return Handle<Object>::Cast(val); |
1202 } | 1209 } |
1203 | 1210 |
1204 | 1211 |
1205 Handle<Value> Shell::DebugCommandToJSONRequest(Handle<String> command) { | 1212 Handle<Value> Shell::DebugCommandToJSONRequest(Handle<String> command) { |
1206 Context::Scope context_scope(utility_context_); | 1213 Isolate* isolate = v8::Isolate::GetCurrent(); |
1214 HandleScope handle_scope(isolate); | |
1215 Context::Scope context_scope(isolate, utility_context_); | |
1207 Handle<Object> global = utility_context_->Global(); | 1216 Handle<Object> global = utility_context_->Global(); |
1208 Handle<Value> fun = global->Get(String::New("DebugCommandToJSONRequest")); | 1217 Handle<Value> fun = global->Get(String::New("DebugCommandToJSONRequest")); |
1209 static const int kArgc = 1; | 1218 static const int kArgc = 1; |
1210 Handle<Value> argv[kArgc] = { command }; | 1219 Handle<Value> argv[kArgc] = { command }; |
1211 Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv); | 1220 Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv); |
1212 return val; | 1221 return val; |
1213 } | 1222 } |
1214 | 1223 |
1215 | 1224 |
1216 void Shell::DispatchDebugMessages() { | 1225 void Shell::DispatchDebugMessages() { |
1217 v8::Context::Scope scope(Shell::evaluation_context_); | 1226 Isolate* isolate = v8::Isolate::GetCurrent(); |
1227 HandleScope handle_scope(isolate); | |
1228 v8::Context::Scope scope(isolate, Shell::evaluation_context_); | |
1218 v8::Debug::ProcessDebugMessages(); | 1229 v8::Debug::ProcessDebugMessages(); |
1219 } | 1230 } |
1220 #endif // ENABLE_DEBUGGER_SUPPORT | 1231 #endif // ENABLE_DEBUGGER_SUPPORT |
1221 #endif // V8_SHARED | 1232 #endif // V8_SHARED |
1222 | 1233 |
1223 | 1234 |
1224 #ifndef V8_SHARED | 1235 #ifndef V8_SHARED |
1225 int32_t* Counter::Bind(const char* name, bool is_histogram) { | 1236 int32_t* Counter::Bind(const char* name, bool is_histogram) { |
1226 int i; | 1237 int i; |
1227 for (i = 0; i < kMaxNameSize - 1 && name[i]; i++) | 1238 for (i = 0; i < kMaxNameSize - 1 && name[i]; i++) |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1320 } | 1331 } |
1321 | 1332 |
1322 | 1333 |
1323 void Shell::InstallUtilityScript(Isolate* isolate) { | 1334 void Shell::InstallUtilityScript(Isolate* isolate) { |
1324 Locker lock(isolate); | 1335 Locker lock(isolate); |
1325 HandleScope scope(isolate); | 1336 HandleScope scope(isolate); |
1326 // If we use the utility context, we have to set the security tokens so that | 1337 // If we use the utility context, we have to set the security tokens so that |
1327 // utility, evaluation and debug context can all access each other. | 1338 // utility, evaluation and debug context can all access each other. |
1328 utility_context_->SetSecurityToken(Undefined(isolate)); | 1339 utility_context_->SetSecurityToken(Undefined(isolate)); |
1329 evaluation_context_->SetSecurityToken(Undefined(isolate)); | 1340 evaluation_context_->SetSecurityToken(Undefined(isolate)); |
1330 Context::Scope utility_scope(utility_context_); | 1341 Context::Scope utility_scope(isolate, utility_context_); |
1331 | 1342 |
1332 #ifdef ENABLE_DEBUGGER_SUPPORT | 1343 #ifdef ENABLE_DEBUGGER_SUPPORT |
1333 if (i::FLAG_debugger) printf("JavaScript debugger enabled\n"); | 1344 if (i::FLAG_debugger) printf("JavaScript debugger enabled\n"); |
1334 // Install the debugger object in the utility scope | 1345 // Install the debugger object in the utility scope |
1335 i::Debug* debug = i::Isolate::Current()->debug(); | 1346 i::Debug* debug = i::Isolate::Current()->debug(); |
1336 debug->Load(); | 1347 debug->Load(); |
1337 i::Handle<i::JSObject> js_debug | 1348 i::Handle<i::JSObject> js_debug |
1338 = i::Handle<i::JSObject>(debug->debug_context()->global_object()); | 1349 = i::Handle<i::JSObject>(debug->debug_context()->global_object()); |
1339 utility_context_->Global()->Set(String::New("$debug"), | 1350 utility_context_->Global()->Set(String::New("$debug"), |
1340 Utils::ToLocal(js_debug)); | 1351 Utils::ToLocal(js_debug)); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1537 | 1548 |
1538 Persistent<Context> Shell::CreateEvaluationContext(Isolate* isolate) { | 1549 Persistent<Context> Shell::CreateEvaluationContext(Isolate* isolate) { |
1539 #ifndef V8_SHARED | 1550 #ifndef V8_SHARED |
1540 // This needs to be a critical section since this is not thread-safe | 1551 // This needs to be a critical section since this is not thread-safe |
1541 i::ScopedLock lock(context_mutex_); | 1552 i::ScopedLock lock(context_mutex_); |
1542 #endif // V8_SHARED | 1553 #endif // V8_SHARED |
1543 // Initialize the global objects | 1554 // Initialize the global objects |
1544 Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate); | 1555 Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate); |
1545 Persistent<Context> context = Context::New(NULL, global_template); | 1556 Persistent<Context> context = Context::New(NULL, global_template); |
1546 ASSERT(!context.IsEmpty()); | 1557 ASSERT(!context.IsEmpty()); |
1547 Context::Scope scope(context); | 1558 HandleScope handle_scope(isolate); |
1559 Context::Scope scope(isolate, context); | |
1548 | 1560 |
1549 #ifndef V8_SHARED | 1561 #ifndef V8_SHARED |
1550 i::JSArguments js_args = i::FLAG_js_arguments; | 1562 i::JSArguments js_args = i::FLAG_js_arguments; |
1551 i::Handle<i::FixedArray> arguments_array = | 1563 i::Handle<i::FixedArray> arguments_array = |
1552 FACTORY->NewFixedArray(js_args.argc()); | 1564 FACTORY->NewFixedArray(js_args.argc()); |
1553 for (int j = 0; j < js_args.argc(); j++) { | 1565 for (int j = 0; j < js_args.argc(); j++) { |
1554 i::Handle<i::String> arg = | 1566 i::Handle<i::String> arg = |
1555 FACTORY->NewStringFromUtf8(i::CStrVector(js_args[j])); | 1567 FACTORY->NewStringFromUtf8(i::CStrVector(js_args[j])); |
1556 arguments_array->set(j, *arg); | 1568 arguments_array->set(j, *arg); |
1557 } | 1569 } |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1733 char* chars = ReadChars(isolate, name, &size); | 1745 char* chars = ReadChars(isolate, name, &size); |
1734 if (chars == NULL) return Handle<String>(); | 1746 if (chars == NULL) return Handle<String>(); |
1735 Handle<String> result = String::New(chars, size); | 1747 Handle<String> result = String::New(chars, size); |
1736 delete[] chars; | 1748 delete[] chars; |
1737 return result; | 1749 return result; |
1738 } | 1750 } |
1739 | 1751 |
1740 | 1752 |
1741 void Shell::RunShell(Isolate* isolate) { | 1753 void Shell::RunShell(Isolate* isolate) { |
1742 Locker locker(isolate); | 1754 Locker locker(isolate); |
1743 Context::Scope context_scope(evaluation_context_); | 1755 Context::Scope context_scope(isolate, evaluation_context_); |
1744 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate)); | 1756 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate)); |
1745 HandleScope outer_scope(isolate); | 1757 HandleScope outer_scope(isolate); |
1746 Handle<String> name = String::New("(d8)"); | 1758 Handle<String> name = String::New("(d8)"); |
1747 LineEditor* console = LineEditor::Get(); | 1759 LineEditor* console = LineEditor::Get(); |
1748 printf("V8 version %s [console: %s]\n", V8::GetVersion(), console->name()); | 1760 printf("V8 version %s [console: %s]\n", V8::GetVersion(), console->name()); |
1749 console->Open(isolate); | 1761 console->Open(isolate); |
1750 while (true) { | 1762 while (true) { |
1751 HandleScope inner_scope(isolate); | 1763 HandleScope inner_scope(isolate); |
1752 Handle<String> input = console->Prompt(Shell::kPrompt); | 1764 Handle<String> input = console->Prompt(Shell::kPrompt); |
1753 if (input.IsEmpty()) break; | 1765 if (input.IsEmpty()) break; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1786 // Skip comment lines. | 1798 // Skip comment lines. |
1787 ptr = next_line; | 1799 ptr = next_line; |
1788 continue; | 1800 continue; |
1789 } | 1801 } |
1790 | 1802 |
1791 // Prepare the context for this thread. | 1803 // Prepare the context for this thread. |
1792 Locker locker(isolate_); | 1804 Locker locker(isolate_); |
1793 HandleScope outer_scope(isolate_); | 1805 HandleScope outer_scope(isolate_); |
1794 Persistent<Context> thread_context = | 1806 Persistent<Context> thread_context = |
1795 Shell::CreateEvaluationContext(isolate_); | 1807 Shell::CreateEvaluationContext(isolate_); |
1796 Context::Scope context_scope(thread_context); | 1808 Context::Scope context_scope(isolate_, thread_context); |
1797 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate_)); | 1809 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate_)); |
1798 | 1810 |
1799 while ((ptr != NULL) && (*ptr != '\0')) { | 1811 while ((ptr != NULL) && (*ptr != '\0')) { |
1800 HandleScope inner_scope(isolate_); | 1812 HandleScope inner_scope(isolate_); |
1801 char* filename = ptr; | 1813 char* filename = ptr; |
1802 ptr = ReadWord(ptr); | 1814 ptr = ReadWord(ptr); |
1803 | 1815 |
1804 // Skip empty strings. | 1816 // Skip empty strings. |
1805 if (strlen(filename) == 0) { | 1817 if (strlen(filename) == 0) { |
1806 continue; | 1818 continue; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1889 Isolate* isolate = Isolate::New(); | 1901 Isolate* isolate = Isolate::New(); |
1890 do { | 1902 do { |
1891 if (next_semaphore_ != NULL) next_semaphore_->Wait(); | 1903 if (next_semaphore_ != NULL) next_semaphore_->Wait(); |
1892 { | 1904 { |
1893 Isolate::Scope iscope(isolate); | 1905 Isolate::Scope iscope(isolate); |
1894 Locker lock(isolate); | 1906 Locker lock(isolate); |
1895 HandleScope scope(isolate); | 1907 HandleScope scope(isolate); |
1896 PerIsolateData data(isolate); | 1908 PerIsolateData data(isolate); |
1897 Persistent<Context> context = Shell::CreateEvaluationContext(isolate); | 1909 Persistent<Context> context = Shell::CreateEvaluationContext(isolate); |
1898 { | 1910 { |
1899 Context::Scope cscope(context); | 1911 Context::Scope cscope(isolate, context); |
1900 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate)); | 1912 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate)); |
1901 Execute(isolate); | 1913 Execute(isolate); |
1902 } | 1914 } |
1903 context.Dispose(isolate); | 1915 context.Dispose(isolate); |
1904 if (Shell::options.send_idle_notification) { | 1916 if (Shell::options.send_idle_notification) { |
1905 const int kLongIdlePauseInMs = 1000; | 1917 const int kLongIdlePauseInMs = 1000; |
1906 V8::ContextDisposedNotification(); | 1918 V8::ContextDisposedNotification(); |
1907 V8::IdleNotification(kLongIdlePauseInMs); | 1919 V8::IdleNotification(kLongIdlePauseInMs); |
1908 } | 1920 } |
1909 } | 1921 } |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2098 evaluation_context_ = context; | 2110 evaluation_context_ = context; |
2099 #if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT) | 2111 #if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT) |
2100 // If the interactive debugger is enabled make sure to activate | 2112 // If the interactive debugger is enabled make sure to activate |
2101 // it before running the files passed on the command line. | 2113 // it before running the files passed on the command line. |
2102 if (i::FLAG_debugger) { | 2114 if (i::FLAG_debugger) { |
2103 InstallUtilityScript(isolate); | 2115 InstallUtilityScript(isolate); |
2104 } | 2116 } |
2105 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT | 2117 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT |
2106 } | 2118 } |
2107 { | 2119 { |
2108 Context::Scope cscope(context); | 2120 Context::Scope cscope(isolate, context); |
2109 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate)); | 2121 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate)); |
2110 options.isolate_sources[0].Execute(isolate); | 2122 options.isolate_sources[0].Execute(isolate); |
2111 } | 2123 } |
2112 if (!options.last_run) { | 2124 if (!options.last_run) { |
2113 context.Dispose(isolate); | 2125 context.Dispose(isolate); |
2114 if (options.send_idle_notification) { | 2126 if (options.send_idle_notification) { |
2115 const int kLongIdlePauseInMs = 1000; | 2127 const int kLongIdlePauseInMs = 1000; |
2116 V8::ContextDisposedNotification(); | 2128 V8::ContextDisposedNotification(); |
2117 V8::IdleNotification(kLongIdlePauseInMs); | 2129 V8::IdleNotification(kLongIdlePauseInMs); |
2118 } | 2130 } |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2217 } | 2229 } |
2218 | 2230 |
2219 } // namespace v8 | 2231 } // namespace v8 |
2220 | 2232 |
2221 | 2233 |
2222 #ifndef GOOGLE3 | 2234 #ifndef GOOGLE3 |
2223 int main(int argc, char* argv[]) { | 2235 int main(int argc, char* argv[]) { |
2224 return v8::Shell::Main(argc, argv); | 2236 return v8::Shell::Main(argc, argv); |
2225 } | 2237 } |
2226 #endif | 2238 #endif |
OLD | NEW |