| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1936 } | 1936 } |
| 1937 | 1937 |
| 1938 | 1938 |
| 1939 bool Genesis::InstallExtensions(Handle<Context> global_context, | 1939 bool Genesis::InstallExtensions(Handle<Context> global_context, |
| 1940 v8::ExtensionConfiguration* extensions) { | 1940 v8::ExtensionConfiguration* extensions) { |
| 1941 // TODO(isolates): Extensions on multiple isolates may take a little more | 1941 // TODO(isolates): Extensions on multiple isolates may take a little more |
| 1942 // effort. (The external API reads 'ignore'-- does that mean | 1942 // effort. (The external API reads 'ignore'-- does that mean |
| 1943 // we can break the interface?) | 1943 // we can break the interface?) |
| 1944 | 1944 |
| 1945 // Clear coloring of extension list | 1945 // Clear coloring of extension list |
| 1946 i::Isolate* isolate = i::Isolate::Current(); |
| 1946 v8::RegisteredExtension* current = v8::RegisteredExtension::first_extension(); | 1947 v8::RegisteredExtension* current = v8::RegisteredExtension::first_extension(); |
| 1947 while (current != NULL) { | 1948 while (current != NULL) { |
| 1948 current->set_state(v8::UNVISITED); | 1949 isolate->extension_states()->set_state(current, i::UNVISITED); |
| 1949 current = current->next(); | 1950 current = current->next(); |
| 1950 } | 1951 } |
| 1951 // Install auto extensions. | 1952 // Install auto extensions. |
| 1952 current = v8::RegisteredExtension::first_extension(); | 1953 current = v8::RegisteredExtension::first_extension(); |
| 1953 while (current != NULL) { | 1954 while (current != NULL) { |
| 1954 if (current->extension()->auto_enable()) | 1955 if (current->extension()->auto_enable()) |
| 1955 InstallExtension(current); | 1956 InstallExtension(current); |
| 1956 current = current->next(); | 1957 current = current->next(); |
| 1957 } | 1958 } |
| 1958 | 1959 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1987 "v8::Context::New()", "Cannot find required extension"); | 1988 "v8::Context::New()", "Cannot find required extension"); |
| 1988 return false; | 1989 return false; |
| 1989 } | 1990 } |
| 1990 return InstallExtension(current); | 1991 return InstallExtension(current); |
| 1991 } | 1992 } |
| 1992 | 1993 |
| 1993 | 1994 |
| 1994 bool Genesis::InstallExtension(v8::RegisteredExtension* current) { | 1995 bool Genesis::InstallExtension(v8::RegisteredExtension* current) { |
| 1995 HandleScope scope; | 1996 HandleScope scope; |
| 1996 | 1997 |
| 1997 if (current->state() == v8::INSTALLED) return true; | 1998 ExtensionStates* extension_states = Isolate::Current()->extension_states(); |
| 1999 if (extension_states->get_state(current) == INSTALLED) return true; |
| 1998 // The current node has already been visited so there must be a | 2000 // The current node has already been visited so there must be a |
| 1999 // cycle in the dependency graph; fail. | 2001 // cycle in the dependency graph; fail. |
| 2000 if (current->state() == v8::VISITED) { | 2002 if (extension_states->get_state(current) == VISITED) { |
| 2001 v8::Utils::ReportApiFailure( | 2003 v8::Utils::ReportApiFailure( |
| 2002 "v8::Context::New()", "Circular extension dependency"); | 2004 "v8::Context::New()", "Circular extension dependency"); |
| 2003 return false; | 2005 return false; |
| 2004 } | 2006 } |
| 2005 ASSERT(current->state() == v8::UNVISITED); | 2007 ASSERT(extension_states->get_state(current) == UNVISITED); |
| 2006 current->set_state(v8::VISITED); | 2008 extension_states->set_state(current, VISITED); |
| 2007 v8::Extension* extension = current->extension(); | 2009 v8::Extension* extension = current->extension(); |
| 2008 // Install the extension's dependencies | 2010 // Install the extension's dependencies |
| 2009 for (int i = 0; i < extension->dependency_count(); i++) { | 2011 for (int i = 0; i < extension->dependency_count(); i++) { |
| 2010 if (!InstallExtension(extension->dependencies()[i])) return false; | 2012 if (!InstallExtension(extension->dependencies()[i])) return false; |
| 2011 } | 2013 } |
| 2012 Isolate* isolate = Isolate::Current(); | 2014 Isolate* isolate = Isolate::Current(); |
| 2013 Handle<String> source_code = | 2015 Handle<String> source_code = |
| 2014 isolate->factory()->NewExternalStringFromAscii(extension->source()); | 2016 isolate->factory()->NewExternalStringFromAscii(extension->source()); |
| 2015 bool result = CompileScriptCached( | 2017 bool result = CompileScriptCached( |
| 2016 CStrVector(extension->name()), | 2018 CStrVector(extension->name()), |
| 2017 source_code, | 2019 source_code, |
| 2018 isolate->bootstrapper()->extensions_cache(), | 2020 isolate->bootstrapper()->extensions_cache(), |
| 2019 extension, | 2021 extension, |
| 2020 Handle<Context>(isolate->context()), | 2022 Handle<Context>(isolate->context()), |
| 2021 false); | 2023 false); |
| 2022 ASSERT(isolate->has_pending_exception() != result); | 2024 ASSERT(isolate->has_pending_exception() != result); |
| 2023 if (!result) { | 2025 if (!result) { |
| 2024 // We print out the name of the extension that fail to install. | 2026 // We print out the name of the extension that fail to install. |
| 2025 // When an error is thrown during bootstrapping we automatically print | 2027 // When an error is thrown during bootstrapping we automatically print |
| 2026 // the line number at which this happened to the console in the isolate | 2028 // the line number at which this happened to the console in the isolate |
| 2027 // error throwing functionality. | 2029 // error throwing functionality. |
| 2028 OS::PrintError("Error installing extension '%s'.\n", | 2030 OS::PrintError("Error installing extension '%s'.\n", |
| 2029 current->extension()->name()); | 2031 current->extension()->name()); |
| 2030 isolate->clear_pending_exception(); | 2032 isolate->clear_pending_exception(); |
| 2031 } | 2033 } |
| 2032 current->set_state(v8::INSTALLED); | 2034 extension_states->set_state(current, INSTALLED); |
| 2033 return result; | 2035 return result; |
| 2034 } | 2036 } |
| 2035 | 2037 |
| 2036 | 2038 |
| 2037 bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) { | 2039 bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) { |
| 2038 HandleScope scope; | 2040 HandleScope scope; |
| 2039 Factory* factory = builtins->GetIsolate()->factory(); | 2041 Factory* factory = builtins->GetIsolate()->factory(); |
| 2040 for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) { | 2042 for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) { |
| 2041 Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i); | 2043 Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i); |
| 2042 Handle<String> name = factory->LookupAsciiSymbol(Builtins::GetName(id)); | 2044 Handle<String> name = factory->LookupAsciiSymbol(Builtins::GetName(id)); |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2306 return from + sizeof(NestingCounterType); | 2308 return from + sizeof(NestingCounterType); |
| 2307 } | 2309 } |
| 2308 | 2310 |
| 2309 | 2311 |
| 2310 // Called when the top-level V8 mutex is destroyed. | 2312 // Called when the top-level V8 mutex is destroyed. |
| 2311 void Bootstrapper::FreeThreadResources() { | 2313 void Bootstrapper::FreeThreadResources() { |
| 2312 ASSERT(!IsActive()); | 2314 ASSERT(!IsActive()); |
| 2313 } | 2315 } |
| 2314 | 2316 |
| 2315 } } // namespace v8::internal | 2317 } } // namespace v8::internal |
| OLD | NEW |