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