| OLD | NEW |
| 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 static_cast<Worker*>(object->GetAlignedPointerFromInternalField(0)); | 195 static_cast<Worker*>(object->GetAlignedPointerFromInternalField(0)); |
| 196 if (worker == NULL) { | 196 if (worker == NULL) { |
| 197 Throw(isolate, "Worker is defunct because main thread is terminating"); | 197 Throw(isolate, "Worker is defunct because main thread is terminating"); |
| 198 return NULL; | 198 return NULL; |
| 199 } | 199 } |
| 200 | 200 |
| 201 return worker; | 201 return worker; |
| 202 } | 202 } |
| 203 #endif // !V8_SHARED | 203 #endif // !V8_SHARED |
| 204 | 204 |
| 205 bool AccessCheck(v8::Local<v8::Context> accessing_context, |
| 206 v8::Local<v8::Object> accessed_object, v8::Local<Value> data) { |
| 207 return !Shell::options.restricted_realms; |
| 208 } |
| 205 | 209 |
| 206 } // namespace | 210 } // namespace |
| 207 | 211 |
| 208 | 212 |
| 209 class PerIsolateData { | 213 class PerIsolateData { |
| 210 public: | 214 public: |
| 211 explicit PerIsolateData(Isolate* isolate) : isolate_(isolate), realms_(NULL) { | 215 explicit PerIsolateData(Isolate* isolate) : isolate_(isolate), realms_(NULL) { |
| 212 HandleScope scope(isolate); | 216 HandleScope scope(isolate); |
| 213 isolate->SetData(0, this); | 217 isolate->SetData(0, this); |
| 214 } | 218 } |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1218 worker_fun_template); | 1222 worker_fun_template); |
| 1219 #endif // !V8_SHARED | 1223 #endif // !V8_SHARED |
| 1220 | 1224 |
| 1221 Local<ObjectTemplate> os_templ = ObjectTemplate::New(isolate); | 1225 Local<ObjectTemplate> os_templ = ObjectTemplate::New(isolate); |
| 1222 AddOSMethods(isolate, os_templ); | 1226 AddOSMethods(isolate, os_templ); |
| 1223 global_template->Set( | 1227 global_template->Set( |
| 1224 String::NewFromUtf8(isolate, "os", NewStringType::kNormal) | 1228 String::NewFromUtf8(isolate, "os", NewStringType::kNormal) |
| 1225 .ToLocalChecked(), | 1229 .ToLocalChecked(), |
| 1226 os_templ); | 1230 os_templ); |
| 1227 | 1231 |
| 1232 global_template->SetAccessCheckCallback(AccessCheck); |
| 1233 |
| 1228 return global_template; | 1234 return global_template; |
| 1229 } | 1235 } |
| 1230 | 1236 |
| 1231 static void EmptyMessageCallback(Local<Message> message, Local<Value> error) { | 1237 static void EmptyMessageCallback(Local<Message> message, Local<Value> error) { |
| 1232 // Nothing to be done here, exceptions thrown up to the shell will be reported | 1238 // Nothing to be done here, exceptions thrown up to the shell will be reported |
| 1233 // separately by {Shell::ReportException} after they are caught. | 1239 // separately by {Shell::ReportException} after they are caught. |
| 1234 } | 1240 } |
| 1235 | 1241 |
| 1236 void Shell::Initialize(Isolate* isolate) { | 1242 void Shell::Initialize(Isolate* isolate) { |
| 1237 #ifndef V8_SHARED | 1243 #ifndef V8_SHARED |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1983 options.compile_options = v8::ScriptCompiler::kProduceCodeCache; | 1989 options.compile_options = v8::ScriptCompiler::kProduceCodeCache; |
| 1984 } else if (strncmp(value, "=parse", 7) == 0) { | 1990 } else if (strncmp(value, "=parse", 7) == 0) { |
| 1985 options.compile_options = v8::ScriptCompiler::kProduceParserCache; | 1991 options.compile_options = v8::ScriptCompiler::kProduceParserCache; |
| 1986 } else if (strncmp(value, "=none", 6) == 0) { | 1992 } else if (strncmp(value, "=none", 6) == 0) { |
| 1987 options.compile_options = v8::ScriptCompiler::kNoCompileOptions; | 1993 options.compile_options = v8::ScriptCompiler::kNoCompileOptions; |
| 1988 } else { | 1994 } else { |
| 1989 printf("Unknown option to --cache.\n"); | 1995 printf("Unknown option to --cache.\n"); |
| 1990 return false; | 1996 return false; |
| 1991 } | 1997 } |
| 1992 argv[i] = NULL; | 1998 argv[i] = NULL; |
| 1999 } else if (strcmp(argv[i], "--restricted-realms") == 0) { |
| 2000 options.restricted_realms = true; |
| 2001 argv[i] = nullptr; |
| 1993 } | 2002 } |
| 1994 } | 2003 } |
| 1995 | 2004 |
| 1996 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); | 2005 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); |
| 1997 | 2006 |
| 1998 // Set up isolated source groups. | 2007 // Set up isolated source groups. |
| 1999 options.isolate_sources = new SourceGroup[options.num_isolates]; | 2008 options.isolate_sources = new SourceGroup[options.num_isolates]; |
| 2000 SourceGroup* current = options.isolate_sources; | 2009 SourceGroup* current = options.isolate_sources; |
| 2001 current->Begin(argv, 1); | 2010 current->Begin(argv, 1); |
| 2002 for (int i = 1; i < argc; i++) { | 2011 for (int i = 1; i < argc; i++) { |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2547 } | 2556 } |
| 2548 | 2557 |
| 2549 } // namespace v8 | 2558 } // namespace v8 |
| 2550 | 2559 |
| 2551 | 2560 |
| 2552 #ifndef GOOGLE3 | 2561 #ifndef GOOGLE3 |
| 2553 int main(int argc, char* argv[]) { | 2562 int main(int argc, char* argv[]) { |
| 2554 return v8::Shell::Main(argc, argv); | 2563 return v8::Shell::Main(argc, argv); |
| 2555 } | 2564 } |
| 2556 #endif | 2565 #endif |
| OLD | NEW |