| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 return *desc; | 877 return *desc; |
| 878 } | 878 } |
| 879 | 879 |
| 880 | 880 |
| 881 static MaybeObject* Runtime_PreventExtensions(Arguments args) { | 881 static MaybeObject* Runtime_PreventExtensions(Arguments args) { |
| 882 ASSERT(args.length() == 1); | 882 ASSERT(args.length() == 1); |
| 883 CONVERT_CHECKED(JSObject, obj, args[0]); | 883 CONVERT_CHECKED(JSObject, obj, args[0]); |
| 884 return obj->PreventExtensions(); | 884 return obj->PreventExtensions(); |
| 885 } | 885 } |
| 886 | 886 |
| 887 |
| 887 static MaybeObject* Runtime_IsExtensible(Arguments args) { | 888 static MaybeObject* Runtime_IsExtensible(Arguments args) { |
| 888 ASSERT(args.length() == 1); | 889 ASSERT(args.length() == 1); |
| 889 CONVERT_CHECKED(JSObject, obj, args[0]); | 890 CONVERT_CHECKED(JSObject, obj, args[0]); |
| 890 return obj->map()->is_extensible() ? Heap::true_value() | 891 if (obj->IsJSGlobalProxy()) { |
| 892 Object* proto = obj->GetPrototype(); |
| 893 if (proto->IsNull()) return Heap::false_value(); |
| 894 ASSERT(proto->IsJSGlobalObject()); |
| 895 obj = JSObject::cast(proto); |
| 896 } |
| 897 return obj->map()->is_extensible() ? Heap::true_value() |
| 891 : Heap::false_value(); | 898 : Heap::false_value(); |
| 892 } | 899 } |
| 893 | 900 |
| 894 | 901 |
| 895 static MaybeObject* Runtime_RegExpCompile(Arguments args) { | 902 static MaybeObject* Runtime_RegExpCompile(Arguments args) { |
| 896 HandleScope scope; | 903 HandleScope scope; |
| 897 ASSERT(args.length() == 3); | 904 ASSERT(args.length() == 3); |
| 898 CONVERT_ARG_CHECKED(JSRegExp, re, 0); | 905 CONVERT_ARG_CHECKED(JSRegExp, re, 0); |
| 899 CONVERT_ARG_CHECKED(String, pattern, 1); | 906 CONVERT_ARG_CHECKED(String, pattern, 1); |
| 900 CONVERT_ARG_CHECKED(String, flags, 2); | 907 CONVERT_ARG_CHECKED(String, flags, 2); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 // that claims the property is absent. | 1082 // that claims the property is absent. |
| 1076 | 1083 |
| 1077 // Check for conflicting re-declarations. We cannot have | 1084 // Check for conflicting re-declarations. We cannot have |
| 1078 // conflicting types in case of intercepted properties because | 1085 // conflicting types in case of intercepted properties because |
| 1079 // they are absent. | 1086 // they are absent. |
| 1080 if (lookup.type() != INTERCEPTOR && | 1087 if (lookup.type() != INTERCEPTOR && |
| 1081 (lookup.IsReadOnly() || is_const_property)) { | 1088 (lookup.IsReadOnly() || is_const_property)) { |
| 1082 const char* type = (lookup.IsReadOnly()) ? "const" : "var"; | 1089 const char* type = (lookup.IsReadOnly()) ? "const" : "var"; |
| 1083 return ThrowRedeclarationError(type, name); | 1090 return ThrowRedeclarationError(type, name); |
| 1084 } | 1091 } |
| 1085 SetProperty(global, name, value, attributes); | 1092 Handle<Object> result = SetProperty(global, name, value, attributes); |
| 1093 if (result.is_null()) { |
| 1094 ASSERT(Top::has_pending_exception()); |
| 1095 return Failure::Exception(); |
| 1096 } |
| 1086 } else { | 1097 } else { |
| 1087 // If a property with this name does not already exist on the | 1098 // If a property with this name does not already exist on the |
| 1088 // global object add the property locally. We take special | 1099 // global object add the property locally. We take special |
| 1089 // precautions to always add it as a local property even in case | 1100 // precautions to always add it as a local property even in case |
| 1090 // of callbacks in the prototype chain (this rules out using | 1101 // of callbacks in the prototype chain (this rules out using |
| 1091 // SetProperty). Also, we must use the handle-based version to | 1102 // SetProperty). Also, we must use the handle-based version to |
| 1092 // avoid GC issues. | 1103 // avoid GC issues. |
| 1093 SetLocalPropertyIgnoreAttributes(global, name, value, attributes); | 1104 Handle<Object> result = |
| 1105 SetLocalPropertyIgnoreAttributes(global, name, value, attributes); |
| 1106 if (result.is_null()) { |
| 1107 ASSERT(Top::has_pending_exception()); |
| 1108 return Failure::Exception(); |
| 1109 } |
| 1094 } | 1110 } |
| 1095 } | 1111 } |
| 1096 | 1112 |
| 1113 ASSERT(!Top::has_pending_exception()); |
| 1097 return Heap::undefined_value(); | 1114 return Heap::undefined_value(); |
| 1098 } | 1115 } |
| 1099 | 1116 |
| 1100 | 1117 |
| 1101 static MaybeObject* Runtime_DeclareContextSlot(Arguments args) { | 1118 static MaybeObject* Runtime_DeclareContextSlot(Arguments args) { |
| 1102 HandleScope scope; | 1119 HandleScope scope; |
| 1103 ASSERT(args.length() == 4); | 1120 ASSERT(args.length() == 4); |
| 1104 | 1121 |
| 1105 CONVERT_ARG_CHECKED(Context, context, 0); | 1122 CONVERT_ARG_CHECKED(Context, context, 0); |
| 1106 Handle<String> name(String::cast(args[1])); | 1123 Handle<String> name(String::cast(args[1])); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1136 // the function context or the arguments object. | 1153 // the function context or the arguments object. |
| 1137 if (holder->IsContext()) { | 1154 if (holder->IsContext()) { |
| 1138 ASSERT(holder.is_identical_to(context)); | 1155 ASSERT(holder.is_identical_to(context)); |
| 1139 if (((attributes & READ_ONLY) == 0) || | 1156 if (((attributes & READ_ONLY) == 0) || |
| 1140 context->get(index)->IsTheHole()) { | 1157 context->get(index)->IsTheHole()) { |
| 1141 context->set(index, *initial_value); | 1158 context->set(index, *initial_value); |
| 1142 } | 1159 } |
| 1143 } else { | 1160 } else { |
| 1144 // The holder is an arguments object. | 1161 // The holder is an arguments object. |
| 1145 Handle<JSObject> arguments(Handle<JSObject>::cast(holder)); | 1162 Handle<JSObject> arguments(Handle<JSObject>::cast(holder)); |
| 1146 SetElement(arguments, index, initial_value); | 1163 Handle<Object> result = SetElement(arguments, index, initial_value); |
| 1164 if (result.is_null()) return Failure::Exception(); |
| 1147 } | 1165 } |
| 1148 } else { | 1166 } else { |
| 1149 // Slow case: The property is not in the FixedArray part of the context. | 1167 // Slow case: The property is not in the FixedArray part of the context. |
| 1150 Handle<JSObject> context_ext = Handle<JSObject>::cast(holder); | 1168 Handle<JSObject> context_ext = Handle<JSObject>::cast(holder); |
| 1151 SetProperty(context_ext, name, initial_value, mode); | 1169 Handle<Object> result = |
| 1170 SetProperty(context_ext, name, initial_value, mode); |
| 1171 if (result.is_null()) return Failure::Exception(); |
| 1152 } | 1172 } |
| 1153 } | 1173 } |
| 1154 | 1174 |
| 1155 } else { | 1175 } else { |
| 1156 // The property is not in the function context. It needs to be | 1176 // The property is not in the function context. It needs to be |
| 1157 // "declared" in the function context's extension context, or in the | 1177 // "declared" in the function context's extension context, or in the |
| 1158 // global context. | 1178 // global context. |
| 1159 Handle<JSObject> context_ext; | 1179 Handle<JSObject> context_ext; |
| 1160 if (context->has_extension()) { | 1180 if (context->has_extension()) { |
| 1161 // The function context's extension context exists - use it. | 1181 // The function context's extension context exists - use it. |
| 1162 context_ext = Handle<JSObject>(context->extension()); | 1182 context_ext = Handle<JSObject>(context->extension()); |
| 1163 } else { | 1183 } else { |
| 1164 // The function context's extension context does not exists - allocate | 1184 // The function context's extension context does not exists - allocate |
| 1165 // it. | 1185 // it. |
| 1166 context_ext = Factory::NewJSObject(Top::context_extension_function()); | 1186 context_ext = Factory::NewJSObject(Top::context_extension_function()); |
| 1167 // And store it in the extension slot. | 1187 // And store it in the extension slot. |
| 1168 context->set_extension(*context_ext); | 1188 context->set_extension(*context_ext); |
| 1169 } | 1189 } |
| 1170 ASSERT(*context_ext != NULL); | 1190 ASSERT(*context_ext != NULL); |
| 1171 | 1191 |
| 1172 // Declare the property by setting it to the initial value if provided, | 1192 // Declare the property by setting it to the initial value if provided, |
| 1173 // or undefined, and use the correct mode (e.g. READ_ONLY attribute for | 1193 // or undefined, and use the correct mode (e.g. READ_ONLY attribute for |
| 1174 // constant declarations). | 1194 // constant declarations). |
| 1175 ASSERT(!context_ext->HasLocalProperty(*name)); | 1195 ASSERT(!context_ext->HasLocalProperty(*name)); |
| 1176 Handle<Object> value(Heap::undefined_value()); | 1196 Handle<Object> value(Heap::undefined_value()); |
| 1177 if (*initial_value != NULL) value = initial_value; | 1197 if (*initial_value != NULL) value = initial_value; |
| 1178 SetProperty(context_ext, name, value, mode); | 1198 Handle<Object> result = SetProperty(context_ext, name, value, mode); |
| 1179 ASSERT(context_ext->GetLocalPropertyAttribute(*name) == mode); | 1199 if (result.is_null()) return Failure::Exception(); |
| 1180 } | 1200 } |
| 1181 | 1201 |
| 1182 return Heap::undefined_value(); | 1202 return Heap::undefined_value(); |
| 1183 } | 1203 } |
| 1184 | 1204 |
| 1185 | 1205 |
| 1186 static MaybeObject* Runtime_InitializeVarGlobal(Arguments args) { | 1206 static MaybeObject* Runtime_InitializeVarGlobal(Arguments args) { |
| 1187 NoHandleAllocation nha; | 1207 NoHandleAllocation nha; |
| 1188 | 1208 |
| 1189 // Determine if we need to assign to the variable if it already | 1209 // Determine if we need to assign to the variable if it already |
| (...skipping 2471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3661 // Check if this is an element. | 3681 // Check if this is an element. |
| 3662 uint32_t index; | 3682 uint32_t index; |
| 3663 bool is_element = name->AsArrayIndex(&index); | 3683 bool is_element = name->AsArrayIndex(&index); |
| 3664 | 3684 |
| 3665 // Special case for elements if any of the flags are true. | 3685 // Special case for elements if any of the flags are true. |
| 3666 // If elements are in fast case we always implicitly assume that: | 3686 // If elements are in fast case we always implicitly assume that: |
| 3667 // DONT_DELETE: false, DONT_ENUM: false, READ_ONLY: false. | 3687 // DONT_DELETE: false, DONT_ENUM: false, READ_ONLY: false. |
| 3668 if (((unchecked & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0) && | 3688 if (((unchecked & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0) && |
| 3669 is_element) { | 3689 is_element) { |
| 3670 // Normalize the elements to enable attributes on the property. | 3690 // Normalize the elements to enable attributes on the property. |
| 3671 if (!js_object->IsJSGlobalProxy()) { | 3691 if (js_object->IsJSGlobalProxy()) { |
| 3672 NormalizeElements(js_object); | 3692 Handle<Object> proto(js_object->GetPrototype()); |
| 3693 // If proxy is detached, ignore the assignment. Alternatively, |
| 3694 // we could throw an exception. |
| 3695 if (proto->IsNull()) return *obj_value; |
| 3696 js_object = Handle<JSObject>::cast(proto); |
| 3673 } | 3697 } |
| 3698 NormalizeElements(js_object); |
| 3674 Handle<NumberDictionary> dictionary(js_object->element_dictionary()); | 3699 Handle<NumberDictionary> dictionary(js_object->element_dictionary()); |
| 3675 // Make sure that we never go back to fast case. | 3700 // Make sure that we never go back to fast case. |
| 3676 dictionary->set_requires_slow_elements(); | 3701 dictionary->set_requires_slow_elements(); |
| 3677 PropertyDetails details = PropertyDetails(attr, NORMAL); | 3702 PropertyDetails details = PropertyDetails(attr, NORMAL); |
| 3678 NumberDictionarySet(dictionary, index, obj_value, details); | 3703 NumberDictionarySet(dictionary, index, obj_value, details); |
| 3704 return *obj_value; |
| 3679 } | 3705 } |
| 3680 | 3706 |
| 3681 LookupResult result; | 3707 LookupResult result; |
| 3682 js_object->LookupRealNamedProperty(*name, &result); | 3708 js_object->LookupRealNamedProperty(*name, &result); |
| 3683 | 3709 |
| 3684 // Take special care when attributes are different and there is already | 3710 // Take special care when attributes are different and there is already |
| 3685 // a property. For simplicity we normalize the property which enables us | 3711 // a property. For simplicity we normalize the property which enables us |
| 3686 // to not worry about changing the instance_descriptor and creating a new | 3712 // to not worry about changing the instance_descriptor and creating a new |
| 3687 // map. The current version of SetObjectProperty does not handle attributes | 3713 // map. The current version of SetObjectProperty does not handle attributes |
| 3688 // correctly in the case where a property is a field and is reset with | 3714 // correctly in the case where a property is a field and is reset with |
| 3689 // new attributes. | 3715 // new attributes. |
| 3690 if (result.IsProperty() && | 3716 if (result.IsProperty() && |
| 3691 (attr != result.GetAttributes() || result.type() == CALLBACKS)) { | 3717 (attr != result.GetAttributes() || result.type() == CALLBACKS)) { |
| 3692 // New attributes - normalize to avoid writing to instance descriptor | 3718 // New attributes - normalize to avoid writing to instance descriptor |
| 3693 if (!js_object->IsJSGlobalProxy()) { | 3719 if (js_object->IsJSGlobalProxy()) { |
| 3694 NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); | 3720 // Since the result is a property, the prototype will exist so |
| 3721 // we don't have to check for null. |
| 3722 js_object = Handle<JSObject>(JSObject::cast(js_object->GetPrototype())); |
| 3695 } | 3723 } |
| 3724 NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); |
| 3696 // Use IgnoreAttributes version since a readonly property may be | 3725 // Use IgnoreAttributes version since a readonly property may be |
| 3697 // overridden and SetProperty does not allow this. | 3726 // overridden and SetProperty does not allow this. |
| 3698 return js_object->SetLocalPropertyIgnoreAttributes(*name, | 3727 return js_object->SetLocalPropertyIgnoreAttributes(*name, |
| 3699 *obj_value, | 3728 *obj_value, |
| 3700 attr); | 3729 attr); |
| 3701 } | 3730 } |
| 3702 | 3731 |
| 3703 return Runtime::SetObjectProperty(js_object, name, obj_value, attr); | 3732 return Runtime::SetObjectProperty(js_object, name, obj_value, attr); |
| 3704 } | 3733 } |
| 3705 | 3734 |
| (...skipping 2968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6674 // directly to properties. | 6703 // directly to properties. |
| 6675 pretenure = pretenure || (context->global_context() == *context); | 6704 pretenure = pretenure || (context->global_context() == *context); |
| 6676 PretenureFlag pretenure_flag = pretenure ? TENURED : NOT_TENURED; | 6705 PretenureFlag pretenure_flag = pretenure ? TENURED : NOT_TENURED; |
| 6677 Handle<JSFunction> result = | 6706 Handle<JSFunction> result = |
| 6678 Factory::NewFunctionFromSharedFunctionInfo(shared, | 6707 Factory::NewFunctionFromSharedFunctionInfo(shared, |
| 6679 context, | 6708 context, |
| 6680 pretenure_flag); | 6709 pretenure_flag); |
| 6681 return *result; | 6710 return *result; |
| 6682 } | 6711 } |
| 6683 | 6712 |
| 6713 |
| 6684 static MaybeObject* Runtime_NewObjectFromBound(Arguments args) { | 6714 static MaybeObject* Runtime_NewObjectFromBound(Arguments args) { |
| 6685 HandleScope scope; | 6715 HandleScope scope; |
| 6686 ASSERT(args.length() == 2); | 6716 ASSERT(args.length() == 2); |
| 6717 // First argument is a function to use as a constructor. |
| 6687 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 6718 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
| 6688 CONVERT_ARG_CHECKED(JSArray, params, 1); | |
| 6689 | 6719 |
| 6690 RUNTIME_ASSERT(params->HasFastElements()); | 6720 // Second argument is either null or an array of bound arguments. |
| 6691 FixedArray* fixed = FixedArray::cast(params->elements()); | 6721 FixedArray* bound_args = NULL; |
| 6722 int bound_argc = 0; |
| 6723 if (!args[1]->IsNull()) { |
| 6724 CONVERT_ARG_CHECKED(JSArray, params, 1); |
| 6725 RUNTIME_ASSERT(params->HasFastElements()); |
| 6726 bound_args = FixedArray::cast(params->elements()); |
| 6727 bound_argc = Smi::cast(params->length())->value(); |
| 6728 } |
| 6692 | 6729 |
| 6693 int fixed_length = Smi::cast(params->length())->value(); | 6730 // Find frame containing arguments passed to the caller. |
| 6694 SmartPointer<Object**> param_data(NewArray<Object**>(fixed_length)); | 6731 JavaScriptFrameIterator it; |
| 6695 for (int i = 0; i < fixed_length; i++) { | 6732 JavaScriptFrame* frame = it.frame(); |
| 6696 Handle<Object> val = Handle<Object>(fixed->get(i)); | 6733 ASSERT(!frame->is_optimized()); |
| 6734 it.AdvanceToArgumentsFrame(); |
| 6735 frame = it.frame(); |
| 6736 int argc = frame->GetProvidedParametersCount(); |
| 6737 |
| 6738 // Prepend bound arguments to caller's arguments. |
| 6739 int total_argc = bound_argc + argc; |
| 6740 SmartPointer<Object**> param_data(NewArray<Object**>(total_argc)); |
| 6741 for (int i = 0; i < bound_argc; i++) { |
| 6742 Handle<Object> val = Handle<Object>(bound_args->get(i)); |
| 6697 param_data[i] = val.location(); | 6743 param_data[i] = val.location(); |
| 6698 } | 6744 } |
| 6745 for (int i = 0; i < argc; i++) { |
| 6746 Handle<Object> val = Handle<Object>(frame->GetParameter(i)); |
| 6747 param_data[bound_argc + i] = val.location(); |
| 6748 } |
| 6699 | 6749 |
| 6700 bool exception = false; | 6750 bool exception = false; |
| 6701 Handle<Object> result = Execution::New( | 6751 Handle<Object> result = |
| 6702 function, fixed_length, *param_data, &exception); | 6752 Execution::New(function, total_argc, *param_data, &exception); |
| 6703 if (exception) { | 6753 if (exception) { |
| 6704 return Failure::Exception(); | 6754 return Failure::Exception(); |
| 6705 } | 6755 } |
| 6756 |
| 6706 ASSERT(!result.is_null()); | 6757 ASSERT(!result.is_null()); |
| 6707 return *result; | 6758 return *result; |
| 6708 } | 6759 } |
| 6709 | 6760 |
| 6710 | 6761 |
| 6711 static void TrySettingInlineConstructStub(Handle<JSFunction> function) { | 6762 static void TrySettingInlineConstructStub(Handle<JSFunction> function) { |
| 6712 Handle<Object> prototype = Factory::null_value(); | 6763 Handle<Object> prototype = Factory::null_value(); |
| 6713 if (function->has_instance_prototype()) { | 6764 if (function->has_instance_prototype()) { |
| 6714 prototype = Handle<Object>(function->instance_prototype()); | 6765 prototype = Handle<Object>(function->instance_prototype()); |
| 6715 } | 6766 } |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7333 | 7384 |
| 7334 int index; | 7385 int index; |
| 7335 PropertyAttributes attributes; | 7386 PropertyAttributes attributes; |
| 7336 ContextLookupFlags flags = FOLLOW_CHAINS; | 7387 ContextLookupFlags flags = FOLLOW_CHAINS; |
| 7337 Handle<Object> holder = context->Lookup(name, flags, &index, &attributes); | 7388 Handle<Object> holder = context->Lookup(name, flags, &index, &attributes); |
| 7338 | 7389 |
| 7339 if (index >= 0) { | 7390 if (index >= 0) { |
| 7340 if (holder->IsContext()) { | 7391 if (holder->IsContext()) { |
| 7341 // Ignore if read_only variable. | 7392 // Ignore if read_only variable. |
| 7342 if ((attributes & READ_ONLY) == 0) { | 7393 if ((attributes & READ_ONLY) == 0) { |
| 7343 Handle<Context>::cast(holder)->set(index, *value); | 7394 // Context is a fixed array and set cannot fail. |
| 7395 Context::cast(*holder)->set(index, *value); |
| 7344 } | 7396 } |
| 7345 } else { | 7397 } else { |
| 7346 ASSERT((attributes & READ_ONLY) == 0); | 7398 ASSERT((attributes & READ_ONLY) == 0); |
| 7347 Handle<JSObject>::cast(holder)->SetElement(index, *value)-> | 7399 Handle<Object> result = |
| 7348 ToObjectUnchecked(); | 7400 SetElement(Handle<JSObject>::cast(holder), index, value); |
| 7401 if (result.is_null()) { |
| 7402 ASSERT(Top::has_pending_exception()); |
| 7403 return Failure::Exception(); |
| 7404 } |
| 7349 } | 7405 } |
| 7350 return *value; | 7406 return *value; |
| 7351 } | 7407 } |
| 7352 | 7408 |
| 7353 // Slow case: The property is not in a FixedArray context. | 7409 // Slow case: The property is not in a FixedArray context. |
| 7354 // It is either in an JSObject extension context or it was not found. | 7410 // It is either in an JSObject extension context or it was not found. |
| 7355 Handle<JSObject> context_ext; | 7411 Handle<JSObject> context_ext; |
| 7356 | 7412 |
| 7357 if (!holder.is_null()) { | 7413 if (!holder.is_null()) { |
| 7358 // The property exists in the extension context. | 7414 // The property exists in the extension context. |
| 7359 context_ext = Handle<JSObject>::cast(holder); | 7415 context_ext = Handle<JSObject>::cast(holder); |
| 7360 } else { | 7416 } else { |
| 7361 // The property was not found. It needs to be stored in the global context. | 7417 // The property was not found. It needs to be stored in the global context. |
| 7362 ASSERT(attributes == ABSENT); | 7418 ASSERT(attributes == ABSENT); |
| 7363 attributes = NONE; | 7419 attributes = NONE; |
| 7364 context_ext = Handle<JSObject>(Top::context()->global()); | 7420 context_ext = Handle<JSObject>(Top::context()->global()); |
| 7365 } | 7421 } |
| 7366 | 7422 |
| 7367 // Set the property, but ignore if read_only variable on the context | 7423 // Set the property, but ignore if read_only variable on the context |
| 7368 // extension object itself. | 7424 // extension object itself. |
| 7369 if ((attributes & READ_ONLY) == 0 || | 7425 if ((attributes & READ_ONLY) == 0 || |
| 7370 (context_ext->GetLocalPropertyAttribute(*name) == ABSENT)) { | 7426 (context_ext->GetLocalPropertyAttribute(*name) == ABSENT)) { |
| 7371 Handle<Object> set = SetProperty(context_ext, name, value, NONE); | 7427 Handle<Object> result = SetProperty(context_ext, name, value, NONE); |
| 7372 if (set.is_null()) { | 7428 if (result.is_null()) { |
| 7373 // Failure::Exception is converted to a null handle in the | 7429 // Failure::Exception is converted to a null handle in the |
| 7374 // handle-based methods such as SetProperty. We therefore need | 7430 // handle-based methods such as SetProperty. We therefore need |
| 7375 // to convert null handles back to exceptions. | 7431 // to convert null handles back to exceptions. |
| 7376 ASSERT(Top::has_pending_exception()); | 7432 ASSERT(Top::has_pending_exception()); |
| 7377 return Failure::Exception(); | 7433 return Failure::Exception(); |
| 7378 } | 7434 } |
| 7379 } | 7435 } |
| 7380 return *value; | 7436 return *value; |
| 7381 } | 7437 } |
| 7382 | 7438 |
| (...skipping 3662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11045 } else { | 11101 } else { |
| 11046 // Handle last resort GC and make sure to allow future allocations | 11102 // Handle last resort GC and make sure to allow future allocations |
| 11047 // to grow the heap without causing GCs (if possible). | 11103 // to grow the heap without causing GCs (if possible). |
| 11048 Counters::gc_last_resort_from_js.Increment(); | 11104 Counters::gc_last_resort_from_js.Increment(); |
| 11049 Heap::CollectAllGarbage(false); | 11105 Heap::CollectAllGarbage(false); |
| 11050 } | 11106 } |
| 11051 } | 11107 } |
| 11052 | 11108 |
| 11053 | 11109 |
| 11054 } } // namespace v8::internal | 11110 } } // namespace v8::internal |
| OLD | NEW |