OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "bootstrapper.h" | 5 #include "bootstrapper.h" |
6 | 6 |
7 #include "accessors.h" | 7 #include "accessors.h" |
8 #include "isolate-inl.h" | 8 #include "isolate-inl.h" |
9 #include "natives.h" | 9 #include "natives.h" |
10 #include "snapshot.h" | 10 #include "snapshot.h" |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 prototype, | 363 prototype, |
364 call_code, | 364 call_code, |
365 install_initial_map); | 365 install_initial_map); |
366 PropertyAttributes attributes; | 366 PropertyAttributes attributes; |
367 if (target->IsJSBuiltinsObject()) { | 367 if (target->IsJSBuiltinsObject()) { |
368 attributes = | 368 attributes = |
369 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 369 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
370 } else { | 370 } else { |
371 attributes = DONT_ENUM; | 371 attributes = DONT_ENUM; |
372 } | 372 } |
373 CHECK_NOT_EMPTY_HANDLE(isolate, | 373 JSObject::SetLocalPropertyIgnoreAttributes( |
374 JSObject::SetLocalPropertyIgnoreAttributes( | 374 target, internalized_name, function, attributes).Check(); |
375 target, internalized_name, function, attributes)); | |
376 if (set_instance_class_name) { | 375 if (set_instance_class_name) { |
377 function->shared()->set_instance_class_name(*internalized_name); | 376 function->shared()->set_instance_class_name(*internalized_name); |
378 } | 377 } |
379 function->shared()->set_native(true); | 378 function->shared()->set_native(true); |
380 return function; | 379 return function; |
381 } | 380 } |
382 | 381 |
383 | 382 |
384 void Genesis::SetFunctionInstanceDescriptor( | 383 void Genesis::SetFunctionInstanceDescriptor( |
385 Handle<Map> map, PrototypePropertyMode prototypeMode) { | 384 Handle<Map> map, PrototypePropertyMode prototypeMode) { |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin( | 715 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin( |
717 Builtins::kIllegal)); | 716 Builtins::kIllegal)); |
718 js_global_function = | 717 js_global_function = |
719 factory()->NewFunction(name, JS_GLOBAL_OBJECT_TYPE, | 718 factory()->NewFunction(name, JS_GLOBAL_OBJECT_TYPE, |
720 JSGlobalObject::kSize, code, true); | 719 JSGlobalObject::kSize, code, true); |
721 // Change the constructor property of the prototype of the | 720 // Change the constructor property of the prototype of the |
722 // hidden global function to refer to the Object function. | 721 // hidden global function to refer to the Object function. |
723 Handle<JSObject> prototype = | 722 Handle<JSObject> prototype = |
724 Handle<JSObject>( | 723 Handle<JSObject>( |
725 JSObject::cast(js_global_function->instance_prototype())); | 724 JSObject::cast(js_global_function->instance_prototype())); |
726 CHECK_NOT_EMPTY_HANDLE(isolate(), | 725 JSObject::SetLocalPropertyIgnoreAttributes( |
727 JSObject::SetLocalPropertyIgnoreAttributes( | 726 prototype, factory()->constructor_string(), |
728 prototype, factory()->constructor_string(), | 727 isolate()->object_function(), NONE).Check(); |
729 isolate()->object_function(), NONE)); | |
730 } else { | 728 } else { |
731 Handle<FunctionTemplateInfo> js_global_constructor( | 729 Handle<FunctionTemplateInfo> js_global_constructor( |
732 FunctionTemplateInfo::cast(js_global_template->constructor())); | 730 FunctionTemplateInfo::cast(js_global_template->constructor())); |
733 js_global_function = | 731 js_global_function = |
734 factory()->CreateApiFunction(js_global_constructor, | 732 factory()->CreateApiFunction(js_global_constructor, |
735 factory()->InnerGlobalObject); | 733 factory()->InnerGlobalObject); |
736 } | 734 } |
737 | 735 |
738 js_global_function->initial_map()->set_is_hidden_prototype(); | 736 js_global_function->initial_map()->set_is_hidden_prototype(); |
739 js_global_function->initial_map()->set_dictionary_map(true); | 737 js_global_function->initial_map()->set_dictionary_map(true); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 | 793 |
796 void Genesis::HookUpInnerGlobal(Handle<GlobalObject> inner_global) { | 794 void Genesis::HookUpInnerGlobal(Handle<GlobalObject> inner_global) { |
797 Handle<GlobalObject> inner_global_from_snapshot( | 795 Handle<GlobalObject> inner_global_from_snapshot( |
798 GlobalObject::cast(native_context()->extension())); | 796 GlobalObject::cast(native_context()->extension())); |
799 Handle<JSBuiltinsObject> builtins_global(native_context()->builtins()); | 797 Handle<JSBuiltinsObject> builtins_global(native_context()->builtins()); |
800 native_context()->set_extension(*inner_global); | 798 native_context()->set_extension(*inner_global); |
801 native_context()->set_global_object(*inner_global); | 799 native_context()->set_global_object(*inner_global); |
802 native_context()->set_security_token(*inner_global); | 800 native_context()->set_security_token(*inner_global); |
803 static const PropertyAttributes attributes = | 801 static const PropertyAttributes attributes = |
804 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); | 802 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); |
805 ForceSetProperty(builtins_global, | 803 Runtime::ForceSetObjectProperty(builtins_global, |
806 factory()->InternalizeOneByteString( | 804 factory()->InternalizeOneByteString( |
807 STATIC_ASCII_VECTOR("global")), | 805 STATIC_ASCII_VECTOR("global")), |
808 inner_global, | 806 inner_global, |
809 attributes); | 807 attributes).Assert(); |
810 // Set up the reference from the global object to the builtins object. | 808 // Set up the reference from the global object to the builtins object. |
811 JSGlobalObject::cast(*inner_global)->set_builtins(*builtins_global); | 809 JSGlobalObject::cast(*inner_global)->set_builtins(*builtins_global); |
812 TransferNamedProperties(inner_global_from_snapshot, inner_global); | 810 TransferNamedProperties(inner_global_from_snapshot, inner_global); |
813 TransferIndexedProperties(inner_global_from_snapshot, inner_global); | 811 TransferIndexedProperties(inner_global_from_snapshot, inner_global); |
814 } | 812 } |
815 | 813 |
816 | 814 |
817 // This is only called if we are not using snapshots. The equivalent | 815 // This is only called if we are not using snapshots. The equivalent |
818 // work in the snapshot case is done in HookUpInnerGlobal. | 816 // work in the snapshot case is done in HookUpInnerGlobal. |
819 void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, | 817 void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, |
820 Handle<JSFunction> empty_function) { | 818 Handle<JSFunction> empty_function) { |
821 // --- N a t i v e C o n t e x t --- | 819 // --- N a t i v e C o n t e x t --- |
822 // Use the empty function as closure (no scope info). | 820 // Use the empty function as closure (no scope info). |
823 native_context()->set_closure(*empty_function); | 821 native_context()->set_closure(*empty_function); |
824 native_context()->set_previous(NULL); | 822 native_context()->set_previous(NULL); |
825 // Set extension and global object. | 823 // Set extension and global object. |
826 native_context()->set_extension(*inner_global); | 824 native_context()->set_extension(*inner_global); |
827 native_context()->set_global_object(*inner_global); | 825 native_context()->set_global_object(*inner_global); |
828 // Security setup: Set the security token of the global object to | 826 // Security setup: Set the security token of the global object to |
829 // its the inner global. This makes the security check between two | 827 // its the inner global. This makes the security check between two |
830 // different contexts fail by default even in case of global | 828 // different contexts fail by default even in case of global |
831 // object reinitialization. | 829 // object reinitialization. |
832 native_context()->set_security_token(*inner_global); | 830 native_context()->set_security_token(*inner_global); |
833 | 831 |
834 Isolate* isolate = inner_global->GetIsolate(); | 832 Isolate* isolate = inner_global->GetIsolate(); |
835 Factory* factory = isolate->factory(); | 833 Factory* factory = isolate->factory(); |
836 Heap* heap = isolate->heap(); | 834 Heap* heap = isolate->heap(); |
837 | 835 |
838 Handle<String> object_name = factory->Object_string(); | 836 Handle<String> object_name = factory->Object_string(); |
839 CHECK_NOT_EMPTY_HANDLE(isolate, | 837 JSObject::SetLocalPropertyIgnoreAttributes( |
840 JSObject::SetLocalPropertyIgnoreAttributes( | 838 inner_global, object_name, |
841 inner_global, object_name, | 839 isolate->object_function(), DONT_ENUM).Check(); |
842 isolate->object_function(), DONT_ENUM)); | |
843 | 840 |
844 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); | 841 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); |
845 | 842 |
846 // Install global Function object | 843 // Install global Function object |
847 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, | 844 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, |
848 empty_function, Builtins::kIllegal, true, true); | 845 empty_function, Builtins::kIllegal, true, true); |
849 | 846 |
850 { // --- A r r a y --- | 847 { // --- A r r a y --- |
851 Handle<JSFunction> array_function = | 848 Handle<JSFunction> array_function = |
852 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, | 849 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 | 1035 |
1039 { // -- J S O N | 1036 { // -- J S O N |
1040 Handle<String> name = factory->InternalizeUtf8String("JSON"); | 1037 Handle<String> name = factory->InternalizeUtf8String("JSON"); |
1041 Handle<JSFunction> cons = factory->NewFunction(name, | 1038 Handle<JSFunction> cons = factory->NewFunction(name, |
1042 factory->the_hole_value()); | 1039 factory->the_hole_value()); |
1043 JSFunction::SetInstancePrototype(cons, | 1040 JSFunction::SetInstancePrototype(cons, |
1044 Handle<Object>(native_context()->initial_object_prototype(), isolate)); | 1041 Handle<Object>(native_context()->initial_object_prototype(), isolate)); |
1045 cons->SetInstanceClassName(*name); | 1042 cons->SetInstanceClassName(*name); |
1046 Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED); | 1043 Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED); |
1047 ASSERT(json_object->IsJSObject()); | 1044 ASSERT(json_object->IsJSObject()); |
1048 CHECK_NOT_EMPTY_HANDLE(isolate, | 1045 JSObject::SetLocalPropertyIgnoreAttributes( |
1049 JSObject::SetLocalPropertyIgnoreAttributes( | 1046 global, name, json_object, DONT_ENUM).Check(); |
1050 global, name, json_object, DONT_ENUM)); | |
1051 native_context()->set_json_object(*json_object); | 1047 native_context()->set_json_object(*json_object); |
1052 } | 1048 } |
1053 | 1049 |
1054 { // -- A r r a y B u f f e r | 1050 { // -- A r r a y B u f f e r |
1055 Handle<JSFunction> array_buffer_fun = | 1051 Handle<JSFunction> array_buffer_fun = |
1056 InstallFunction( | 1052 InstallFunction( |
1057 global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE, | 1053 global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE, |
1058 JSArrayBuffer::kSizeWithInternalFields, | 1054 JSArrayBuffer::kSizeWithInternalFields, |
1059 isolate->initial_object_prototype(), | 1055 isolate->initial_object_prototype(), |
1060 Builtins::kIllegal, true, true); | 1056 Builtins::kIllegal, true, true); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1100 code, | 1096 code, |
1101 false); | 1097 false); |
1102 ASSERT(!function->has_initial_map()); | 1098 ASSERT(!function->has_initial_map()); |
1103 function->shared()->set_instance_class_name(*arguments_string); | 1099 function->shared()->set_instance_class_name(*arguments_string); |
1104 function->shared()->set_expected_nof_properties(2); | 1100 function->shared()->set_expected_nof_properties(2); |
1105 Handle<JSObject> result = factory->NewJSObject(function); | 1101 Handle<JSObject> result = factory->NewJSObject(function); |
1106 | 1102 |
1107 native_context()->set_sloppy_arguments_boilerplate(*result); | 1103 native_context()->set_sloppy_arguments_boilerplate(*result); |
1108 // Note: length must be added as the first property and | 1104 // Note: length must be added as the first property and |
1109 // callee must be added as the second property. | 1105 // callee must be added as the second property. |
1110 CHECK_NOT_EMPTY_HANDLE(isolate, | 1106 JSObject::SetLocalPropertyIgnoreAttributes( |
1111 JSObject::SetLocalPropertyIgnoreAttributes( | 1107 result, factory->length_string(), |
1112 result, factory->length_string(), | 1108 factory->undefined_value(), DONT_ENUM, |
1113 factory->undefined_value(), DONT_ENUM, | 1109 Object::FORCE_TAGGED, FORCE_FIELD).Check(); |
1114 Object::FORCE_TAGGED, FORCE_FIELD)); | 1110 JSObject::SetLocalPropertyIgnoreAttributes( |
1115 CHECK_NOT_EMPTY_HANDLE(isolate, | 1111 result, factory->callee_string(), |
1116 JSObject::SetLocalPropertyIgnoreAttributes( | 1112 factory->undefined_value(), DONT_ENUM, |
1117 result, factory->callee_string(), | 1113 Object::FORCE_TAGGED, FORCE_FIELD).Check(); |
1118 factory->undefined_value(), DONT_ENUM, | |
1119 Object::FORCE_TAGGED, FORCE_FIELD)); | |
1120 | 1114 |
1121 #ifdef DEBUG | 1115 #ifdef DEBUG |
1122 LookupResult lookup(isolate); | 1116 LookupResult lookup(isolate); |
1123 result->LocalLookup(heap->callee_string(), &lookup); | 1117 result->LocalLookup(heap->callee_string(), &lookup); |
1124 ASSERT(lookup.IsField()); | 1118 ASSERT(lookup.IsField()); |
1125 ASSERT(lookup.GetFieldIndex().field_index() == Heap::kArgumentsCalleeIndex); | 1119 ASSERT(lookup.GetFieldIndex().field_index() == Heap::kArgumentsCalleeIndex); |
1126 | 1120 |
1127 result->LocalLookup(heap->length_string(), &lookup); | 1121 result->LocalLookup(heap->length_string(), &lookup); |
1128 ASSERT(lookup.IsField()); | 1122 ASSERT(lookup.IsField()); |
1129 ASSERT(lookup.GetFieldIndex().field_index() == Heap::kArgumentsLengthIndex); | 1123 ASSERT(lookup.GetFieldIndex().field_index() == Heap::kArgumentsLengthIndex); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 | 1204 |
1211 // Copy constructor from the sloppy arguments boilerplate. | 1205 // Copy constructor from the sloppy arguments boilerplate. |
1212 map->set_constructor( | 1206 map->set_constructor( |
1213 native_context()->sloppy_arguments_boilerplate()->map()->constructor()); | 1207 native_context()->sloppy_arguments_boilerplate()->map()->constructor()); |
1214 | 1208 |
1215 // Allocate the arguments boilerplate object. | 1209 // Allocate the arguments boilerplate object. |
1216 Handle<JSObject> result = factory->NewJSObjectFromMap(map); | 1210 Handle<JSObject> result = factory->NewJSObjectFromMap(map); |
1217 native_context()->set_strict_arguments_boilerplate(*result); | 1211 native_context()->set_strict_arguments_boilerplate(*result); |
1218 | 1212 |
1219 // Add length property only for strict mode boilerplate. | 1213 // Add length property only for strict mode boilerplate. |
1220 CHECK_NOT_EMPTY_HANDLE(isolate, | 1214 JSObject::SetLocalPropertyIgnoreAttributes( |
1221 JSObject::SetLocalPropertyIgnoreAttributes( | 1215 result, factory->length_string(), |
1222 result, factory->length_string(), | 1216 factory->undefined_value(), DONT_ENUM).Check(); |
1223 factory->undefined_value(), DONT_ENUM)); | |
1224 | 1217 |
1225 #ifdef DEBUG | 1218 #ifdef DEBUG |
1226 LookupResult lookup(isolate); | 1219 LookupResult lookup(isolate); |
1227 result->LocalLookup(heap->length_string(), &lookup); | 1220 result->LocalLookup(heap->length_string(), &lookup); |
1228 ASSERT(lookup.IsField()); | 1221 ASSERT(lookup.IsField()); |
1229 ASSERT(lookup.GetFieldIndex().field_index() == Heap::kArgumentsLengthIndex); | 1222 ASSERT(lookup.GetFieldIndex().field_index() == Heap::kArgumentsLengthIndex); |
1230 | 1223 |
1231 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex); | 1224 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex); |
1232 | 1225 |
1233 // Check the state of the object. | 1226 // Check the state of the object. |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1667 | 1660 |
1668 // Set up the 'global' properties of the builtins object. The | 1661 // Set up the 'global' properties of the builtins object. The |
1669 // 'global' property that refers to the global object is the only | 1662 // 'global' property that refers to the global object is the only |
1670 // way to get from code running in the builtins context to the | 1663 // way to get from code running in the builtins context to the |
1671 // global object. | 1664 // global object. |
1672 static const PropertyAttributes attributes = | 1665 static const PropertyAttributes attributes = |
1673 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); | 1666 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); |
1674 Handle<String> global_string = | 1667 Handle<String> global_string = |
1675 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("global")); | 1668 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("global")); |
1676 Handle<Object> global_obj(native_context()->global_object(), isolate()); | 1669 Handle<Object> global_obj(native_context()->global_object(), isolate()); |
1677 CHECK_NOT_EMPTY_HANDLE(isolate(), | 1670 JSObject::SetLocalPropertyIgnoreAttributes( |
1678 JSObject::SetLocalPropertyIgnoreAttributes( | 1671 builtins, global_string, global_obj, attributes).Check(); |
1679 builtins, global_string, global_obj, attributes)); | |
1680 Handle<String> builtins_string = | 1672 Handle<String> builtins_string = |
1681 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("builtins")); | 1673 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("builtins")); |
1682 CHECK_NOT_EMPTY_HANDLE(isolate(), | 1674 JSObject::SetLocalPropertyIgnoreAttributes( |
1683 JSObject::SetLocalPropertyIgnoreAttributes( | 1675 builtins, builtins_string, builtins, attributes).Check(); |
1684 builtins, builtins_string, builtins, attributes)); | |
1685 | 1676 |
1686 // Set up the reference from the global object to the builtins object. | 1677 // Set up the reference from the global object to the builtins object. |
1687 JSGlobalObject::cast(native_context()->global_object())-> | 1678 JSGlobalObject::cast(native_context()->global_object())-> |
1688 set_builtins(*builtins); | 1679 set_builtins(*builtins); |
1689 | 1680 |
1690 // Create a bridge function that has context in the native context. | 1681 // Create a bridge function that has context in the native context. |
1691 Handle<JSFunction> bridge = | 1682 Handle<JSFunction> bridge = |
1692 factory()->NewFunction(factory()->empty_string(), | 1683 factory()->NewFunction(factory()->empty_string(), |
1693 factory()->undefined_value()); | 1684 factory()->undefined_value()); |
1694 ASSERT(bridge->context() == *isolate()->native_context()); | 1685 ASSERT(bridge->context() == *isolate()->native_context()); |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2156 bool Genesis::InstallSpecialObjects(Handle<Context> native_context) { | 2147 bool Genesis::InstallSpecialObjects(Handle<Context> native_context) { |
2157 Isolate* isolate = native_context->GetIsolate(); | 2148 Isolate* isolate = native_context->GetIsolate(); |
2158 Factory* factory = isolate->factory(); | 2149 Factory* factory = isolate->factory(); |
2159 HandleScope scope(isolate); | 2150 HandleScope scope(isolate); |
2160 Handle<JSGlobalObject> global(JSGlobalObject::cast( | 2151 Handle<JSGlobalObject> global(JSGlobalObject::cast( |
2161 native_context->global_object())); | 2152 native_context->global_object())); |
2162 // Expose the natives in global if a name for it is specified. | 2153 // Expose the natives in global if a name for it is specified. |
2163 if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) { | 2154 if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) { |
2164 Handle<String> natives = | 2155 Handle<String> natives = |
2165 factory->InternalizeUtf8String(FLAG_expose_natives_as); | 2156 factory->InternalizeUtf8String(FLAG_expose_natives_as); |
2166 JSObject::SetLocalPropertyIgnoreAttributes( | 2157 RETURN_ON_EXCEPTION_VALUE( |
2167 global, natives, Handle<JSObject>(global->builtins()), DONT_ENUM); | 2158 isolate, |
2168 if (isolate->has_pending_exception()) return false; | 2159 JSObject::SetLocalPropertyIgnoreAttributes( |
| 2160 global, natives, Handle<JSObject>(global->builtins()), DONT_ENUM), |
| 2161 false); |
2169 } | 2162 } |
2170 | 2163 |
2171 Handle<Object> Error = GetProperty(global, "Error"); | 2164 Handle<Object> Error = GetProperty(global, "Error"); |
2172 if (Error->IsJSObject()) { | 2165 if (Error->IsJSObject()) { |
2173 Handle<String> name = factory->InternalizeOneByteString( | 2166 Handle<String> name = factory->InternalizeOneByteString( |
2174 STATIC_ASCII_VECTOR("stackTraceLimit")); | 2167 STATIC_ASCII_VECTOR("stackTraceLimit")); |
2175 Handle<Smi> stack_trace_limit( | 2168 Handle<Smi> stack_trace_limit( |
2176 Smi::FromInt(FLAG_stack_trace_limit), isolate); | 2169 Smi::FromInt(FLAG_stack_trace_limit), isolate); |
2177 JSObject::SetLocalPropertyIgnoreAttributes( | 2170 RETURN_ON_EXCEPTION_VALUE( |
2178 Handle<JSObject>::cast(Error), name, stack_trace_limit, NONE); | 2171 isolate, |
2179 if (isolate->has_pending_exception()) return false; | 2172 JSObject::SetLocalPropertyIgnoreAttributes( |
| 2173 Handle<JSObject>::cast(Error), name, stack_trace_limit, NONE), |
| 2174 false); |
2180 } | 2175 } |
2181 | 2176 |
2182 #ifdef ENABLE_DEBUGGER_SUPPORT | 2177 #ifdef ENABLE_DEBUGGER_SUPPORT |
2183 // Expose the debug global object in global if a name for it is specified. | 2178 // Expose the debug global object in global if a name for it is specified. |
2184 if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) { | 2179 if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) { |
2185 Debug* debug = isolate->debug(); | 2180 Debug* debug = isolate->debug(); |
2186 // If loading fails we just bail out without installing the | 2181 // If loading fails we just bail out without installing the |
2187 // debugger but without tanking the whole context. | 2182 // debugger but without tanking the whole context. |
2188 if (!debug->Load()) return true; | 2183 if (!debug->Load()) return true; |
2189 // Set the security token for the debugger context to the same as | 2184 // Set the security token for the debugger context to the same as |
2190 // the shell native context to allow calling between these (otherwise | 2185 // the shell native context to allow calling between these (otherwise |
2191 // exposing debug global object doesn't make much sense). | 2186 // exposing debug global object doesn't make much sense). |
2192 debug->debug_context()->set_security_token( | 2187 debug->debug_context()->set_security_token( |
2193 native_context->security_token()); | 2188 native_context->security_token()); |
2194 | 2189 |
2195 Handle<String> debug_string = | 2190 Handle<String> debug_string = |
2196 factory->InternalizeUtf8String(FLAG_expose_debug_as); | 2191 factory->InternalizeUtf8String(FLAG_expose_debug_as); |
2197 Handle<Object> global_proxy( | 2192 Handle<Object> global_proxy( |
2198 debug->debug_context()->global_proxy(), isolate); | 2193 debug->debug_context()->global_proxy(), isolate); |
2199 JSObject::SetLocalPropertyIgnoreAttributes( | 2194 RETURN_ON_EXCEPTION_VALUE( |
2200 global, debug_string, global_proxy, DONT_ENUM); | 2195 isolate, |
2201 if (isolate->has_pending_exception()) return false; | 2196 JSObject::SetLocalPropertyIgnoreAttributes( |
| 2197 global, debug_string, global_proxy, DONT_ENUM), |
| 2198 false); |
2202 } | 2199 } |
2203 #endif | 2200 #endif |
2204 return true; | 2201 return true; |
2205 } | 2202 } |
2206 | 2203 |
2207 | 2204 |
2208 static uint32_t Hash(RegisteredExtension* extension) { | 2205 static uint32_t Hash(RegisteredExtension* extension) { |
2209 return v8::internal::ComputePointerHash(extension); | 2206 return v8::internal::ComputePointerHash(extension); |
2210 } | 2207 } |
2211 | 2208 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2424 for (int i = 0; i < from->map()->NumberOfOwnDescriptors(); i++) { | 2421 for (int i = 0; i < from->map()->NumberOfOwnDescriptors(); i++) { |
2425 PropertyDetails details = descs->GetDetails(i); | 2422 PropertyDetails details = descs->GetDetails(i); |
2426 switch (details.type()) { | 2423 switch (details.type()) { |
2427 case FIELD: { | 2424 case FIELD: { |
2428 HandleScope inner(isolate()); | 2425 HandleScope inner(isolate()); |
2429 Handle<Name> key = Handle<Name>(descs->GetKey(i)); | 2426 Handle<Name> key = Handle<Name>(descs->GetKey(i)); |
2430 int index = descs->GetFieldIndex(i); | 2427 int index = descs->GetFieldIndex(i); |
2431 ASSERT(!descs->GetDetails(i).representation().IsDouble()); | 2428 ASSERT(!descs->GetDetails(i).representation().IsDouble()); |
2432 Handle<Object> value = Handle<Object>(from->RawFastPropertyAt(index), | 2429 Handle<Object> value = Handle<Object>(from->RawFastPropertyAt(index), |
2433 isolate()); | 2430 isolate()); |
2434 CHECK_NOT_EMPTY_HANDLE(isolate(), | 2431 JSObject::SetLocalPropertyIgnoreAttributes( |
2435 JSObject::SetLocalPropertyIgnoreAttributes( | 2432 to, key, value, details.attributes()).Check(); |
2436 to, key, value, details.attributes())); | |
2437 break; | 2433 break; |
2438 } | 2434 } |
2439 case CONSTANT: { | 2435 case CONSTANT: { |
2440 HandleScope inner(isolate()); | 2436 HandleScope inner(isolate()); |
2441 Handle<Name> key = Handle<Name>(descs->GetKey(i)); | 2437 Handle<Name> key = Handle<Name>(descs->GetKey(i)); |
2442 Handle<Object> constant(descs->GetConstant(i), isolate()); | 2438 Handle<Object> constant(descs->GetConstant(i), isolate()); |
2443 CHECK_NOT_EMPTY_HANDLE(isolate(), | 2439 JSObject::SetLocalPropertyIgnoreAttributes( |
2444 JSObject::SetLocalPropertyIgnoreAttributes( | 2440 to, key, constant, details.attributes()).Check(); |
2445 to, key, constant, details.attributes())); | |
2446 break; | 2441 break; |
2447 } | 2442 } |
2448 case CALLBACKS: { | 2443 case CALLBACKS: { |
2449 LookupResult result(isolate()); | 2444 LookupResult result(isolate()); |
2450 to->LocalLookup(descs->GetKey(i), &result); | 2445 to->LocalLookup(descs->GetKey(i), &result); |
2451 // If the property is already there we skip it | 2446 // If the property is already there we skip it |
2452 if (result.IsFound()) continue; | 2447 if (result.IsFound()) continue; |
2453 HandleScope inner(isolate()); | 2448 HandleScope inner(isolate()); |
2454 ASSERT(!to->HasFastProperties()); | 2449 ASSERT(!to->HasFastProperties()); |
2455 // Add to dictionary. | 2450 // Add to dictionary. |
(...skipping 29 matching lines...) Expand all Loading... |
2485 // Set the property. | 2480 // Set the property. |
2486 Handle<Name> key = Handle<Name>(Name::cast(raw_key)); | 2481 Handle<Name> key = Handle<Name>(Name::cast(raw_key)); |
2487 Handle<Object> value = Handle<Object>(properties->ValueAt(i), | 2482 Handle<Object> value = Handle<Object>(properties->ValueAt(i), |
2488 isolate()); | 2483 isolate()); |
2489 ASSERT(!value->IsCell()); | 2484 ASSERT(!value->IsCell()); |
2490 if (value->IsPropertyCell()) { | 2485 if (value->IsPropertyCell()) { |
2491 value = Handle<Object>(PropertyCell::cast(*value)->value(), | 2486 value = Handle<Object>(PropertyCell::cast(*value)->value(), |
2492 isolate()); | 2487 isolate()); |
2493 } | 2488 } |
2494 PropertyDetails details = properties->DetailsAt(i); | 2489 PropertyDetails details = properties->DetailsAt(i); |
2495 CHECK_NOT_EMPTY_HANDLE(isolate(), | 2490 JSObject::SetLocalPropertyIgnoreAttributes( |
2496 JSObject::SetLocalPropertyIgnoreAttributes( | 2491 to, key, value, details.attributes()).Check(); |
2497 to, key, value, details.attributes())); | |
2498 } | 2492 } |
2499 } | 2493 } |
2500 } | 2494 } |
2501 } | 2495 } |
2502 | 2496 |
2503 | 2497 |
2504 void Genesis::TransferIndexedProperties(Handle<JSObject> from, | 2498 void Genesis::TransferIndexedProperties(Handle<JSObject> from, |
2505 Handle<JSObject> to) { | 2499 Handle<JSObject> to) { |
2506 // Cloning the elements array is sufficient. | 2500 // Cloning the elements array is sufficient. |
2507 Handle<FixedArray> from_elements = | 2501 Handle<FixedArray> from_elements = |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2644 | 2638 |
2645 do { | 2639 do { |
2646 isolate->random_number_generator()->NextBytes(state, num_bytes); | 2640 isolate->random_number_generator()->NextBytes(state, num_bytes); |
2647 } while (state[0] == 0 || state[1] == 0); | 2641 } while (state[0] == 0 || state[1] == 0); |
2648 | 2642 |
2649 v8::Local<v8::ArrayBuffer> buffer = v8::ArrayBuffer::New( | 2643 v8::Local<v8::ArrayBuffer> buffer = v8::ArrayBuffer::New( |
2650 reinterpret_cast<v8::Isolate*>(isolate), state, num_bytes); | 2644 reinterpret_cast<v8::Isolate*>(isolate), state, num_bytes); |
2651 Utils::OpenHandle(*buffer)->set_should_be_freed(true); | 2645 Utils::OpenHandle(*buffer)->set_should_be_freed(true); |
2652 v8::Local<v8::Uint32Array> ta = v8::Uint32Array::New(buffer, 0, num_elems); | 2646 v8::Local<v8::Uint32Array> ta = v8::Uint32Array::New(buffer, 0, num_elems); |
2653 Handle<JSBuiltinsObject> builtins(native_context()->builtins()); | 2647 Handle<JSBuiltinsObject> builtins(native_context()->builtins()); |
2654 ForceSetProperty(builtins, | 2648 Runtime::ForceSetObjectProperty(builtins, |
2655 factory()->InternalizeOneByteString( | 2649 factory()->InternalizeOneByteString( |
2656 STATIC_ASCII_VECTOR("rngstate")), | 2650 STATIC_ASCII_VECTOR("rngstate")), |
2657 Utils::OpenHandle(*ta), | 2651 Utils::OpenHandle(*ta), |
2658 NONE); | 2652 NONE).Assert(); |
2659 | 2653 |
2660 // Initialize trigonometric lookup tables and constants. | 2654 // Initialize trigonometric lookup tables and constants. |
2661 const int table_num_bytes = TrigonometricLookupTable::table_num_bytes(); | 2655 const int table_num_bytes = TrigonometricLookupTable::table_num_bytes(); |
2662 v8::Local<v8::ArrayBuffer> sin_buffer = v8::ArrayBuffer::New( | 2656 v8::Local<v8::ArrayBuffer> sin_buffer = v8::ArrayBuffer::New( |
2663 reinterpret_cast<v8::Isolate*>(isolate), | 2657 reinterpret_cast<v8::Isolate*>(isolate), |
2664 TrigonometricLookupTable::sin_table(), table_num_bytes); | 2658 TrigonometricLookupTable::sin_table(), table_num_bytes); |
2665 v8::Local<v8::ArrayBuffer> cos_buffer = v8::ArrayBuffer::New( | 2659 v8::Local<v8::ArrayBuffer> cos_buffer = v8::ArrayBuffer::New( |
2666 reinterpret_cast<v8::Isolate*>(isolate), | 2660 reinterpret_cast<v8::Isolate*>(isolate), |
2667 TrigonometricLookupTable::cos_x_interval_table(), table_num_bytes); | 2661 TrigonometricLookupTable::cos_x_interval_table(), table_num_bytes); |
2668 v8::Local<v8::Float64Array> sin_table = v8::Float64Array::New( | 2662 v8::Local<v8::Float64Array> sin_table = v8::Float64Array::New( |
2669 sin_buffer, 0, TrigonometricLookupTable::table_size()); | 2663 sin_buffer, 0, TrigonometricLookupTable::table_size()); |
2670 v8::Local<v8::Float64Array> cos_table = v8::Float64Array::New( | 2664 v8::Local<v8::Float64Array> cos_table = v8::Float64Array::New( |
2671 cos_buffer, 0, TrigonometricLookupTable::table_size()); | 2665 cos_buffer, 0, TrigonometricLookupTable::table_size()); |
2672 | 2666 |
2673 ForceSetProperty(builtins, | 2667 Runtime::ForceSetObjectProperty(builtins, |
2674 factory()->InternalizeOneByteString( | 2668 factory()->InternalizeOneByteString( |
2675 STATIC_ASCII_VECTOR("kSinTable")), | 2669 STATIC_ASCII_VECTOR("kSinTable")), |
2676 Utils::OpenHandle(*sin_table), | 2670 Utils::OpenHandle(*sin_table), |
2677 NONE); | 2671 NONE).Assert(); |
2678 ForceSetProperty(builtins, | 2672 Runtime::ForceSetObjectProperty( |
2679 factory()->InternalizeOneByteString( | 2673 builtins, |
2680 STATIC_ASCII_VECTOR("kCosXIntervalTable")), | 2674 factory()->InternalizeOneByteString( |
2681 Utils::OpenHandle(*cos_table), | 2675 STATIC_ASCII_VECTOR("kCosXIntervalTable")), |
2682 NONE); | 2676 Utils::OpenHandle(*cos_table), |
2683 ForceSetProperty(builtins, | 2677 NONE).Assert(); |
2684 factory()->InternalizeOneByteString( | 2678 Runtime::ForceSetObjectProperty( |
2685 STATIC_ASCII_VECTOR("kSamples")), | 2679 builtins, |
2686 factory()->NewHeapNumber( | 2680 factory()->InternalizeOneByteString( |
2687 TrigonometricLookupTable::samples()), | 2681 STATIC_ASCII_VECTOR("kSamples")), |
2688 NONE); | 2682 factory()->NewHeapNumber( |
2689 ForceSetProperty(builtins, | 2683 TrigonometricLookupTable::samples()), |
2690 factory()->InternalizeOneByteString( | 2684 NONE).Assert(); |
2691 STATIC_ASCII_VECTOR("kIndexConvert")), | 2685 Runtime::ForceSetObjectProperty( |
2692 factory()->NewHeapNumber( | 2686 builtins, |
2693 TrigonometricLookupTable::samples_over_pi_half()), | 2687 factory()->InternalizeOneByteString( |
2694 NONE); | 2688 STATIC_ASCII_VECTOR("kIndexConvert")), |
| 2689 factory()->NewHeapNumber( |
| 2690 TrigonometricLookupTable::samples_over_pi_half()), |
| 2691 NONE).Assert(); |
2695 } | 2692 } |
2696 | 2693 |
2697 result_ = native_context(); | 2694 result_ = native_context(); |
2698 } | 2695 } |
2699 | 2696 |
2700 | 2697 |
2701 // Support for thread preemption. | 2698 // Support for thread preemption. |
2702 | 2699 |
2703 // Reserve space for statics needing saving and restoring. | 2700 // Reserve space for statics needing saving and restoring. |
2704 int Bootstrapper::ArchiveSpacePerThread() { | 2701 int Bootstrapper::ArchiveSpacePerThread() { |
(...skipping 15 matching lines...) Expand all Loading... |
2720 return from + sizeof(NestingCounterType); | 2717 return from + sizeof(NestingCounterType); |
2721 } | 2718 } |
2722 | 2719 |
2723 | 2720 |
2724 // Called when the top-level V8 mutex is destroyed. | 2721 // Called when the top-level V8 mutex is destroyed. |
2725 void Bootstrapper::FreeThreadResources() { | 2722 void Bootstrapper::FreeThreadResources() { |
2726 ASSERT(!IsActive()); | 2723 ASSERT(!IsActive()); |
2727 } | 2724 } |
2728 | 2725 |
2729 } } // namespace v8::internal | 2726 } } // namespace v8::internal |
OLD | NEW |