OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 // Hooks the given global proxy into the context. If the context was created | 193 // Hooks the given global proxy into the context. If the context was created |
194 // by deserialization then this will unhook the global proxy that was | 194 // by deserialization then this will unhook the global proxy that was |
195 // deserialized, leaving the GC to pick it up. | 195 // deserialized, leaving the GC to pick it up. |
196 void HookUpGlobalProxy(Handle<GlobalObject> inner_global, | 196 void HookUpGlobalProxy(Handle<GlobalObject> inner_global, |
197 Handle<JSGlobalProxy> global_proxy); | 197 Handle<JSGlobalProxy> global_proxy); |
198 // Similarly, we want to use the inner global that has been created by the | 198 // Similarly, we want to use the inner global that has been created by the |
199 // templates passed through the API. The inner global from the snapshot is | 199 // templates passed through the API. The inner global from the snapshot is |
200 // detached from the other objects in the snapshot. | 200 // detached from the other objects in the snapshot. |
201 void HookUpInnerGlobal(Handle<GlobalObject> inner_global); | 201 void HookUpInnerGlobal(Handle<GlobalObject> inner_global); |
202 // New context initialization. Used for creating a context from scratch. | 202 // New context initialization. Used for creating a context from scratch. |
203 bool InitializeGlobal(Handle<GlobalObject> inner_global, | 203 void InitializeGlobal(Handle<GlobalObject> inner_global, |
204 Handle<JSFunction> empty_function); | 204 Handle<JSFunction> empty_function); |
205 void InitializeExperimentalGlobal(); | 205 void InitializeExperimentalGlobal(); |
206 // Installs the contents of the native .js files on the global objects. | 206 // Installs the contents of the native .js files on the global objects. |
207 // Used for creating a context from scratch. | 207 // Used for creating a context from scratch. |
208 void InstallNativeFunctions(); | 208 void InstallNativeFunctions(); |
209 void InstallExperimentalNativeFunctions(); | 209 void InstallExperimentalNativeFunctions(); |
210 Handle<JSFunction> InstallInternalArray(Handle<JSBuiltinsObject> builtins, | 210 Handle<JSFunction> InstallInternalArray(Handle<JSBuiltinsObject> builtins, |
211 const char* name, | 211 const char* name, |
212 ElementsKind elements_kind); | 212 ElementsKind elements_kind); |
213 bool InstallNatives(); | 213 bool InstallNatives(); |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 attributes); | 822 attributes); |
823 // Set up the reference from the global object to the builtins object. | 823 // Set up the reference from the global object to the builtins object. |
824 JSGlobalObject::cast(*inner_global)->set_builtins(*builtins_global); | 824 JSGlobalObject::cast(*inner_global)->set_builtins(*builtins_global); |
825 TransferNamedProperties(inner_global_from_snapshot, inner_global); | 825 TransferNamedProperties(inner_global_from_snapshot, inner_global); |
826 TransferIndexedProperties(inner_global_from_snapshot, inner_global); | 826 TransferIndexedProperties(inner_global_from_snapshot, inner_global); |
827 } | 827 } |
828 | 828 |
829 | 829 |
830 // This is only called if we are not using snapshots. The equivalent | 830 // This is only called if we are not using snapshots. The equivalent |
831 // work in the snapshot case is done in HookUpInnerGlobal. | 831 // work in the snapshot case is done in HookUpInnerGlobal. |
832 bool Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, | 832 void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, |
833 Handle<JSFunction> empty_function) { | 833 Handle<JSFunction> empty_function) { |
834 // --- G l o b a l C o n t e x t --- | 834 // --- G l o b a l C o n t e x t --- |
835 // Use the empty function as closure (no scope info). | 835 // Use the empty function as closure (no scope info). |
836 native_context()->set_closure(*empty_function); | 836 native_context()->set_closure(*empty_function); |
837 native_context()->set_previous(NULL); | 837 native_context()->set_previous(NULL); |
838 // Set extension and global object. | 838 // Set extension and global object. |
839 native_context()->set_extension(*inner_global); | 839 native_context()->set_extension(*inner_global); |
840 native_context()->set_global_object(*inner_global); | 840 native_context()->set_global_object(*inner_global); |
841 // Security setup: Set the security token of the global object to | 841 // Security setup: Set the security token of the global object to |
842 // its the inner global. This makes the security check between two | 842 // its the inner global. This makes the security check between two |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 initial_map->set_prototype(*proto); | 1046 initial_map->set_prototype(*proto); |
1047 factory->SetRegExpIrregexpData(Handle<JSRegExp>::cast(proto), | 1047 factory->SetRegExpIrregexpData(Handle<JSRegExp>::cast(proto), |
1048 JSRegExp::IRREGEXP, factory->empty_string(), | 1048 JSRegExp::IRREGEXP, factory->empty_string(), |
1049 JSRegExp::Flags(0), 0); | 1049 JSRegExp::Flags(0), 0); |
1050 } | 1050 } |
1051 | 1051 |
1052 { // -- J S O N | 1052 { // -- J S O N |
1053 Handle<String> name = factory->NewStringFromAscii(CStrVector("JSON")); | 1053 Handle<String> name = factory->NewStringFromAscii(CStrVector("JSON")); |
1054 Handle<JSFunction> cons = factory->NewFunction(name, | 1054 Handle<JSFunction> cons = factory->NewFunction(name, |
1055 factory->the_hole_value()); | 1055 factory->the_hole_value()); |
1056 { MaybeObject* result = cons->SetInstancePrototype( | 1056 JSFunction::SetInstancePrototype(cons, |
1057 native_context()->initial_object_prototype()); | 1057 Handle<Object>(native_context()->initial_object_prototype(), isolate)); |
1058 if (result->IsFailure()) return false; | |
1059 } | |
1060 cons->SetInstanceClassName(*name); | 1058 cons->SetInstanceClassName(*name); |
1061 Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED); | 1059 Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED); |
1062 ASSERT(json_object->IsJSObject()); | 1060 ASSERT(json_object->IsJSObject()); |
1063 CHECK_NOT_EMPTY_HANDLE(isolate, | 1061 CHECK_NOT_EMPTY_HANDLE(isolate, |
1064 JSObject::SetLocalPropertyIgnoreAttributes( | 1062 JSObject::SetLocalPropertyIgnoreAttributes( |
1065 global, name, json_object, DONT_ENUM)); | 1063 global, name, json_object, DONT_ENUM)); |
1066 native_context()->set_json_object(*json_object); | 1064 native_context()->set_json_object(*json_object); |
1067 } | 1065 } |
1068 | 1066 |
1069 { // --- arguments_boilerplate_ | 1067 { // --- arguments_boilerplate_ |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1270 Handle<FixedArray> embedder_data = factory->NewFixedArray(2); | 1268 Handle<FixedArray> embedder_data = factory->NewFixedArray(2); |
1271 native_context()->set_embedder_data(*embedder_data); | 1269 native_context()->set_embedder_data(*embedder_data); |
1272 | 1270 |
1273 { | 1271 { |
1274 // Initialize the random seed slot. | 1272 // Initialize the random seed slot. |
1275 Handle<ByteArray> zeroed_byte_array( | 1273 Handle<ByteArray> zeroed_byte_array( |
1276 factory->NewByteArray(kRandomStateSize)); | 1274 factory->NewByteArray(kRandomStateSize)); |
1277 native_context()->set_random_seed(*zeroed_byte_array); | 1275 native_context()->set_random_seed(*zeroed_byte_array); |
1278 memset(zeroed_byte_array->GetDataStartAddress(), 0, kRandomStateSize); | 1276 memset(zeroed_byte_array->GetDataStartAddress(), 0, kRandomStateSize); |
1279 } | 1277 } |
1280 return true; | |
1281 } | 1278 } |
1282 | 1279 |
1283 | 1280 |
1284 Handle<JSFunction> Genesis::InstallTypedArray( | 1281 Handle<JSFunction> Genesis::InstallTypedArray( |
1285 const char* name, ElementsKind elementsKind) { | 1282 const char* name, ElementsKind elementsKind) { |
1286 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); | 1283 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); |
1287 Handle<JSFunction> result = InstallFunction(global, name, JS_TYPED_ARRAY_TYPE, | 1284 Handle<JSFunction> result = InstallFunction(global, name, JS_TYPED_ARRAY_TYPE, |
1288 JSTypedArray::kSize, isolate()->initial_object_prototype(), | 1285 JSTypedArray::kSize, isolate()->initial_object_prototype(), |
1289 Builtins::kIllegal, false, true); | 1286 Builtins::kIllegal, false, true); |
1290 | 1287 |
(...skipping 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2625 if (!ConfigureGlobalObjects(global_template)) return; | 2622 if (!ConfigureGlobalObjects(global_template)) return; |
2626 } else { | 2623 } else { |
2627 // We get here if there was no context snapshot. | 2624 // We get here if there was no context snapshot. |
2628 CreateRoots(); | 2625 CreateRoots(); |
2629 Handle<JSFunction> empty_function = CreateEmptyFunction(isolate); | 2626 Handle<JSFunction> empty_function = CreateEmptyFunction(isolate); |
2630 CreateStrictModeFunctionMaps(empty_function); | 2627 CreateStrictModeFunctionMaps(empty_function); |
2631 Handle<GlobalObject> inner_global; | 2628 Handle<GlobalObject> inner_global; |
2632 Handle<JSGlobalProxy> global_proxy = | 2629 Handle<JSGlobalProxy> global_proxy = |
2633 CreateNewGlobals(global_template, global_object, &inner_global); | 2630 CreateNewGlobals(global_template, global_object, &inner_global); |
2634 HookUpGlobalProxy(inner_global, global_proxy); | 2631 HookUpGlobalProxy(inner_global, global_proxy); |
2635 if (!InitializeGlobal(inner_global, empty_function)) return; | 2632 InitializeGlobal(inner_global, empty_function); |
2636 InstallJSFunctionResultCaches(); | 2633 InstallJSFunctionResultCaches(); |
2637 InitializeNormalizedMapCaches(); | 2634 InitializeNormalizedMapCaches(); |
2638 if (!InstallNatives()) return; | 2635 if (!InstallNatives()) return; |
2639 | 2636 |
2640 MakeFunctionInstancePrototypeWritable(); | 2637 MakeFunctionInstancePrototypeWritable(); |
2641 | 2638 |
2642 if (!ConfigureGlobalObjects(global_template)) return; | 2639 if (!ConfigureGlobalObjects(global_template)) return; |
2643 isolate->counters()->contexts_created_from_scratch()->Increment(); | 2640 isolate->counters()->contexts_created_from_scratch()->Increment(); |
2644 } | 2641 } |
2645 | 2642 |
(...skipping 27 matching lines...) Expand all Loading... |
2673 return from + sizeof(NestingCounterType); | 2670 return from + sizeof(NestingCounterType); |
2674 } | 2671 } |
2675 | 2672 |
2676 | 2673 |
2677 // Called when the top-level V8 mutex is destroyed. | 2674 // Called when the top-level V8 mutex is destroyed. |
2678 void Bootstrapper::FreeThreadResources() { | 2675 void Bootstrapper::FreeThreadResources() { |
2679 ASSERT(!IsActive()); | 2676 ASSERT(!IsActive()); |
2680 } | 2677 } |
2681 | 2678 |
2682 } } // namespace v8::internal | 2679 } } // namespace v8::internal |
OLD | NEW |