| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 // templates passed through the API. The inner global from the snapshot is | 221 // templates passed through the API. The inner global from the snapshot is |
| 222 // detached from the other objects in the snapshot. | 222 // detached from the other objects in the snapshot. |
| 223 void HookUpInnerGlobal(Handle<GlobalObject> inner_global); | 223 void HookUpInnerGlobal(Handle<GlobalObject> inner_global); |
| 224 // New context initialization. Used for creating a context from scratch. | 224 // New context initialization. Used for creating a context from scratch. |
| 225 void InitializeGlobal(Handle<GlobalObject> inner_global, | 225 void InitializeGlobal(Handle<GlobalObject> inner_global, |
| 226 Handle<JSFunction> empty_function); | 226 Handle<JSFunction> empty_function); |
| 227 // Installs the contents of the native .js files on the global objects. | 227 // Installs the contents of the native .js files on the global objects. |
| 228 // Used for creating a context from scratch. | 228 // Used for creating a context from scratch. |
| 229 void InstallNativeFunctions(); | 229 void InstallNativeFunctions(); |
| 230 bool InstallNatives(); | 230 bool InstallNatives(); |
| 231 void InstallJSFunctionResultCaches(); |
| 231 // Used both for deserialized and from-scratch contexts to add the extensions | 232 // Used both for deserialized and from-scratch contexts to add the extensions |
| 232 // provided. | 233 // provided. |
| 233 static bool InstallExtensions(Handle<Context> global_context, | 234 static bool InstallExtensions(Handle<Context> global_context, |
| 234 v8::ExtensionConfiguration* extensions); | 235 v8::ExtensionConfiguration* extensions); |
| 235 static bool InstallExtension(const char* name); | 236 static bool InstallExtension(const char* name); |
| 236 static bool InstallExtension(v8::RegisteredExtension* current); | 237 static bool InstallExtension(v8::RegisteredExtension* current); |
| 237 static void InstallSpecialObjects(Handle<Context> global_context); | 238 static void InstallSpecialObjects(Handle<Context> global_context); |
| 238 bool InstallJSBuiltins(Handle<JSBuiltinsObject> builtins); | 239 bool InstallJSBuiltins(Handle<JSBuiltinsObject> builtins); |
| 239 bool ConfigureApiObject(Handle<JSObject> object, | 240 bool ConfigureApiObject(Handle<JSObject> object, |
| 240 Handle<ObjectTemplateInfo> object_template); | 241 Handle<ObjectTemplateInfo> object_template); |
| (...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1294 } | 1295 } |
| 1295 | 1296 |
| 1296 #ifdef DEBUG | 1297 #ifdef DEBUG |
| 1297 builtins->Verify(); | 1298 builtins->Verify(); |
| 1298 #endif | 1299 #endif |
| 1299 | 1300 |
| 1300 return true; | 1301 return true; |
| 1301 } | 1302 } |
| 1302 | 1303 |
| 1303 | 1304 |
| 1305 // Do not forget to update macros.py with named constant |
| 1306 // of cache id. |
| 1307 #define JSFUNCTION_RESULT_CACHE_LIST(F) \ |
| 1308 F(16, global_context()->regexp_function()) |
| 1309 |
| 1310 |
| 1311 static FixedArray* CreateCache(int size, JSFunction* factory) { |
| 1312 // Caches are supposed to live for a long time, allocate in old space. |
| 1313 int array_size = JSFunctionResultCache::kEntriesIndex + 2 * size; |
| 1314 Handle<FixedArray> cache = |
| 1315 Factory::NewFixedArrayWithHoles(array_size, TENURED); |
| 1316 cache->set(JSFunctionResultCache::kFactoryIndex, factory); |
| 1317 cache->set(JSFunctionResultCache::kFingerIndex, |
| 1318 Smi::FromInt(JSFunctionResultCache::kEntriesIndex)); |
| 1319 cache->set(JSFunctionResultCache::kCacheSizeIndex, |
| 1320 Smi::FromInt(JSFunctionResultCache::kEntriesIndex)); |
| 1321 return *cache; |
| 1322 } |
| 1323 |
| 1324 |
| 1325 void Genesis::InstallJSFunctionResultCaches() { |
| 1326 const int kNumberOfCaches = 0 + |
| 1327 #define F(size, func) + 1 |
| 1328 JSFUNCTION_RESULT_CACHE_LIST(F) |
| 1329 #undef F |
| 1330 ; |
| 1331 |
| 1332 Handle<FixedArray> caches = Factory::NewFixedArray(kNumberOfCaches, TENURED); |
| 1333 |
| 1334 int index = 0; |
| 1335 #define F(size, func) caches->set(index++, CreateCache(size, func)); |
| 1336 JSFUNCTION_RESULT_CACHE_LIST(F) |
| 1337 #undef F |
| 1338 |
| 1339 global_context()->set_jsfunction_result_caches(*caches); |
| 1340 } |
| 1341 |
| 1342 |
| 1304 int BootstrapperActive::nesting_ = 0; | 1343 int BootstrapperActive::nesting_ = 0; |
| 1305 | 1344 |
| 1306 | 1345 |
| 1307 bool Bootstrapper::InstallExtensions(Handle<Context> global_context, | 1346 bool Bootstrapper::InstallExtensions(Handle<Context> global_context, |
| 1308 v8::ExtensionConfiguration* extensions) { | 1347 v8::ExtensionConfiguration* extensions) { |
| 1309 BootstrapperActive active; | 1348 BootstrapperActive active; |
| 1310 SaveContext saved_context; | 1349 SaveContext saved_context; |
| 1311 Top::set_context(*global_context); | 1350 Top::set_context(*global_context); |
| 1312 if (!Genesis::InstallExtensions(global_context, extensions)) return false; | 1351 if (!Genesis::InstallExtensions(global_context, extensions)) return false; |
| 1313 Genesis::InstallSpecialObjects(global_context); | 1352 Genesis::InstallSpecialObjects(global_context); |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1657 } else { | 1696 } else { |
| 1658 // We get here if there was no context snapshot. | 1697 // We get here if there was no context snapshot. |
| 1659 CreateRoots(); | 1698 CreateRoots(); |
| 1660 Handle<JSFunction> empty_function = CreateEmptyFunction(); | 1699 Handle<JSFunction> empty_function = CreateEmptyFunction(); |
| 1661 Handle<GlobalObject> inner_global; | 1700 Handle<GlobalObject> inner_global; |
| 1662 Handle<JSGlobalProxy> global_proxy = | 1701 Handle<JSGlobalProxy> global_proxy = |
| 1663 CreateNewGlobals(global_template, global_object, &inner_global); | 1702 CreateNewGlobals(global_template, global_object, &inner_global); |
| 1664 HookUpGlobalProxy(inner_global, global_proxy); | 1703 HookUpGlobalProxy(inner_global, global_proxy); |
| 1665 InitializeGlobal(inner_global, empty_function); | 1704 InitializeGlobal(inner_global, empty_function); |
| 1666 if (!InstallNatives()) return; | 1705 if (!InstallNatives()) return; |
| 1706 InstallJSFunctionResultCaches(); |
| 1667 | 1707 |
| 1668 MakeFunctionInstancePrototypeWritable(); | 1708 MakeFunctionInstancePrototypeWritable(); |
| 1669 | 1709 |
| 1670 if (!ConfigureGlobalObjects(global_template)) return; | 1710 if (!ConfigureGlobalObjects(global_template)) return; |
| 1671 i::Counters::contexts_created_from_scratch.Increment(); | 1711 i::Counters::contexts_created_from_scratch.Increment(); |
| 1672 } | 1712 } |
| 1673 | 1713 |
| 1674 result_ = global_context_; | 1714 result_ = global_context_; |
| 1675 } | 1715 } |
| 1676 | 1716 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1715 } | 1755 } |
| 1716 | 1756 |
| 1717 | 1757 |
| 1718 // Restore statics that are thread local. | 1758 // Restore statics that are thread local. |
| 1719 char* BootstrapperActive::RestoreState(char* from) { | 1759 char* BootstrapperActive::RestoreState(char* from) { |
| 1720 nesting_ = *reinterpret_cast<int*>(from); | 1760 nesting_ = *reinterpret_cast<int*>(from); |
| 1721 return from + sizeof(nesting_); | 1761 return from + sizeof(nesting_); |
| 1722 } | 1762 } |
| 1723 | 1763 |
| 1724 } } // namespace v8::internal | 1764 } } // namespace v8::internal |
| OLD | NEW |