| 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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 ? factory->NewFunction(internalized_name, call_code, prototype, | 364 ? factory->NewFunction(internalized_name, call_code, prototype, |
| 365 type, instance_size) | 365 type, instance_size) |
| 366 : factory->NewFunctionWithoutPrototype(internalized_name, call_code); | 366 : factory->NewFunctionWithoutPrototype(internalized_name, call_code); |
| 367 PropertyAttributes attributes; | 367 PropertyAttributes attributes; |
| 368 if (target->IsJSBuiltinsObject()) { | 368 if (target->IsJSBuiltinsObject()) { |
| 369 attributes = | 369 attributes = |
| 370 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 370 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 371 } else { | 371 } else { |
| 372 attributes = DONT_ENUM; | 372 attributes = DONT_ENUM; |
| 373 } | 373 } |
| 374 JSObject::SetLocalPropertyIgnoreAttributes( | 374 JSObject::SetOwnPropertyIgnoreAttributes( |
| 375 target, internalized_name, function, attributes).Check(); | 375 target, internalized_name, function, attributes).Check(); |
| 376 if (target->IsJSGlobalObject()) { | 376 if (target->IsJSGlobalObject()) { |
| 377 function->shared()->set_instance_class_name(*internalized_name); | 377 function->shared()->set_instance_class_name(*internalized_name); |
| 378 } | 378 } |
| 379 function->shared()->set_native(true); | 379 function->shared()->set_native(true); |
| 380 return function; | 380 return function; |
| 381 } | 381 } |
| 382 | 382 |
| 383 | 383 |
| 384 void Genesis::SetFunctionInstanceDescriptor( | 384 void Genesis::SetFunctionInstanceDescriptor( |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 Handle<String> name = Handle<String>(heap()->empty_string()); | 741 Handle<String> name = Handle<String>(heap()->empty_string()); |
| 742 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin( | 742 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin( |
| 743 Builtins::kIllegal)); | 743 Builtins::kIllegal)); |
| 744 js_global_function = factory()->NewFunction( | 744 js_global_function = factory()->NewFunction( |
| 745 name, code, JS_GLOBAL_OBJECT_TYPE, JSGlobalObject::kSize); | 745 name, code, JS_GLOBAL_OBJECT_TYPE, JSGlobalObject::kSize); |
| 746 // Change the constructor property of the prototype of the | 746 // Change the constructor property of the prototype of the |
| 747 // hidden global function to refer to the Object function. | 747 // hidden global function to refer to the Object function. |
| 748 Handle<JSObject> prototype = | 748 Handle<JSObject> prototype = |
| 749 Handle<JSObject>( | 749 Handle<JSObject>( |
| 750 JSObject::cast(js_global_function->instance_prototype())); | 750 JSObject::cast(js_global_function->instance_prototype())); |
| 751 JSObject::SetLocalPropertyIgnoreAttributes( | 751 JSObject::SetOwnPropertyIgnoreAttributes( |
| 752 prototype, factory()->constructor_string(), | 752 prototype, factory()->constructor_string(), |
| 753 isolate()->object_function(), NONE).Check(); | 753 isolate()->object_function(), NONE).Check(); |
| 754 } else { | 754 } else { |
| 755 Handle<FunctionTemplateInfo> js_global_constructor( | 755 Handle<FunctionTemplateInfo> js_global_constructor( |
| 756 FunctionTemplateInfo::cast(js_global_template->constructor())); | 756 FunctionTemplateInfo::cast(js_global_template->constructor())); |
| 757 js_global_function = | 757 js_global_function = |
| 758 factory()->CreateApiFunction(js_global_constructor, | 758 factory()->CreateApiFunction(js_global_constructor, |
| 759 factory()->the_hole_value(), | 759 factory()->the_hole_value(), |
| 760 factory()->InnerGlobalObject); | 760 factory()->InnerGlobalObject); |
| 761 } | 761 } |
| (...skipping 94 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 native_context()->set_security_token(*inner_global); | 859 native_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 = factory->Object_string(); | 865 Handle<String> object_name = factory->Object_string(); |
| 866 JSObject::SetLocalPropertyIgnoreAttributes( | 866 JSObject::SetOwnPropertyIgnoreAttributes( |
| 867 inner_global, object_name, | 867 inner_global, object_name, |
| 868 isolate->object_function(), DONT_ENUM).Check(); | 868 isolate->object_function(), DONT_ENUM).Check(); |
| 869 | 869 |
| 870 Handle<JSObject> global(native_context()->global_object()); | 870 Handle<JSObject> global(native_context()->global_object()); |
| 871 | 871 |
| 872 // Install global Function object | 872 // Install global Function object |
| 873 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, | 873 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, |
| 874 empty_function, Builtins::kIllegal); | 874 empty_function, Builtins::kIllegal); |
| 875 | 875 |
| 876 { // --- A r r a y --- | 876 { // --- A r r a y --- |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 } | 1057 } |
| 1058 | 1058 |
| 1059 { // -- J S O N | 1059 { // -- J S O N |
| 1060 Handle<String> name = factory->InternalizeUtf8String("JSON"); | 1060 Handle<String> name = factory->InternalizeUtf8String("JSON"); |
| 1061 Handle<JSFunction> cons = factory->NewFunction(name); | 1061 Handle<JSFunction> cons = factory->NewFunction(name); |
| 1062 JSFunction::SetInstancePrototype(cons, | 1062 JSFunction::SetInstancePrototype(cons, |
| 1063 Handle<Object>(native_context()->initial_object_prototype(), isolate)); | 1063 Handle<Object>(native_context()->initial_object_prototype(), isolate)); |
| 1064 cons->SetInstanceClassName(*name); | 1064 cons->SetInstanceClassName(*name); |
| 1065 Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED); | 1065 Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED); |
| 1066 ASSERT(json_object->IsJSObject()); | 1066 ASSERT(json_object->IsJSObject()); |
| 1067 JSObject::SetLocalPropertyIgnoreAttributes( | 1067 JSObject::SetOwnPropertyIgnoreAttributes( |
| 1068 global, name, json_object, DONT_ENUM).Check(); | 1068 global, name, json_object, DONT_ENUM).Check(); |
| 1069 native_context()->set_json_object(*json_object); | 1069 native_context()->set_json_object(*json_object); |
| 1070 } | 1070 } |
| 1071 | 1071 |
| 1072 { // -- A r r a y B u f f e r | 1072 { // -- A r r a y B u f f e r |
| 1073 Handle<JSFunction> array_buffer_fun = | 1073 Handle<JSFunction> array_buffer_fun = |
| 1074 InstallFunction( | 1074 InstallFunction( |
| 1075 global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE, | 1075 global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE, |
| 1076 JSArrayBuffer::kSizeWithInternalFields, | 1076 JSArrayBuffer::kSizeWithInternalFields, |
| 1077 isolate->initial_object_prototype(), | 1077 isolate->initial_object_prototype(), |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1123 ASSERT(!function->has_initial_map()); | 1123 ASSERT(!function->has_initial_map()); |
| 1124 function->shared()->set_instance_class_name(*arguments_string); | 1124 function->shared()->set_instance_class_name(*arguments_string); |
| 1125 function->shared()->set_expected_nof_properties(2); | 1125 function->shared()->set_expected_nof_properties(2); |
| 1126 function->set_prototype_or_initial_map( | 1126 function->set_prototype_or_initial_map( |
| 1127 native_context()->object_function()->prototype()); | 1127 native_context()->object_function()->prototype()); |
| 1128 Handle<JSObject> result = factory->NewJSObject(function); | 1128 Handle<JSObject> result = factory->NewJSObject(function); |
| 1129 | 1129 |
| 1130 native_context()->set_sloppy_arguments_boilerplate(*result); | 1130 native_context()->set_sloppy_arguments_boilerplate(*result); |
| 1131 // Note: length must be added as the first property and | 1131 // Note: length must be added as the first property and |
| 1132 // callee must be added as the second property. | 1132 // callee must be added as the second property. |
| 1133 JSObject::SetLocalPropertyIgnoreAttributes( | 1133 JSObject::SetOwnPropertyIgnoreAttributes( |
| 1134 result, factory->length_string(), | 1134 result, factory->length_string(), |
| 1135 factory->undefined_value(), DONT_ENUM, | 1135 factory->undefined_value(), DONT_ENUM, |
| 1136 Object::FORCE_TAGGED, FORCE_FIELD).Check(); | 1136 Object::FORCE_TAGGED, FORCE_FIELD).Check(); |
| 1137 JSObject::SetLocalPropertyIgnoreAttributes( | 1137 JSObject::SetOwnPropertyIgnoreAttributes( |
| 1138 result, factory->callee_string(), | 1138 result, factory->callee_string(), |
| 1139 factory->undefined_value(), DONT_ENUM, | 1139 factory->undefined_value(), DONT_ENUM, |
| 1140 Object::FORCE_TAGGED, FORCE_FIELD).Check(); | 1140 Object::FORCE_TAGGED, FORCE_FIELD).Check(); |
| 1141 | 1141 |
| 1142 #ifdef DEBUG | 1142 #ifdef DEBUG |
| 1143 LookupResult lookup(isolate); | 1143 LookupResult lookup(isolate); |
| 1144 result->LocalLookup(factory->callee_string(), &lookup); | 1144 result->LookupOwn(factory->callee_string(), &lookup); |
| 1145 ASSERT(lookup.IsField()); | 1145 ASSERT(lookup.IsField()); |
| 1146 ASSERT(lookup.GetFieldIndex().field_index() == Heap::kArgumentsCalleeIndex); | 1146 ASSERT(lookup.GetFieldIndex().field_index() == Heap::kArgumentsCalleeIndex); |
| 1147 | 1147 |
| 1148 result->LocalLookup(factory->length_string(), &lookup); | 1148 result->LookupOwn(factory->length_string(), &lookup); |
| 1149 ASSERT(lookup.IsField()); | 1149 ASSERT(lookup.IsField()); |
| 1150 ASSERT(lookup.GetFieldIndex().field_index() == Heap::kArgumentsLengthIndex); | 1150 ASSERT(lookup.GetFieldIndex().field_index() == Heap::kArgumentsLengthIndex); |
| 1151 | 1151 |
| 1152 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsCalleeIndex); | 1152 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsCalleeIndex); |
| 1153 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex); | 1153 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex); |
| 1154 | 1154 |
| 1155 // Check the state of the object. | 1155 // Check the state of the object. |
| 1156 ASSERT(result->HasFastProperties()); | 1156 ASSERT(result->HasFastProperties()); |
| 1157 ASSERT(result->HasFastObjectElements()); | 1157 ASSERT(result->HasFastObjectElements()); |
| 1158 #endif | 1158 #endif |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1228 | 1228 |
| 1229 // Copy constructor from the sloppy arguments boilerplate. | 1229 // Copy constructor from the sloppy arguments boilerplate. |
| 1230 map->set_constructor( | 1230 map->set_constructor( |
| 1231 native_context()->sloppy_arguments_boilerplate()->map()->constructor()); | 1231 native_context()->sloppy_arguments_boilerplate()->map()->constructor()); |
| 1232 | 1232 |
| 1233 // Allocate the arguments boilerplate object. | 1233 // Allocate the arguments boilerplate object. |
| 1234 Handle<JSObject> result = factory->NewJSObjectFromMap(map); | 1234 Handle<JSObject> result = factory->NewJSObjectFromMap(map); |
| 1235 native_context()->set_strict_arguments_boilerplate(*result); | 1235 native_context()->set_strict_arguments_boilerplate(*result); |
| 1236 | 1236 |
| 1237 // Add length property only for strict mode boilerplate. | 1237 // Add length property only for strict mode boilerplate. |
| 1238 JSObject::SetLocalPropertyIgnoreAttributes( | 1238 JSObject::SetOwnPropertyIgnoreAttributes( |
| 1239 result, factory->length_string(), | 1239 result, factory->length_string(), |
| 1240 factory->undefined_value(), DONT_ENUM).Check(); | 1240 factory->undefined_value(), DONT_ENUM).Check(); |
| 1241 | 1241 |
| 1242 #ifdef DEBUG | 1242 #ifdef DEBUG |
| 1243 LookupResult lookup(isolate); | 1243 LookupResult lookup(isolate); |
| 1244 result->LocalLookup(factory->length_string(), &lookup); | 1244 result->LookupOwn(factory->length_string(), &lookup); |
| 1245 ASSERT(lookup.IsField()); | 1245 ASSERT(lookup.IsField()); |
| 1246 ASSERT(lookup.GetFieldIndex().field_index() == Heap::kArgumentsLengthIndex); | 1246 ASSERT(lookup.GetFieldIndex().field_index() == Heap::kArgumentsLengthIndex); |
| 1247 | 1247 |
| 1248 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex); | 1248 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex); |
| 1249 | 1249 |
| 1250 // Check the state of the object. | 1250 // Check the state of the object. |
| 1251 ASSERT(result->HasFastProperties()); | 1251 ASSERT(result->HasFastProperties()); |
| 1252 ASSERT(result->HasFastObjectElements()); | 1252 ASSERT(result->HasFastObjectElements()); |
| 1253 #endif | 1253 #endif |
| 1254 } | 1254 } |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1687 | 1687 |
| 1688 // Set up the 'global' properties of the builtins object. The | 1688 // Set up the 'global' properties of the builtins object. The |
| 1689 // 'global' property that refers to the global object is the only | 1689 // 'global' property that refers to the global object is the only |
| 1690 // way to get from code running in the builtins context to the | 1690 // way to get from code running in the builtins context to the |
| 1691 // global object. | 1691 // global object. |
| 1692 static const PropertyAttributes attributes = | 1692 static const PropertyAttributes attributes = |
| 1693 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); | 1693 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); |
| 1694 Handle<String> global_string = | 1694 Handle<String> global_string = |
| 1695 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("global")); | 1695 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("global")); |
| 1696 Handle<Object> global_obj(native_context()->global_object(), isolate()); | 1696 Handle<Object> global_obj(native_context()->global_object(), isolate()); |
| 1697 JSObject::SetLocalPropertyIgnoreAttributes( | 1697 JSObject::SetOwnPropertyIgnoreAttributes( |
| 1698 builtins, global_string, global_obj, attributes).Check(); | 1698 builtins, global_string, global_obj, attributes).Check(); |
| 1699 Handle<String> builtins_string = | 1699 Handle<String> builtins_string = |
| 1700 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("builtins")); | 1700 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("builtins")); |
| 1701 JSObject::SetLocalPropertyIgnoreAttributes( | 1701 JSObject::SetOwnPropertyIgnoreAttributes( |
| 1702 builtins, builtins_string, builtins, attributes).Check(); | 1702 builtins, builtins_string, builtins, attributes).Check(); |
| 1703 | 1703 |
| 1704 // Set up the reference from the global object to the builtins object. | 1704 // Set up the reference from the global object to the builtins object. |
| 1705 JSGlobalObject::cast(native_context()->global_object())-> | 1705 JSGlobalObject::cast(native_context()->global_object())-> |
| 1706 set_builtins(*builtins); | 1706 set_builtins(*builtins); |
| 1707 | 1707 |
| 1708 // Create a bridge function that has context in the native context. | 1708 // Create a bridge function that has context in the native context. |
| 1709 Handle<JSFunction> bridge = factory()->NewFunction(factory()->empty_string()); | 1709 Handle<JSFunction> bridge = factory()->NewFunction(factory()->empty_string()); |
| 1710 ASSERT(bridge->context() == *isolate()->native_context()); | 1710 ASSERT(bridge->context() == *isolate()->native_context()); |
| 1711 | 1711 |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2141 Factory* factory = isolate->factory(); | 2141 Factory* factory = isolate->factory(); |
| 2142 HandleScope scope(isolate); | 2142 HandleScope scope(isolate); |
| 2143 Handle<JSGlobalObject> global(JSGlobalObject::cast( | 2143 Handle<JSGlobalObject> global(JSGlobalObject::cast( |
| 2144 native_context->global_object())); | 2144 native_context->global_object())); |
| 2145 // Expose the natives in global if a name for it is specified. | 2145 // Expose the natives in global if a name for it is specified. |
| 2146 if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) { | 2146 if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) { |
| 2147 Handle<String> natives = | 2147 Handle<String> natives = |
| 2148 factory->InternalizeUtf8String(FLAG_expose_natives_as); | 2148 factory->InternalizeUtf8String(FLAG_expose_natives_as); |
| 2149 RETURN_ON_EXCEPTION_VALUE( | 2149 RETURN_ON_EXCEPTION_VALUE( |
| 2150 isolate, | 2150 isolate, |
| 2151 JSObject::SetLocalPropertyIgnoreAttributes( | 2151 JSObject::SetOwnPropertyIgnoreAttributes( |
| 2152 global, natives, Handle<JSObject>(global->builtins()), DONT_ENUM), | 2152 global, natives, Handle<JSObject>(global->builtins()), DONT_ENUM), |
| 2153 false); | 2153 false); |
| 2154 } | 2154 } |
| 2155 | 2155 |
| 2156 Handle<Object> Error = Object::GetProperty( | 2156 Handle<Object> Error = Object::GetProperty( |
| 2157 isolate, global, "Error").ToHandleChecked(); | 2157 isolate, global, "Error").ToHandleChecked(); |
| 2158 if (Error->IsJSObject()) { | 2158 if (Error->IsJSObject()) { |
| 2159 Handle<String> name = factory->InternalizeOneByteString( | 2159 Handle<String> name = factory->InternalizeOneByteString( |
| 2160 STATIC_ASCII_VECTOR("stackTraceLimit")); | 2160 STATIC_ASCII_VECTOR("stackTraceLimit")); |
| 2161 Handle<Smi> stack_trace_limit( | 2161 Handle<Smi> stack_trace_limit( |
| 2162 Smi::FromInt(FLAG_stack_trace_limit), isolate); | 2162 Smi::FromInt(FLAG_stack_trace_limit), isolate); |
| 2163 RETURN_ON_EXCEPTION_VALUE( | 2163 RETURN_ON_EXCEPTION_VALUE( |
| 2164 isolate, | 2164 isolate, |
| 2165 JSObject::SetLocalPropertyIgnoreAttributes( | 2165 JSObject::SetOwnPropertyIgnoreAttributes( |
| 2166 Handle<JSObject>::cast(Error), name, stack_trace_limit, NONE), | 2166 Handle<JSObject>::cast(Error), name, stack_trace_limit, NONE), |
| 2167 false); | 2167 false); |
| 2168 } | 2168 } |
| 2169 | 2169 |
| 2170 // Expose the debug global object in global if a name for it is specified. | 2170 // Expose the debug global object in global if a name for it is specified. |
| 2171 if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) { | 2171 if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) { |
| 2172 // If loading fails we just bail out without installing the | 2172 // If loading fails we just bail out without installing the |
| 2173 // debugger but without tanking the whole context. | 2173 // debugger but without tanking the whole context. |
| 2174 Debug* debug = isolate->debug(); | 2174 Debug* debug = isolate->debug(); |
| 2175 if (!debug->Load()) return true; | 2175 if (!debug->Load()) return true; |
| 2176 Handle<Context> debug_context = debug->debug_context(); | 2176 Handle<Context> debug_context = debug->debug_context(); |
| 2177 // Set the security token for the debugger context to the same as | 2177 // Set the security token for the debugger context to the same as |
| 2178 // the shell native context to allow calling between these (otherwise | 2178 // the shell native context to allow calling between these (otherwise |
| 2179 // exposing debug global object doesn't make much sense). | 2179 // exposing debug global object doesn't make much sense). |
| 2180 debug_context->set_security_token(native_context->security_token()); | 2180 debug_context->set_security_token(native_context->security_token()); |
| 2181 Handle<String> debug_string = | 2181 Handle<String> debug_string = |
| 2182 factory->InternalizeUtf8String(FLAG_expose_debug_as); | 2182 factory->InternalizeUtf8String(FLAG_expose_debug_as); |
| 2183 Handle<Object> global_proxy(debug_context->global_proxy(), isolate); | 2183 Handle<Object> global_proxy(debug_context->global_proxy(), isolate); |
| 2184 RETURN_ON_EXCEPTION_VALUE( | 2184 RETURN_ON_EXCEPTION_VALUE( |
| 2185 isolate, | 2185 isolate, |
| 2186 JSObject::SetLocalPropertyIgnoreAttributes( | 2186 JSObject::SetOwnPropertyIgnoreAttributes( |
| 2187 global, debug_string, global_proxy, DONT_ENUM), | 2187 global, debug_string, global_proxy, DONT_ENUM), |
| 2188 false); | 2188 false); |
| 2189 } | 2189 } |
| 2190 return true; | 2190 return true; |
| 2191 } | 2191 } |
| 2192 | 2192 |
| 2193 | 2193 |
| 2194 static uint32_t Hash(RegisteredExtension* extension) { | 2194 static uint32_t Hash(RegisteredExtension* extension) { |
| 2195 return v8::internal::ComputePointerHash(extension); | 2195 return v8::internal::ComputePointerHash(extension); |
| 2196 } | 2196 } |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2403 for (int i = 0; i < from->map()->NumberOfOwnDescriptors(); i++) { | 2403 for (int i = 0; i < from->map()->NumberOfOwnDescriptors(); i++) { |
| 2404 PropertyDetails details = descs->GetDetails(i); | 2404 PropertyDetails details = descs->GetDetails(i); |
| 2405 switch (details.type()) { | 2405 switch (details.type()) { |
| 2406 case FIELD: { | 2406 case FIELD: { |
| 2407 HandleScope inner(isolate()); | 2407 HandleScope inner(isolate()); |
| 2408 Handle<Name> key = Handle<Name>(descs->GetKey(i)); | 2408 Handle<Name> key = Handle<Name>(descs->GetKey(i)); |
| 2409 int index = descs->GetFieldIndex(i); | 2409 int index = descs->GetFieldIndex(i); |
| 2410 ASSERT(!descs->GetDetails(i).representation().IsDouble()); | 2410 ASSERT(!descs->GetDetails(i).representation().IsDouble()); |
| 2411 Handle<Object> value = Handle<Object>(from->RawFastPropertyAt(index), | 2411 Handle<Object> value = Handle<Object>(from->RawFastPropertyAt(index), |
| 2412 isolate()); | 2412 isolate()); |
| 2413 JSObject::SetLocalPropertyIgnoreAttributes( | 2413 JSObject::SetOwnPropertyIgnoreAttributes( |
| 2414 to, key, value, details.attributes()).Check(); | 2414 to, key, value, details.attributes()).Check(); |
| 2415 break; | 2415 break; |
| 2416 } | 2416 } |
| 2417 case CONSTANT: { | 2417 case CONSTANT: { |
| 2418 HandleScope inner(isolate()); | 2418 HandleScope inner(isolate()); |
| 2419 Handle<Name> key = Handle<Name>(descs->GetKey(i)); | 2419 Handle<Name> key = Handle<Name>(descs->GetKey(i)); |
| 2420 Handle<Object> constant(descs->GetConstant(i), isolate()); | 2420 Handle<Object> constant(descs->GetConstant(i), isolate()); |
| 2421 JSObject::SetLocalPropertyIgnoreAttributes( | 2421 JSObject::SetOwnPropertyIgnoreAttributes( |
| 2422 to, key, constant, details.attributes()).Check(); | 2422 to, key, constant, details.attributes()).Check(); |
| 2423 break; | 2423 break; |
| 2424 } | 2424 } |
| 2425 case CALLBACKS: { | 2425 case CALLBACKS: { |
| 2426 LookupResult result(isolate()); | 2426 LookupResult result(isolate()); |
| 2427 Handle<Name> key(Name::cast(descs->GetKey(i)), isolate()); | 2427 Handle<Name> key(Name::cast(descs->GetKey(i)), isolate()); |
| 2428 to->LocalLookup(key, &result); | 2428 to->LookupOwn(key, &result); |
| 2429 // If the property is already there we skip it | 2429 // If the property is already there we skip it |
| 2430 if (result.IsFound()) continue; | 2430 if (result.IsFound()) continue; |
| 2431 HandleScope inner(isolate()); | 2431 HandleScope inner(isolate()); |
| 2432 ASSERT(!to->HasFastProperties()); | 2432 ASSERT(!to->HasFastProperties()); |
| 2433 // Add to dictionary. | 2433 // Add to dictionary. |
| 2434 Handle<Object> callbacks(descs->GetCallbacksObject(i), isolate()); | 2434 Handle<Object> callbacks(descs->GetCallbacksObject(i), isolate()); |
| 2435 PropertyDetails d = PropertyDetails( | 2435 PropertyDetails d = PropertyDetails( |
| 2436 details.attributes(), CALLBACKS, i + 1); | 2436 details.attributes(), CALLBACKS, i + 1); |
| 2437 JSObject::SetNormalizedProperty(to, key, callbacks, d); | 2437 JSObject::SetNormalizedProperty(to, key, callbacks, d); |
| 2438 break; | 2438 break; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2451 Handle<NameDictionary> properties = | 2451 Handle<NameDictionary> properties = |
| 2452 Handle<NameDictionary>(from->property_dictionary()); | 2452 Handle<NameDictionary>(from->property_dictionary()); |
| 2453 int capacity = properties->Capacity(); | 2453 int capacity = properties->Capacity(); |
| 2454 for (int i = 0; i < capacity; i++) { | 2454 for (int i = 0; i < capacity; i++) { |
| 2455 Object* raw_key(properties->KeyAt(i)); | 2455 Object* raw_key(properties->KeyAt(i)); |
| 2456 if (properties->IsKey(raw_key)) { | 2456 if (properties->IsKey(raw_key)) { |
| 2457 ASSERT(raw_key->IsName()); | 2457 ASSERT(raw_key->IsName()); |
| 2458 // If the property is already there we skip it. | 2458 // If the property is already there we skip it. |
| 2459 LookupResult result(isolate()); | 2459 LookupResult result(isolate()); |
| 2460 Handle<Name> key(Name::cast(raw_key)); | 2460 Handle<Name> key(Name::cast(raw_key)); |
| 2461 to->LocalLookup(key, &result); | 2461 to->LookupOwn(key, &result); |
| 2462 if (result.IsFound()) continue; | 2462 if (result.IsFound()) continue; |
| 2463 // Set the property. | 2463 // Set the property. |
| 2464 Handle<Object> value = Handle<Object>(properties->ValueAt(i), | 2464 Handle<Object> value = Handle<Object>(properties->ValueAt(i), |
| 2465 isolate()); | 2465 isolate()); |
| 2466 ASSERT(!value->IsCell()); | 2466 ASSERT(!value->IsCell()); |
| 2467 if (value->IsPropertyCell()) { | 2467 if (value->IsPropertyCell()) { |
| 2468 value = Handle<Object>(PropertyCell::cast(*value)->value(), | 2468 value = Handle<Object>(PropertyCell::cast(*value)->value(), |
| 2469 isolate()); | 2469 isolate()); |
| 2470 } | 2470 } |
| 2471 PropertyDetails details = properties->DetailsAt(i); | 2471 PropertyDetails details = properties->DetailsAt(i); |
| 2472 JSObject::SetLocalPropertyIgnoreAttributes( | 2472 JSObject::SetOwnPropertyIgnoreAttributes( |
| 2473 to, key, value, details.attributes()).Check(); | 2473 to, key, value, details.attributes()).Check(); |
| 2474 } | 2474 } |
| 2475 } | 2475 } |
| 2476 } | 2476 } |
| 2477 } | 2477 } |
| 2478 | 2478 |
| 2479 | 2479 |
| 2480 void Genesis::TransferIndexedProperties(Handle<JSObject> from, | 2480 void Genesis::TransferIndexedProperties(Handle<JSObject> from, |
| 2481 Handle<JSObject> to) { | 2481 Handle<JSObject> to) { |
| 2482 // Cloning the elements array is sufficient. | 2482 // Cloning the elements array is sufficient. |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2681 | 2681 |
| 2682 | 2682 |
| 2683 // Support for thread preemption. | 2683 // Support for thread preemption. |
| 2684 | 2684 |
| 2685 // Reserve space for statics needing saving and restoring. | 2685 // Reserve space for statics needing saving and restoring. |
| 2686 int Bootstrapper::ArchiveSpacePerThread() { | 2686 int Bootstrapper::ArchiveSpacePerThread() { |
| 2687 return sizeof(NestingCounterType); | 2687 return sizeof(NestingCounterType); |
| 2688 } | 2688 } |
| 2689 | 2689 |
| 2690 | 2690 |
| 2691 // Archive statics that are thread local. | 2691 // Archive statics that are thread-local. |
| 2692 char* Bootstrapper::ArchiveState(char* to) { | 2692 char* Bootstrapper::ArchiveState(char* to) { |
| 2693 *reinterpret_cast<NestingCounterType*>(to) = nesting_; | 2693 *reinterpret_cast<NestingCounterType*>(to) = nesting_; |
| 2694 nesting_ = 0; | 2694 nesting_ = 0; |
| 2695 return to + sizeof(NestingCounterType); | 2695 return to + sizeof(NestingCounterType); |
| 2696 } | 2696 } |
| 2697 | 2697 |
| 2698 | 2698 |
| 2699 // Restore statics that are thread local. | 2699 // Restore statics that are thread-local. |
| 2700 char* Bootstrapper::RestoreState(char* from) { | 2700 char* Bootstrapper::RestoreState(char* from) { |
| 2701 nesting_ = *reinterpret_cast<NestingCounterType*>(from); | 2701 nesting_ = *reinterpret_cast<NestingCounterType*>(from); |
| 2702 return from + sizeof(NestingCounterType); | 2702 return from + sizeof(NestingCounterType); |
| 2703 } | 2703 } |
| 2704 | 2704 |
| 2705 | 2705 |
| 2706 // Called when the top-level V8 mutex is destroyed. | 2706 // Called when the top-level V8 mutex is destroyed. |
| 2707 void Bootstrapper::FreeThreadResources() { | 2707 void Bootstrapper::FreeThreadResources() { |
| 2708 ASSERT(!IsActive()); | 2708 ASSERT(!IsActive()); |
| 2709 } | 2709 } |
| 2710 | 2710 |
| 2711 } } // namespace v8::internal | 2711 } } // namespace v8::internal |
| OLD | NEW |