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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 prototype, | 371 prototype, |
372 call_code, | 372 call_code, |
373 is_ecma_native); | 373 is_ecma_native); |
374 PropertyAttributes attributes; | 374 PropertyAttributes attributes; |
375 if (target->IsJSBuiltinsObject()) { | 375 if (target->IsJSBuiltinsObject()) { |
376 attributes = | 376 attributes = |
377 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 377 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
378 } else { | 378 } else { |
379 attributes = DONT_ENUM; | 379 attributes = DONT_ENUM; |
380 } | 380 } |
381 SetLocalPropertyNoThrow(target, symbol, function, attributes); | 381 CHECK_NOT_EMPTY_HANDLE(isolate, |
| 382 JSObject::SetLocalPropertyIgnoreAttributes( |
| 383 target, symbol, function, attributes)); |
382 if (is_ecma_native) { | 384 if (is_ecma_native) { |
383 function->shared()->set_instance_class_name(*symbol); | 385 function->shared()->set_instance_class_name(*symbol); |
384 } | 386 } |
385 function->shared()->set_native(true); | 387 function->shared()->set_native(true); |
386 return function; | 388 return function; |
387 } | 389 } |
388 | 390 |
389 | 391 |
390 Handle<DescriptorArray> Genesis::ComputeFunctionInstanceDescriptor( | 392 Handle<DescriptorArray> Genesis::ComputeFunctionInstanceDescriptor( |
391 PrototypePropertyMode prototypeMode) { | 393 PrototypePropertyMode prototypeMode) { |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 throw_type_error_function = | 595 throw_type_error_function = |
594 factory()->NewFunctionWithoutPrototype(name, CLASSIC_MODE); | 596 factory()->NewFunctionWithoutPrototype(name, CLASSIC_MODE); |
595 Handle<Code> code(isolate()->builtins()->builtin( | 597 Handle<Code> code(isolate()->builtins()->builtin( |
596 Builtins::kStrictModePoisonPill)); | 598 Builtins::kStrictModePoisonPill)); |
597 throw_type_error_function->set_map( | 599 throw_type_error_function->set_map( |
598 global_context()->function_map()); | 600 global_context()->function_map()); |
599 throw_type_error_function->set_code(*code); | 601 throw_type_error_function->set_code(*code); |
600 throw_type_error_function->shared()->set_code(*code); | 602 throw_type_error_function->shared()->set_code(*code); |
601 throw_type_error_function->shared()->DontAdaptArguments(); | 603 throw_type_error_function->shared()->DontAdaptArguments(); |
602 | 604 |
603 PreventExtensions(throw_type_error_function); | 605 JSObject::PreventExtensions(throw_type_error_function); |
604 } | 606 } |
605 return throw_type_error_function; | 607 return throw_type_error_function; |
606 } | 608 } |
607 | 609 |
608 | 610 |
609 Handle<Map> Genesis::CreateStrictModeFunctionMap( | 611 Handle<Map> Genesis::CreateStrictModeFunctionMap( |
610 PrototypePropertyMode prototype_mode, | 612 PrototypePropertyMode prototype_mode, |
611 Handle<JSFunction> empty_function, | 613 Handle<JSFunction> empty_function, |
612 Handle<FixedArray> arguments_callbacks, | 614 Handle<FixedArray> arguments_callbacks, |
613 Handle<FixedArray> caller_callbacks) { | 615 Handle<FixedArray> caller_callbacks) { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin( | 748 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin( |
747 Builtins::kIllegal)); | 749 Builtins::kIllegal)); |
748 js_global_function = | 750 js_global_function = |
749 factory()->NewFunction(name, JS_GLOBAL_OBJECT_TYPE, | 751 factory()->NewFunction(name, JS_GLOBAL_OBJECT_TYPE, |
750 JSGlobalObject::kSize, code, true); | 752 JSGlobalObject::kSize, code, true); |
751 // Change the constructor property of the prototype of the | 753 // Change the constructor property of the prototype of the |
752 // hidden global function to refer to the Object function. | 754 // hidden global function to refer to the Object function. |
753 Handle<JSObject> prototype = | 755 Handle<JSObject> prototype = |
754 Handle<JSObject>( | 756 Handle<JSObject>( |
755 JSObject::cast(js_global_function->instance_prototype())); | 757 JSObject::cast(js_global_function->instance_prototype())); |
756 SetLocalPropertyNoThrow( | 758 CHECK_NOT_EMPTY_HANDLE(isolate(), |
757 prototype, | 759 JSObject::SetLocalPropertyIgnoreAttributes( |
758 factory()->constructor_symbol(), | 760 prototype, factory()->constructor_symbol(), |
759 isolate()->object_function(), | 761 isolate()->object_function(), NONE)); |
760 NONE); | |
761 } else { | 762 } else { |
762 Handle<FunctionTemplateInfo> js_global_constructor( | 763 Handle<FunctionTemplateInfo> js_global_constructor( |
763 FunctionTemplateInfo::cast(js_global_template->constructor())); | 764 FunctionTemplateInfo::cast(js_global_template->constructor())); |
764 js_global_function = | 765 js_global_function = |
765 factory()->CreateApiFunction(js_global_constructor, | 766 factory()->CreateApiFunction(js_global_constructor, |
766 factory()->InnerGlobalObject); | 767 factory()->InnerGlobalObject); |
767 } | 768 } |
768 | 769 |
769 js_global_function->initial_map()->set_is_hidden_prototype(); | 770 js_global_function->initial_map()->set_is_hidden_prototype(); |
770 Handle<GlobalObject> inner_global = | 771 Handle<GlobalObject> inner_global = |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 // its the inner global. This makes the security check between two | 857 // its the inner global. This makes the security check between two |
857 // different contexts fail by default even in case of global | 858 // different contexts fail by default even in case of global |
858 // object reinitialization. | 859 // object reinitialization. |
859 global_context()->set_security_token(*inner_global); | 860 global_context()->set_security_token(*inner_global); |
860 | 861 |
861 Isolate* isolate = inner_global->GetIsolate(); | 862 Isolate* isolate = inner_global->GetIsolate(); |
862 Factory* factory = isolate->factory(); | 863 Factory* factory = isolate->factory(); |
863 Heap* heap = isolate->heap(); | 864 Heap* heap = isolate->heap(); |
864 | 865 |
865 Handle<String> object_name = Handle<String>(heap->Object_symbol()); | 866 Handle<String> object_name = Handle<String>(heap->Object_symbol()); |
866 SetLocalPropertyNoThrow(inner_global, object_name, | 867 CHECK_NOT_EMPTY_HANDLE(isolate, |
867 isolate->object_function(), DONT_ENUM); | 868 JSObject::SetLocalPropertyIgnoreAttributes( |
| 869 inner_global, object_name, |
| 870 isolate->object_function(), DONT_ENUM)); |
868 | 871 |
869 Handle<JSObject> global = Handle<JSObject>(global_context()->global()); | 872 Handle<JSObject> global = Handle<JSObject>(global_context()->global()); |
870 | 873 |
871 // Install global Function object | 874 // Install global Function object |
872 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, | 875 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, |
873 empty_function, Builtins::kIllegal, true); // ECMA native. | 876 empty_function, Builtins::kIllegal, true); // ECMA native. |
874 | 877 |
875 { // --- A r r a y --- | 878 { // --- A r r a y --- |
876 Handle<JSFunction> array_function = | 879 Handle<JSFunction> array_function = |
877 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, | 880 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 Smi::FromInt(0), | 1042 Smi::FromInt(0), |
1040 SKIP_WRITE_BARRIER); // It's a Smi. | 1043 SKIP_WRITE_BARRIER); // It's a Smi. |
1041 initial_map->set_prototype(*proto); | 1044 initial_map->set_prototype(*proto); |
1042 factory->SetRegExpIrregexpData(Handle<JSRegExp>::cast(proto), | 1045 factory->SetRegExpIrregexpData(Handle<JSRegExp>::cast(proto), |
1043 JSRegExp::IRREGEXP, factory->empty_string(), | 1046 JSRegExp::IRREGEXP, factory->empty_string(), |
1044 JSRegExp::Flags(0), 0); | 1047 JSRegExp::Flags(0), 0); |
1045 } | 1048 } |
1046 | 1049 |
1047 { // -- J S O N | 1050 { // -- J S O N |
1048 Handle<String> name = factory->NewStringFromAscii(CStrVector("JSON")); | 1051 Handle<String> name = factory->NewStringFromAscii(CStrVector("JSON")); |
1049 Handle<JSFunction> cons = factory->NewFunction( | 1052 Handle<JSFunction> cons = factory->NewFunction(name, |
1050 name, | 1053 factory->the_hole_value()); |
1051 factory->the_hole_value()); | |
1052 cons->SetInstancePrototype(global_context()->initial_object_prototype()); | 1054 cons->SetInstancePrototype(global_context()->initial_object_prototype()); |
1053 cons->SetInstanceClassName(*name); | 1055 cons->SetInstanceClassName(*name); |
1054 Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED); | 1056 Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED); |
1055 ASSERT(json_object->IsJSObject()); | 1057 ASSERT(json_object->IsJSObject()); |
1056 SetLocalPropertyNoThrow(global, name, json_object, DONT_ENUM); | 1058 CHECK_NOT_EMPTY_HANDLE(isolate, |
| 1059 JSObject::SetLocalPropertyIgnoreAttributes( |
| 1060 global, name, json_object, DONT_ENUM)); |
1057 global_context()->set_json_object(*json_object); | 1061 global_context()->set_json_object(*json_object); |
1058 } | 1062 } |
1059 | 1063 |
1060 { // --- arguments_boilerplate_ | 1064 { // --- arguments_boilerplate_ |
1061 // Make sure we can recognize argument objects at runtime. | 1065 // Make sure we can recognize argument objects at runtime. |
1062 // This is done by introducing an anonymous function with | 1066 // This is done by introducing an anonymous function with |
1063 // class_name equals 'Arguments'. | 1067 // class_name equals 'Arguments'. |
1064 Handle<String> symbol = factory->LookupAsciiSymbol("Arguments"); | 1068 Handle<String> symbol = factory->LookupAsciiSymbol("Arguments"); |
1065 Handle<Code> code = Handle<Code>( | 1069 Handle<Code> code = Handle<Code>( |
1066 isolate->builtins()->builtin(Builtins::kIllegal)); | 1070 isolate->builtins()->builtin(Builtins::kIllegal)); |
1067 Handle<JSObject> prototype = | 1071 Handle<JSObject> prototype = |
1068 Handle<JSObject>( | 1072 Handle<JSObject>( |
1069 JSObject::cast(global_context()->object_function()->prototype())); | 1073 JSObject::cast(global_context()->object_function()->prototype())); |
1070 | 1074 |
1071 Handle<JSFunction> function = | 1075 Handle<JSFunction> function = |
1072 factory->NewFunctionWithPrototype(symbol, | 1076 factory->NewFunctionWithPrototype(symbol, |
1073 JS_OBJECT_TYPE, | 1077 JS_OBJECT_TYPE, |
1074 JSObject::kHeaderSize, | 1078 JSObject::kHeaderSize, |
1075 prototype, | 1079 prototype, |
1076 code, | 1080 code, |
1077 false); | 1081 false); |
1078 ASSERT(!function->has_initial_map()); | 1082 ASSERT(!function->has_initial_map()); |
1079 function->shared()->set_instance_class_name(*symbol); | 1083 function->shared()->set_instance_class_name(*symbol); |
1080 function->shared()->set_expected_nof_properties(2); | 1084 function->shared()->set_expected_nof_properties(2); |
1081 Handle<JSObject> result = factory->NewJSObject(function); | 1085 Handle<JSObject> result = factory->NewJSObject(function); |
1082 | 1086 |
1083 global_context()->set_arguments_boilerplate(*result); | 1087 global_context()->set_arguments_boilerplate(*result); |
1084 // Note: length must be added as the first property and | 1088 // Note: length must be added as the first property and |
1085 // callee must be added as the second property. | 1089 // callee must be added as the second property. |
1086 SetLocalPropertyNoThrow(result, factory->length_symbol(), | 1090 CHECK_NOT_EMPTY_HANDLE(isolate, |
1087 factory->undefined_value(), | 1091 JSObject::SetLocalPropertyIgnoreAttributes( |
1088 DONT_ENUM); | 1092 result, factory->length_symbol(), |
1089 SetLocalPropertyNoThrow(result, factory->callee_symbol(), | 1093 factory->undefined_value(), DONT_ENUM)); |
1090 factory->undefined_value(), | 1094 CHECK_NOT_EMPTY_HANDLE(isolate, |
1091 DONT_ENUM); | 1095 JSObject::SetLocalPropertyIgnoreAttributes( |
| 1096 result, factory->callee_symbol(), |
| 1097 factory->undefined_value(), DONT_ENUM)); |
1092 | 1098 |
1093 #ifdef DEBUG | 1099 #ifdef DEBUG |
1094 LookupResult lookup(isolate); | 1100 LookupResult lookup(isolate); |
1095 result->LocalLookup(heap->callee_symbol(), &lookup); | 1101 result->LocalLookup(heap->callee_symbol(), &lookup); |
1096 ASSERT(lookup.IsProperty() && (lookup.type() == FIELD)); | 1102 ASSERT(lookup.IsProperty() && (lookup.type() == FIELD)); |
1097 ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsCalleeIndex); | 1103 ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsCalleeIndex); |
1098 | 1104 |
1099 result->LocalLookup(heap->length_symbol(), &lookup); | 1105 result->LocalLookup(heap->length_symbol(), &lookup); |
1100 ASSERT(lookup.IsProperty() && (lookup.type() == FIELD)); | 1106 ASSERT(lookup.IsProperty() && (lookup.type() == FIELD)); |
1101 ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsLengthIndex); | 1107 ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsLengthIndex); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1176 | 1182 |
1177 // Copy constructor from the non-strict arguments boilerplate. | 1183 // Copy constructor from the non-strict arguments boilerplate. |
1178 map->set_constructor( | 1184 map->set_constructor( |
1179 global_context()->arguments_boilerplate()->map()->constructor()); | 1185 global_context()->arguments_boilerplate()->map()->constructor()); |
1180 | 1186 |
1181 // Allocate the arguments boilerplate object. | 1187 // Allocate the arguments boilerplate object. |
1182 Handle<JSObject> result = factory->NewJSObjectFromMap(map); | 1188 Handle<JSObject> result = factory->NewJSObjectFromMap(map); |
1183 global_context()->set_strict_mode_arguments_boilerplate(*result); | 1189 global_context()->set_strict_mode_arguments_boilerplate(*result); |
1184 | 1190 |
1185 // Add length property only for strict mode boilerplate. | 1191 // Add length property only for strict mode boilerplate. |
1186 SetLocalPropertyNoThrow(result, factory->length_symbol(), | 1192 CHECK_NOT_EMPTY_HANDLE(isolate, |
1187 factory->undefined_value(), | 1193 JSObject::SetLocalPropertyIgnoreAttributes( |
1188 DONT_ENUM); | 1194 result, factory->length_symbol(), |
| 1195 factory->undefined_value(), DONT_ENUM)); |
1189 | 1196 |
1190 #ifdef DEBUG | 1197 #ifdef DEBUG |
1191 LookupResult lookup(isolate); | 1198 LookupResult lookup(isolate); |
1192 result->LocalLookup(heap->length_symbol(), &lookup); | 1199 result->LocalLookup(heap->length_symbol(), &lookup); |
1193 ASSERT(lookup.IsProperty() && (lookup.type() == FIELD)); | 1200 ASSERT(lookup.IsProperty() && (lookup.type() == FIELD)); |
1194 ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsLengthIndex); | 1201 ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsLengthIndex); |
1195 | 1202 |
1196 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex); | 1203 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex); |
1197 | 1204 |
1198 // Check the state of the object. | 1205 // Check the state of the object. |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1441 builtins->set_global_receiver(*builtins); | 1448 builtins->set_global_receiver(*builtins); |
1442 | 1449 |
1443 // Setup the 'global' properties of the builtins object. The | 1450 // Setup the 'global' properties of the builtins object. The |
1444 // 'global' property that refers to the global object is the only | 1451 // 'global' property that refers to the global object is the only |
1445 // way to get from code running in the builtins context to the | 1452 // way to get from code running in the builtins context to the |
1446 // global object. | 1453 // global object. |
1447 static const PropertyAttributes attributes = | 1454 static const PropertyAttributes attributes = |
1448 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); | 1455 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); |
1449 Handle<String> global_symbol = factory()->LookupAsciiSymbol("global"); | 1456 Handle<String> global_symbol = factory()->LookupAsciiSymbol("global"); |
1450 Handle<Object> global_obj(global_context()->global()); | 1457 Handle<Object> global_obj(global_context()->global()); |
1451 SetLocalPropertyNoThrow(builtins, global_symbol, global_obj, attributes); | 1458 CHECK_NOT_EMPTY_HANDLE(isolate(), |
| 1459 JSObject::SetLocalPropertyIgnoreAttributes( |
| 1460 builtins, global_symbol, global_obj, attributes)); |
1452 | 1461 |
1453 // Setup the reference from the global object to the builtins object. | 1462 // Setup the reference from the global object to the builtins object. |
1454 JSGlobalObject::cast(global_context()->global())->set_builtins(*builtins); | 1463 JSGlobalObject::cast(global_context()->global())->set_builtins(*builtins); |
1455 | 1464 |
1456 // Create a bridge function that has context in the global context. | 1465 // Create a bridge function that has context in the global context. |
1457 Handle<JSFunction> bridge = | 1466 Handle<JSFunction> bridge = |
1458 factory()->NewFunction(factory()->empty_symbol(), | 1467 factory()->NewFunction(factory()->empty_symbol(), |
1459 factory()->undefined_value()); | 1468 factory()->undefined_value()); |
1460 ASSERT(bridge->context() == *isolate()->global_context()); | 1469 ASSERT(bridge->context() == *isolate()->global_context()); |
1461 | 1470 |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1904 BootstrapperActive active; | 1913 BootstrapperActive active; |
1905 SaveContext saved_context(isolate); | 1914 SaveContext saved_context(isolate); |
1906 isolate->set_context(*global_context); | 1915 isolate->set_context(*global_context); |
1907 if (!Genesis::InstallExtensions(global_context, extensions)) return false; | 1916 if (!Genesis::InstallExtensions(global_context, extensions)) return false; |
1908 Genesis::InstallSpecialObjects(global_context); | 1917 Genesis::InstallSpecialObjects(global_context); |
1909 return true; | 1918 return true; |
1910 } | 1919 } |
1911 | 1920 |
1912 | 1921 |
1913 void Genesis::InstallSpecialObjects(Handle<Context> global_context) { | 1922 void Genesis::InstallSpecialObjects(Handle<Context> global_context) { |
1914 Factory* factory = global_context->GetIsolate()->factory(); | 1923 Isolate* isolate = global_context->GetIsolate(); |
| 1924 Factory* factory = isolate->factory(); |
1915 HandleScope scope; | 1925 HandleScope scope; |
1916 Handle<JSGlobalObject> js_global( | 1926 Handle<JSGlobalObject> global(JSGlobalObject::cast(global_context->global())); |
1917 JSGlobalObject::cast(global_context->global())); | |
1918 // Expose the natives in global if a name for it is specified. | 1927 // Expose the natives in global if a name for it is specified. |
1919 if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) { | 1928 if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) { |
1920 Handle<String> natives_string = | 1929 Handle<String> natives = factory->LookupAsciiSymbol(FLAG_expose_natives_as); |
1921 factory->LookupAsciiSymbol(FLAG_expose_natives_as); | 1930 CHECK_NOT_EMPTY_HANDLE(isolate, |
1922 SetLocalPropertyNoThrow(js_global, natives_string, | 1931 JSObject::SetLocalPropertyIgnoreAttributes( |
1923 Handle<JSObject>(js_global->builtins()), DONT_ENUM); | 1932 global, natives, |
| 1933 Handle<JSObject>(global->builtins()), |
| 1934 DONT_ENUM)); |
1924 } | 1935 } |
1925 | 1936 |
1926 Handle<Object> Error = GetProperty(js_global, "Error"); | 1937 Handle<Object> Error = GetProperty(global, "Error"); |
1927 if (Error->IsJSObject()) { | 1938 if (Error->IsJSObject()) { |
1928 Handle<String> name = factory->LookupAsciiSymbol("stackTraceLimit"); | 1939 Handle<String> name = factory->LookupAsciiSymbol("stackTraceLimit"); |
1929 SetLocalPropertyNoThrow(Handle<JSObject>::cast(Error), | 1940 Handle<Smi> stack_trace_limit(Smi::FromInt(FLAG_stack_trace_limit)); |
1930 name, | 1941 CHECK_NOT_EMPTY_HANDLE(isolate, |
1931 Handle<Smi>(Smi::FromInt(FLAG_stack_trace_limit)), | 1942 JSObject::SetLocalPropertyIgnoreAttributes( |
1932 NONE); | 1943 Handle<JSObject>::cast(Error), name, |
| 1944 stack_trace_limit, NONE)); |
1933 } | 1945 } |
1934 | 1946 |
1935 #ifdef ENABLE_DEBUGGER_SUPPORT | 1947 #ifdef ENABLE_DEBUGGER_SUPPORT |
1936 // Expose the debug global object in global if a name for it is specified. | 1948 // Expose the debug global object in global if a name for it is specified. |
1937 if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) { | 1949 if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) { |
1938 Debug* debug = Isolate::Current()->debug(); | 1950 Debug* debug = Isolate::Current()->debug(); |
1939 // If loading fails we just bail out without installing the | 1951 // If loading fails we just bail out without installing the |
1940 // debugger but without tanking the whole context. | 1952 // debugger but without tanking the whole context. |
1941 if (!debug->Load()) return; | 1953 if (!debug->Load()) return; |
1942 // Set the security token for the debugger context to the same as | 1954 // Set the security token for the debugger context to the same as |
1943 // the shell global context to allow calling between these (otherwise | 1955 // the shell global context to allow calling between these (otherwise |
1944 // exposing debug global object doesn't make much sense). | 1956 // exposing debug global object doesn't make much sense). |
1945 debug->debug_context()->set_security_token( | 1957 debug->debug_context()->set_security_token( |
1946 global_context->security_token()); | 1958 global_context->security_token()); |
1947 | 1959 |
1948 Handle<String> debug_string = | 1960 Handle<String> debug_string = |
1949 factory->LookupAsciiSymbol(FLAG_expose_debug_as); | 1961 factory->LookupAsciiSymbol(FLAG_expose_debug_as); |
1950 Handle<Object> global_proxy(debug->debug_context()->global_proxy()); | 1962 Handle<Object> global_proxy(debug->debug_context()->global_proxy()); |
1951 SetLocalPropertyNoThrow(js_global, debug_string, global_proxy, DONT_ENUM); | 1963 CHECK_NOT_EMPTY_HANDLE(isolate, |
| 1964 JSObject::SetLocalPropertyIgnoreAttributes( |
| 1965 global, debug_string, global_proxy, DONT_ENUM)); |
1952 } | 1966 } |
1953 #endif | 1967 #endif |
1954 } | 1968 } |
1955 | 1969 |
1956 static uint32_t Hash(RegisteredExtension* extension) { | 1970 static uint32_t Hash(RegisteredExtension* extension) { |
1957 return v8::internal::ComputePointerHash(extension); | 1971 return v8::internal::ComputePointerHash(extension); |
1958 } | 1972 } |
1959 | 1973 |
1960 static bool MatchRegisteredExtensions(void* key1, void* key2) { | 1974 static bool MatchRegisteredExtensions(void* key1, void* key2) { |
1961 return key1 == key2; | 1975 return key1 == key2; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2157 Handle<DescriptorArray> descs = | 2171 Handle<DescriptorArray> descs = |
2158 Handle<DescriptorArray>(from->map()->instance_descriptors()); | 2172 Handle<DescriptorArray>(from->map()->instance_descriptors()); |
2159 for (int i = 0; i < descs->number_of_descriptors(); i++) { | 2173 for (int i = 0; i < descs->number_of_descriptors(); i++) { |
2160 PropertyDetails details = PropertyDetails(descs->GetDetails(i)); | 2174 PropertyDetails details = PropertyDetails(descs->GetDetails(i)); |
2161 switch (details.type()) { | 2175 switch (details.type()) { |
2162 case FIELD: { | 2176 case FIELD: { |
2163 HandleScope inner; | 2177 HandleScope inner; |
2164 Handle<String> key = Handle<String>(descs->GetKey(i)); | 2178 Handle<String> key = Handle<String>(descs->GetKey(i)); |
2165 int index = descs->GetFieldIndex(i); | 2179 int index = descs->GetFieldIndex(i); |
2166 Handle<Object> value = Handle<Object>(from->FastPropertyAt(index)); | 2180 Handle<Object> value = Handle<Object>(from->FastPropertyAt(index)); |
2167 SetLocalPropertyNoThrow(to, key, value, details.attributes()); | 2181 CHECK_NOT_EMPTY_HANDLE(to->GetIsolate(), |
| 2182 JSObject::SetLocalPropertyIgnoreAttributes( |
| 2183 to, key, value, details.attributes())); |
2168 break; | 2184 break; |
2169 } | 2185 } |
2170 case CONSTANT_FUNCTION: { | 2186 case CONSTANT_FUNCTION: { |
2171 HandleScope inner; | 2187 HandleScope inner; |
2172 Handle<String> key = Handle<String>(descs->GetKey(i)); | 2188 Handle<String> key = Handle<String>(descs->GetKey(i)); |
2173 Handle<JSFunction> fun = | 2189 Handle<JSFunction> fun = |
2174 Handle<JSFunction>(descs->GetConstantFunction(i)); | 2190 Handle<JSFunction>(descs->GetConstantFunction(i)); |
2175 SetLocalPropertyNoThrow(to, key, fun, details.attributes()); | 2191 CHECK_NOT_EMPTY_HANDLE(to->GetIsolate(), |
| 2192 JSObject::SetLocalPropertyIgnoreAttributes( |
| 2193 to, key, fun, details.attributes())); |
2176 break; | 2194 break; |
2177 } | 2195 } |
2178 case CALLBACKS: { | 2196 case CALLBACKS: { |
2179 LookupResult result(isolate()); | 2197 LookupResult result(isolate()); |
2180 to->LocalLookup(descs->GetKey(i), &result); | 2198 to->LocalLookup(descs->GetKey(i), &result); |
2181 // If the property is already there we skip it | 2199 // If the property is already there we skip it |
2182 if (result.IsProperty()) continue; | 2200 if (result.IsProperty()) continue; |
2183 HandleScope inner; | 2201 HandleScope inner; |
2184 ASSERT(!to->HasFastProperties()); | 2202 ASSERT(!to->HasFastProperties()); |
2185 // Add to dictionary. | 2203 // Add to dictionary. |
2186 Handle<String> key = Handle<String>(descs->GetKey(i)); | 2204 Handle<String> key = Handle<String>(descs->GetKey(i)); |
2187 Handle<Object> callbacks(descs->GetCallbacksObject(i)); | 2205 Handle<Object> callbacks(descs->GetCallbacksObject(i)); |
2188 PropertyDetails d = | 2206 PropertyDetails d = |
2189 PropertyDetails(details.attributes(), CALLBACKS, details.index()); | 2207 PropertyDetails(details.attributes(), CALLBACKS, details.index()); |
2190 SetNormalizedProperty(to, key, callbacks, d); | 2208 JSObject::SetNormalizedProperty(to, key, callbacks, d); |
2191 break; | 2209 break; |
2192 } | 2210 } |
2193 case MAP_TRANSITION: | 2211 case MAP_TRANSITION: |
2194 case ELEMENTS_TRANSITION: | 2212 case ELEMENTS_TRANSITION: |
2195 case CONSTANT_TRANSITION: | 2213 case CONSTANT_TRANSITION: |
2196 case NULL_DESCRIPTOR: | 2214 case NULL_DESCRIPTOR: |
2197 // Ignore non-properties. | 2215 // Ignore non-properties. |
2198 break; | 2216 break; |
2199 case NORMAL: | 2217 case NORMAL: |
2200 // Do not occur since the from object has fast properties. | 2218 // Do not occur since the from object has fast properties. |
(...skipping 16 matching lines...) Expand all Loading... |
2217 LookupResult result(isolate()); | 2235 LookupResult result(isolate()); |
2218 to->LocalLookup(String::cast(raw_key), &result); | 2236 to->LocalLookup(String::cast(raw_key), &result); |
2219 if (result.IsProperty()) continue; | 2237 if (result.IsProperty()) continue; |
2220 // Set the property. | 2238 // Set the property. |
2221 Handle<String> key = Handle<String>(String::cast(raw_key)); | 2239 Handle<String> key = Handle<String>(String::cast(raw_key)); |
2222 Handle<Object> value = Handle<Object>(properties->ValueAt(i)); | 2240 Handle<Object> value = Handle<Object>(properties->ValueAt(i)); |
2223 if (value->IsJSGlobalPropertyCell()) { | 2241 if (value->IsJSGlobalPropertyCell()) { |
2224 value = Handle<Object>(JSGlobalPropertyCell::cast(*value)->value()); | 2242 value = Handle<Object>(JSGlobalPropertyCell::cast(*value)->value()); |
2225 } | 2243 } |
2226 PropertyDetails details = properties->DetailsAt(i); | 2244 PropertyDetails details = properties->DetailsAt(i); |
2227 SetLocalPropertyNoThrow(to, key, value, details.attributes()); | 2245 CHECK_NOT_EMPTY_HANDLE(to->GetIsolate(), |
| 2246 JSObject::SetLocalPropertyIgnoreAttributes( |
| 2247 to, key, value, details.attributes())); |
2228 } | 2248 } |
2229 } | 2249 } |
2230 } | 2250 } |
2231 } | 2251 } |
2232 | 2252 |
2233 | 2253 |
2234 void Genesis::TransferIndexedProperties(Handle<JSObject> from, | 2254 void Genesis::TransferIndexedProperties(Handle<JSObject> from, |
2235 Handle<JSObject> to) { | 2255 Handle<JSObject> to) { |
2236 // Cloning the elements array is sufficient. | 2256 // Cloning the elements array is sufficient. |
2237 Handle<FixedArray> from_elements = | 2257 Handle<FixedArray> from_elements = |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2354 return from + sizeof(NestingCounterType); | 2374 return from + sizeof(NestingCounterType); |
2355 } | 2375 } |
2356 | 2376 |
2357 | 2377 |
2358 // Called when the top-level V8 mutex is destroyed. | 2378 // Called when the top-level V8 mutex is destroyed. |
2359 void Bootstrapper::FreeThreadResources() { | 2379 void Bootstrapper::FreeThreadResources() { |
2360 ASSERT(!IsActive()); | 2380 ASSERT(!IsActive()); |
2361 } | 2381 } |
2362 | 2382 |
2363 } } // namespace v8::internal | 2383 } } // namespace v8::internal |
OLD | NEW |