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 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1136 // the function context or the arguments object. | 1136 // the function context or the arguments object. |
1137 if (holder->IsContext()) { | 1137 if (holder->IsContext()) { |
1138 ASSERT(holder.is_identical_to(context)); | 1138 ASSERT(holder.is_identical_to(context)); |
1139 if (((attributes & READ_ONLY) == 0) || | 1139 if (((attributes & READ_ONLY) == 0) || |
1140 context->get(index)->IsTheHole()) { | 1140 context->get(index)->IsTheHole()) { |
1141 context->set(index, *initial_value); | 1141 context->set(index, *initial_value); |
1142 } | 1142 } |
1143 } else { | 1143 } else { |
1144 // The holder is an arguments object. | 1144 // The holder is an arguments object. |
1145 Handle<JSObject> arguments(Handle<JSObject>::cast(holder)); | 1145 Handle<JSObject> arguments(Handle<JSObject>::cast(holder)); |
1146 SetElement(arguments, index, initial_value); | 1146 Handle<Object> result = SetElement(arguments, index, initial_value); |
| 1147 if (result.is_null()) return Failure::Exception(); |
1147 } | 1148 } |
1148 } else { | 1149 } else { |
1149 // Slow case: The property is not in the FixedArray part of the context. | 1150 // Slow case: The property is not in the FixedArray part of the context. |
1150 Handle<JSObject> context_ext = Handle<JSObject>::cast(holder); | 1151 Handle<JSObject> context_ext = Handle<JSObject>::cast(holder); |
1151 SetProperty(context_ext, name, initial_value, mode); | 1152 Handle<Object> result = |
| 1153 SetProperty(context_ext, name, initial_value, mode); |
| 1154 if (result.is_null()) return Failure::Exception(); |
1152 } | 1155 } |
1153 } | 1156 } |
1154 | 1157 |
1155 } else { | 1158 } else { |
1156 // The property is not in the function context. It needs to be | 1159 // The property is not in the function context. It needs to be |
1157 // "declared" in the function context's extension context, or in the | 1160 // "declared" in the function context's extension context, or in the |
1158 // global context. | 1161 // global context. |
1159 Handle<JSObject> context_ext; | 1162 Handle<JSObject> context_ext; |
1160 if (context->has_extension()) { | 1163 if (context->has_extension()) { |
1161 // The function context's extension context exists - use it. | 1164 // The function context's extension context exists - use it. |
1162 context_ext = Handle<JSObject>(context->extension()); | 1165 context_ext = Handle<JSObject>(context->extension()); |
1163 } else { | 1166 } else { |
1164 // The function context's extension context does not exists - allocate | 1167 // The function context's extension context does not exists - allocate |
1165 // it. | 1168 // it. |
1166 context_ext = Factory::NewJSObject(Top::context_extension_function()); | 1169 context_ext = Factory::NewJSObject(Top::context_extension_function()); |
1167 // And store it in the extension slot. | 1170 // And store it in the extension slot. |
1168 context->set_extension(*context_ext); | 1171 context->set_extension(*context_ext); |
1169 } | 1172 } |
1170 ASSERT(*context_ext != NULL); | 1173 ASSERT(*context_ext != NULL); |
1171 | 1174 |
1172 // Declare the property by setting it to the initial value if provided, | 1175 // 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 | 1176 // or undefined, and use the correct mode (e.g. READ_ONLY attribute for |
1174 // constant declarations). | 1177 // constant declarations). |
1175 ASSERT(!context_ext->HasLocalProperty(*name)); | 1178 ASSERT(!context_ext->HasLocalProperty(*name)); |
1176 Handle<Object> value(Heap::undefined_value()); | 1179 Handle<Object> value(Heap::undefined_value()); |
1177 if (*initial_value != NULL) value = initial_value; | 1180 if (*initial_value != NULL) value = initial_value; |
1178 SetProperty(context_ext, name, value, mode); | 1181 Handle<Object> result = SetProperty(context_ext, name, value, mode); |
1179 ASSERT(context_ext->GetLocalPropertyAttribute(*name) == mode); | 1182 if (result.is_null()) return Failure::Exception(); |
1180 } | 1183 } |
1181 | 1184 |
1182 return Heap::undefined_value(); | 1185 return Heap::undefined_value(); |
1183 } | 1186 } |
1184 | 1187 |
1185 | 1188 |
1186 static MaybeObject* Runtime_InitializeVarGlobal(Arguments args) { | 1189 static MaybeObject* Runtime_InitializeVarGlobal(Arguments args) { |
1187 NoHandleAllocation nha; | 1190 NoHandleAllocation nha; |
1188 | 1191 |
1189 // Determine if we need to assign to the variable if it already | 1192 // Determine if we need to assign to the variable if it already |
(...skipping 9877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11067 } else { | 11070 } else { |
11068 // Handle last resort GC and make sure to allow future allocations | 11071 // Handle last resort GC and make sure to allow future allocations |
11069 // to grow the heap without causing GCs (if possible). | 11072 // to grow the heap without causing GCs (if possible). |
11070 Counters::gc_last_resort_from_js.Increment(); | 11073 Counters::gc_last_resort_from_js.Increment(); |
11071 Heap::CollectAllGarbage(false); | 11074 Heap::CollectAllGarbage(false); |
11072 } | 11075 } |
11073 } | 11076 } |
11074 | 11077 |
11075 | 11078 |
11076 } } // namespace v8::internal | 11079 } } // namespace v8::internal |
OLD | NEW |