| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 void InitializeExperimentalGlobal(); | 204 void InitializeExperimentalGlobal(); |
| 205 // Installs the contents of the native .js files on the global objects. | 205 // Installs the contents of the native .js files on the global objects. |
| 206 // Used for creating a context from scratch. | 206 // Used for creating a context from scratch. |
| 207 void InstallNativeFunctions(); | 207 void InstallNativeFunctions(); |
| 208 void InstallExperimentalNativeFunctions(); | 208 void InstallExperimentalNativeFunctions(); |
| 209 bool InstallNatives(); | 209 bool InstallNatives(); |
| 210 bool InstallExperimentalNatives(); | 210 bool InstallExperimentalNatives(); |
| 211 void InstallBuiltinFunctionIds(); | 211 void InstallBuiltinFunctionIds(); |
| 212 void InstallJSFunctionResultCaches(); | 212 void InstallJSFunctionResultCaches(); |
| 213 void InitializeNormalizedMapCaches(); | 213 void InitializeNormalizedMapCaches(); |
| 214 | 214 |
| 215 enum ExtensionTraversalState { | 215 enum ExtensionTraversalState { |
| 216 UNVISITED, VISITED, INSTALLED | 216 UNVISITED, VISITED, INSTALLED |
| 217 }; | 217 }; |
| 218 | 218 |
| 219 class ExtensionStates { | 219 class ExtensionStates { |
| 220 DISALLOW_COPY_AND_ASSIGN(ExtensionStates); | |
| 221 public: | 220 public: |
| 222 ExtensionStates(); | 221 ExtensionStates(); |
| 223 ExtensionTraversalState get_state(RegisteredExtension* extension); | 222 ExtensionTraversalState get_state(RegisteredExtension* extension); |
| 224 void set_state(RegisteredExtension* extension, | 223 void set_state(RegisteredExtension* extension, |
| 225 ExtensionTraversalState state); | 224 ExtensionTraversalState state); |
| 226 private: | 225 private: |
| 227 Allocator allocator_; | 226 Allocator allocator_; |
| 228 HashMap map_; | 227 HashMap map_; |
| 228 DISALLOW_COPY_AND_ASSIGN(ExtensionStates); |
| 229 }; | 229 }; |
| 230 | 230 |
| 231 // Used both for deserialized and from-scratch contexts to add the extensions | 231 // Used both for deserialized and from-scratch contexts to add the extensions |
| 232 // provided. | 232 // provided. |
| 233 static bool InstallExtensions(Handle<Context> global_context, | 233 static bool InstallExtensions(Handle<Context> global_context, |
| 234 v8::ExtensionConfiguration* extensions); | 234 v8::ExtensionConfiguration* extensions); |
| 235 static bool InstallExtension(const char* name, | 235 static bool InstallExtension(const char* name, |
| 236 ExtensionStates* extension_states); | 236 ExtensionStates* extension_states); |
| 237 static bool InstallExtension(v8::RegisteredExtension* current, | 237 static bool InstallExtension(v8::RegisteredExtension* current, |
| 238 ExtensionStates* extension_states); | 238 ExtensionStates* extension_states); |
| (...skipping 1743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1982 map_.Lookup(extension, Hash(extension), true)->value = | 1982 map_.Lookup(extension, Hash(extension), true)->value = |
| 1983 reinterpret_cast<void*>(static_cast<intptr_t>(state)); | 1983 reinterpret_cast<void*>(static_cast<intptr_t>(state)); |
| 1984 } | 1984 } |
| 1985 | 1985 |
| 1986 bool Genesis::InstallExtensions(Handle<Context> global_context, | 1986 bool Genesis::InstallExtensions(Handle<Context> global_context, |
| 1987 v8::ExtensionConfiguration* extensions) { | 1987 v8::ExtensionConfiguration* extensions) { |
| 1988 // TODO(isolates): Extensions on multiple isolates may take a little more | 1988 // TODO(isolates): Extensions on multiple isolates may take a little more |
| 1989 // effort. (The external API reads 'ignore'-- does that mean | 1989 // effort. (The external API reads 'ignore'-- does that mean |
| 1990 // we can break the interface?) | 1990 // we can break the interface?) |
| 1991 | 1991 |
| 1992 ExtensionStates extension_states; // All extensions have state UNVISITED. | 1992 |
| 1993 ExtensionStates extension_states; // All extensions have state UNVISITED. |
| 1993 // Install auto extensions. | 1994 // Install auto extensions. |
| 1994 v8::RegisteredExtension* current = v8::RegisteredExtension::first_extension(); | 1995 v8::RegisteredExtension* current = v8::RegisteredExtension::first_extension(); |
| 1995 while (current != NULL) { | 1996 while (current != NULL) { |
| 1996 if (current->extension()->auto_enable()) | 1997 if (current->extension()->auto_enable()) |
| 1997 InstallExtension(current, &extension_states); | 1998 InstallExtension(current, &extension_states); |
| 1998 current = current->next(); | 1999 current = current->next(); |
| 1999 } | 2000 } |
| 2000 | 2001 |
| 2001 if (FLAG_expose_gc) InstallExtension("v8/gc", &extension_states); | 2002 if (FLAG_expose_gc) InstallExtension("v8/gc", &extension_states); |
| 2002 if (FLAG_expose_externalize_string) { | 2003 if (FLAG_expose_externalize_string) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2029 // Didn't find the extension; fail. | 2030 // Didn't find the extension; fail. |
| 2030 if (current == NULL) { | 2031 if (current == NULL) { |
| 2031 v8::Utils::ReportApiFailure( | 2032 v8::Utils::ReportApiFailure( |
| 2032 "v8::Context::New()", "Cannot find required extension"); | 2033 "v8::Context::New()", "Cannot find required extension"); |
| 2033 return false; | 2034 return false; |
| 2034 } | 2035 } |
| 2035 return InstallExtension(current, extension_states); | 2036 return InstallExtension(current, extension_states); |
| 2036 } | 2037 } |
| 2037 | 2038 |
| 2038 | 2039 |
| 2039 bool Genesis::InstallExtension(v8::RegisteredExtension* current, | 2040 bool Genesis::InstallExtension(v8::RegisteredExtension* current, |
| 2040 ExtensionStates* extension_states) { | 2041 ExtensionStates* extension_states) { |
| 2041 HandleScope scope; | 2042 HandleScope scope; |
| 2042 | 2043 |
| 2043 if (extension_states->get_state(current) == INSTALLED) return true; | 2044 if (extension_states->get_state(current) == INSTALLED) return true; |
| 2044 // The current node has already been visited so there must be a | 2045 // The current node has already been visited so there must be a |
| 2045 // cycle in the dependency graph; fail. | 2046 // cycle in the dependency graph; fail. |
| 2046 if (extension_states->get_state(current) == VISITED) { | 2047 if (extension_states->get_state(current) == VISITED) { |
| 2047 v8::Utils::ReportApiFailure( | 2048 v8::Utils::ReportApiFailure( |
| 2048 "v8::Context::New()", "Circular extension dependency"); | 2049 "v8::Context::New()", "Circular extension dependency"); |
| 2049 return false; | 2050 return false; |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2354 return from + sizeof(NestingCounterType); | 2355 return from + sizeof(NestingCounterType); |
| 2355 } | 2356 } |
| 2356 | 2357 |
| 2357 | 2358 |
| 2358 // Called when the top-level V8 mutex is destroyed. | 2359 // Called when the top-level V8 mutex is destroyed. |
| 2359 void Bootstrapper::FreeThreadResources() { | 2360 void Bootstrapper::FreeThreadResources() { |
| 2360 ASSERT(!IsActive()); | 2361 ASSERT(!IsActive()); |
| 2361 } | 2362 } |
| 2362 | 2363 |
| 2363 } } // namespace v8::internal | 2364 } } // namespace v8::internal |
| OLD | NEW |