| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 // deserialized, leaving the GC to pick it up. | 192 // deserialized, leaving the GC to pick it up. |
| 193 void HookUpGlobalProxy(Handle<GlobalObject> inner_global, | 193 void HookUpGlobalProxy(Handle<GlobalObject> inner_global, |
| 194 Handle<JSGlobalProxy> global_proxy); | 194 Handle<JSGlobalProxy> global_proxy); |
| 195 // Similarly, we want to use the inner global that has been created by the | 195 // Similarly, we want to use the inner global that has been created by the |
| 196 // templates passed through the API. The inner global from the snapshot is | 196 // templates passed through the API. The inner global from the snapshot is |
| 197 // detached from the other objects in the snapshot. | 197 // detached from the other objects in the snapshot. |
| 198 void HookUpInnerGlobal(Handle<GlobalObject> inner_global); | 198 void HookUpInnerGlobal(Handle<GlobalObject> inner_global); |
| 199 // New context initialization. Used for creating a context from scratch. | 199 // New context initialization. Used for creating a context from scratch. |
| 200 void InitializeGlobal(Handle<GlobalObject> inner_global, | 200 void InitializeGlobal(Handle<GlobalObject> inner_global, |
| 201 Handle<JSFunction> empty_function); | 201 Handle<JSFunction> empty_function); |
| 202 void InitializeExperimentalGlobal(); |
| 202 // Installs the contents of the native .js files on the global objects. | 203 // Installs the contents of the native .js files on the global objects. |
| 203 // Used for creating a context from scratch. | 204 // Used for creating a context from scratch. |
| 204 void InstallNativeFunctions(); | 205 void InstallNativeFunctions(); |
| 205 void InstallExperimentalNativeFunctions(); | 206 void InstallExperimentalNativeFunctions(); |
| 206 bool InstallNatives(); | 207 bool InstallNatives(); |
| 207 bool InstallExperimentalNatives(); | 208 bool InstallExperimentalNatives(); |
| 208 void InstallBuiltinFunctionIds(); | 209 void InstallBuiltinFunctionIds(); |
| 209 void InstallJSFunctionResultCaches(); | 210 void InstallJSFunctionResultCaches(); |
| 210 void InitializeNormalizedMapCaches(); | 211 void InitializeNormalizedMapCaches(); |
| 211 // Used both for deserialized and from-scratch contexts to add the extensions | 212 // Used both for deserialized and from-scratch contexts to add the extensions |
| (...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1183 } | 1184 } |
| 1184 | 1185 |
| 1185 // Initialize the out of memory slot. | 1186 // Initialize the out of memory slot. |
| 1186 global_context()->set_out_of_memory(heap->false_value()); | 1187 global_context()->set_out_of_memory(heap->false_value()); |
| 1187 | 1188 |
| 1188 // Initialize the data slot. | 1189 // Initialize the data slot. |
| 1189 global_context()->set_data(heap->undefined_value()); | 1190 global_context()->set_data(heap->undefined_value()); |
| 1190 } | 1191 } |
| 1191 | 1192 |
| 1192 | 1193 |
| 1194 void Genesis::InitializeExperimentalGlobal() { |
| 1195 Isolate* isolate = this->isolate(); |
| 1196 Handle<JSObject> global = Handle<JSObject>(global_context()->global()); |
| 1197 |
| 1198 // TODO (mstarzinger): Move this into Genesis::InitializeGlobal once we no |
| 1199 // longer need to live behind a flag, so WeakMap gets added to the snapshot. |
| 1200 if (FLAG_harmony_weakmaps) { // -- W e a k M a p |
| 1201 Handle<JSFunction> weakmap_fun = |
| 1202 InstallFunction(global, "WeakMap", JS_WEAK_MAP_TYPE, JSWeakMap::kSize, |
| 1203 isolate->initial_object_prototype(), |
| 1204 Builtins::kIllegal, true); |
| 1205 } |
| 1206 } |
| 1207 |
| 1208 |
| 1193 bool Genesis::CompileBuiltin(Isolate* isolate, int index) { | 1209 bool Genesis::CompileBuiltin(Isolate* isolate, int index) { |
| 1194 Vector<const char> name = Natives::GetScriptName(index); | 1210 Vector<const char> name = Natives::GetScriptName(index); |
| 1195 Handle<String> source_code = | 1211 Handle<String> source_code = |
| 1196 isolate->bootstrapper()->NativesSourceLookup(index); | 1212 isolate->bootstrapper()->NativesSourceLookup(index); |
| 1197 return CompileNative(name, source_code); | 1213 return CompileNative(name, source_code); |
| 1198 } | 1214 } |
| 1199 | 1215 |
| 1200 | 1216 |
| 1201 bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) { | 1217 bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) { |
| 1202 Vector<const char> name = ExperimentalNatives::GetScriptName(index); | 1218 Vector<const char> name = ExperimentalNatives::GetScriptName(index); |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1673 | 1689 |
| 1674 bool Genesis::InstallExperimentalNatives() { | 1690 bool Genesis::InstallExperimentalNatives() { |
| 1675 for (int i = ExperimentalNatives::GetDebuggerCount(); | 1691 for (int i = ExperimentalNatives::GetDebuggerCount(); |
| 1676 i < ExperimentalNatives::GetBuiltinsCount(); | 1692 i < ExperimentalNatives::GetBuiltinsCount(); |
| 1677 i++) { | 1693 i++) { |
| 1678 if (FLAG_harmony_proxies && | 1694 if (FLAG_harmony_proxies && |
| 1679 strcmp(ExperimentalNatives::GetScriptName(i).start(), | 1695 strcmp(ExperimentalNatives::GetScriptName(i).start(), |
| 1680 "native proxy.js") == 0) { | 1696 "native proxy.js") == 0) { |
| 1681 if (!CompileExperimentalBuiltin(isolate(), i)) return false; | 1697 if (!CompileExperimentalBuiltin(isolate(), i)) return false; |
| 1682 } | 1698 } |
| 1699 if (FLAG_harmony_weakmaps && |
| 1700 strcmp(ExperimentalNatives::GetScriptName(i).start(), |
| 1701 "native weakmap.js") == 0) { |
| 1702 if (!CompileExperimentalBuiltin(isolate(), i)) return false; |
| 1703 } |
| 1683 } | 1704 } |
| 1684 | 1705 |
| 1685 InstallExperimentalNativeFunctions(); | 1706 InstallExperimentalNativeFunctions(); |
| 1686 | 1707 |
| 1687 return true; | 1708 return true; |
| 1688 } | 1709 } |
| 1689 | 1710 |
| 1690 | 1711 |
| 1691 static Handle<JSObject> ResolveBuiltinIdHolder( | 1712 static Handle<JSObject> ResolveBuiltinIdHolder( |
| 1692 Handle<Context> global_context, | 1713 Handle<Context> global_context, |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2162 InstallJSFunctionResultCaches(); | 2183 InstallJSFunctionResultCaches(); |
| 2163 InitializeNormalizedMapCaches(); | 2184 InitializeNormalizedMapCaches(); |
| 2164 if (!InstallNatives()) return; | 2185 if (!InstallNatives()) return; |
| 2165 | 2186 |
| 2166 MakeFunctionInstancePrototypeWritable(); | 2187 MakeFunctionInstancePrototypeWritable(); |
| 2167 | 2188 |
| 2168 if (!ConfigureGlobalObjects(global_template)) return; | 2189 if (!ConfigureGlobalObjects(global_template)) return; |
| 2169 isolate->counters()->contexts_created_from_scratch()->Increment(); | 2190 isolate->counters()->contexts_created_from_scratch()->Increment(); |
| 2170 } | 2191 } |
| 2171 | 2192 |
| 2172 // Install experimental natives. | 2193 // Initialize experimental globals and install experimental natives. |
| 2194 InitializeExperimentalGlobal(); |
| 2173 if (!InstallExperimentalNatives()) return; | 2195 if (!InstallExperimentalNatives()) return; |
| 2174 | 2196 |
| 2175 result_ = global_context_; | 2197 result_ = global_context_; |
| 2176 } | 2198 } |
| 2177 | 2199 |
| 2178 | 2200 |
| 2179 // Support for thread preemption. | 2201 // Support for thread preemption. |
| 2180 | 2202 |
| 2181 // Reserve space for statics needing saving and restoring. | 2203 // Reserve space for statics needing saving and restoring. |
| 2182 int Bootstrapper::ArchiveSpacePerThread() { | 2204 int Bootstrapper::ArchiveSpacePerThread() { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2198 return from + sizeof(NestingCounterType); | 2220 return from + sizeof(NestingCounterType); |
| 2199 } | 2221 } |
| 2200 | 2222 |
| 2201 | 2223 |
| 2202 // Called when the top-level V8 mutex is destroyed. | 2224 // Called when the top-level V8 mutex is destroyed. |
| 2203 void Bootstrapper::FreeThreadResources() { | 2225 void Bootstrapper::FreeThreadResources() { |
| 2204 ASSERT(!IsActive()); | 2226 ASSERT(!IsActive()); |
| 2205 } | 2227 } |
| 2206 | 2228 |
| 2207 } } // namespace v8::internal | 2229 } } // namespace v8::internal |
| OLD | NEW |