| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 // an array. | 153 // an array. |
| 154 if (attributes != NONE) continue; | 154 if (attributes != NONE) continue; |
| 155 Object* value = | 155 Object* value = |
| 156 copy->GetProperty(key_string, &attributes)->ToObjectUnchecked(); | 156 copy->GetProperty(key_string, &attributes)->ToObjectUnchecked(); |
| 157 if (value->IsJSObject()) { | 157 if (value->IsJSObject()) { |
| 158 JSObject* js_object = JSObject::cast(value); | 158 JSObject* js_object = JSObject::cast(value); |
| 159 { MaybeObject* maybe_result = DeepCopyBoilerplate(js_object); | 159 { MaybeObject* maybe_result = DeepCopyBoilerplate(js_object); |
| 160 if (!maybe_result->ToObject(&result)) return maybe_result; | 160 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 161 } | 161 } |
| 162 { MaybeObject* maybe_result = | 162 { MaybeObject* maybe_result = |
| 163 copy->SetProperty(key_string, result, NONE); | 163 // Creating object copy for literals. No strict mode needed. |
| 164 copy->SetProperty(key_string, result, NONE, kNonStrictMode); |
| 164 if (!maybe_result->ToObject(&result)) return maybe_result; | 165 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 165 } | 166 } |
| 166 } | 167 } |
| 167 } | 168 } |
| 168 } | 169 } |
| 169 | 170 |
| 170 // Deep copy local elements. | 171 // Deep copy local elements. |
| 171 // Pixel elements cannot be created using an object literal. | 172 // Pixel elements cannot be created using an object literal. |
| 172 ASSERT(!copy->HasPixelElements() && !copy->HasExternalArrayElements()); | 173 ASSERT(!copy->HasPixelElements() && !copy->HasExternalArrayElements()); |
| 173 switch (copy->GetElementsKind()) { | 174 switch (copy->GetElementsKind()) { |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 // Create a catch context extension object. | 540 // Create a catch context extension object. |
| 540 JSFunction* constructor = | 541 JSFunction* constructor = |
| 541 Top::context()->global_context()->context_extension_function(); | 542 Top::context()->global_context()->context_extension_function(); |
| 542 Object* object; | 543 Object* object; |
| 543 { MaybeObject* maybe_object = Heap::AllocateJSObject(constructor); | 544 { MaybeObject* maybe_object = Heap::AllocateJSObject(constructor); |
| 544 if (!maybe_object->ToObject(&object)) return maybe_object; | 545 if (!maybe_object->ToObject(&object)) return maybe_object; |
| 545 } | 546 } |
| 546 // Assign the exception value to the catch variable and make sure | 547 // Assign the exception value to the catch variable and make sure |
| 547 // that the catch variable is DontDelete. | 548 // that the catch variable is DontDelete. |
| 548 { MaybeObject* maybe_value = | 549 { MaybeObject* maybe_value = |
| 549 JSObject::cast(object)->SetProperty(key, value, DONT_DELETE); | 550 // Passing non-strict per Ecma-262 5th Ed. 12.14. Catch, bullet #4. |
| 551 JSObject::cast(object)->SetProperty( |
| 552 key, value, DONT_DELETE, kNonStrictMode); |
| 550 if (!maybe_value->ToObject(&value)) return maybe_value; | 553 if (!maybe_value->ToObject(&value)) return maybe_value; |
| 551 } | 554 } |
| 552 return object; | 555 return object; |
| 553 } | 556 } |
| 554 | 557 |
| 555 | 558 |
| 556 static MaybeObject* Runtime_ClassOf(Arguments args) { | 559 static MaybeObject* Runtime_ClassOf(Arguments args) { |
| 557 NoHandleAllocation ha; | 560 NoHandleAllocation ha; |
| 558 ASSERT(args.length() == 1); | 561 ASSERT(args.length() == 1); |
| 559 Object* obj = args[0]; | 562 Object* obj = args[0]; |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 HandleScope scope; | 990 HandleScope scope; |
| 988 Handle<Object> type_handle = Factory::NewStringFromAscii(CStrVector(type)); | 991 Handle<Object> type_handle = Factory::NewStringFromAscii(CStrVector(type)); |
| 989 Handle<Object> args[2] = { type_handle, name }; | 992 Handle<Object> args[2] = { type_handle, name }; |
| 990 Handle<Object> error = | 993 Handle<Object> error = |
| 991 Factory::NewTypeError("redeclaration", HandleVector(args, 2)); | 994 Factory::NewTypeError("redeclaration", HandleVector(args, 2)); |
| 992 return Top::Throw(*error); | 995 return Top::Throw(*error); |
| 993 } | 996 } |
| 994 | 997 |
| 995 | 998 |
| 996 static MaybeObject* Runtime_DeclareGlobals(Arguments args) { | 999 static MaybeObject* Runtime_DeclareGlobals(Arguments args) { |
| 1000 ASSERT(args.length() == 4); |
| 997 HandleScope scope; | 1001 HandleScope scope; |
| 998 Handle<GlobalObject> global = Handle<GlobalObject>(Top::context()->global()); | 1002 Handle<GlobalObject> global = Handle<GlobalObject>(Top::context()->global()); |
| 999 | 1003 |
| 1000 Handle<Context> context = args.at<Context>(0); | 1004 Handle<Context> context = args.at<Context>(0); |
| 1001 CONVERT_ARG_CHECKED(FixedArray, pairs, 1); | 1005 CONVERT_ARG_CHECKED(FixedArray, pairs, 1); |
| 1002 bool is_eval = Smi::cast(args[2])->value() == 1; | 1006 bool is_eval = Smi::cast(args[2])->value() == 1; |
| 1007 StrictModeFlag strict_mode = |
| 1008 static_cast<StrictModeFlag>(Smi::cast(args[3])->value()); |
| 1009 ASSERT(strict_mode == kStrictMode || strict_mode == kNonStrictMode); |
| 1003 | 1010 |
| 1004 // Compute the property attributes. According to ECMA-262, section | 1011 // Compute the property attributes. According to ECMA-262, section |
| 1005 // 13, page 71, the property must be read-only and | 1012 // 13, page 71, the property must be read-only and |
| 1006 // non-deletable. However, neither SpiderMonkey nor KJS creates the | 1013 // non-deletable. However, neither SpiderMonkey nor KJS creates the |
| 1007 // property as read-only, so we don't either. | 1014 // property as read-only, so we don't either. |
| 1008 PropertyAttributes base = is_eval ? NONE : DONT_DELETE; | 1015 PropertyAttributes base = is_eval ? NONE : DONT_DELETE; |
| 1009 | 1016 |
| 1010 // Traverse the name/value pairs and set the properties. | 1017 // Traverse the name/value pairs and set the properties. |
| 1011 int length = pairs->length(); | 1018 int length = pairs->length(); |
| 1012 for (int i = 0; i < length; i += 2) { | 1019 for (int i = 0; i < length; i += 2) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 // difference for global functions with the same names as event | 1109 // difference for global functions with the same names as event |
| 1103 // handlers such as "function onload() {}". Firefox does call the | 1110 // handlers such as "function onload() {}". Firefox does call the |
| 1104 // onload setter in those case and Safari does not. We follow | 1111 // onload setter in those case and Safari does not. We follow |
| 1105 // Safari for compatibility. | 1112 // Safari for compatibility. |
| 1106 if (value->IsJSFunction()) { | 1113 if (value->IsJSFunction()) { |
| 1107 RETURN_IF_EMPTY_HANDLE(SetLocalPropertyIgnoreAttributes(global, | 1114 RETURN_IF_EMPTY_HANDLE(SetLocalPropertyIgnoreAttributes(global, |
| 1108 name, | 1115 name, |
| 1109 value, | 1116 value, |
| 1110 attributes)); | 1117 attributes)); |
| 1111 } else { | 1118 } else { |
| 1112 RETURN_IF_EMPTY_HANDLE(SetProperty(global, name, value, attributes)); | 1119 RETURN_IF_EMPTY_HANDLE(SetProperty(global, |
| 1120 name, |
| 1121 value, |
| 1122 attributes, |
| 1123 strict_mode)); |
| 1113 } | 1124 } |
| 1114 } | 1125 } |
| 1115 | 1126 |
| 1116 ASSERT(!Top::has_pending_exception()); | 1127 ASSERT(!Top::has_pending_exception()); |
| 1117 return Heap::undefined_value(); | 1128 return Heap::undefined_value(); |
| 1118 } | 1129 } |
| 1119 | 1130 |
| 1120 | 1131 |
| 1121 static MaybeObject* Runtime_DeclareContextSlot(Arguments args) { | 1132 static MaybeObject* Runtime_DeclareContextSlot(Arguments args) { |
| 1122 HandleScope scope; | 1133 HandleScope scope; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1163 } else { | 1174 } else { |
| 1164 // The holder is an arguments object. | 1175 // The holder is an arguments object. |
| 1165 Handle<JSObject> arguments(Handle<JSObject>::cast(holder)); | 1176 Handle<JSObject> arguments(Handle<JSObject>::cast(holder)); |
| 1166 Handle<Object> result = SetElement(arguments, index, initial_value); | 1177 Handle<Object> result = SetElement(arguments, index, initial_value); |
| 1167 if (result.is_null()) return Failure::Exception(); | 1178 if (result.is_null()) return Failure::Exception(); |
| 1168 } | 1179 } |
| 1169 } else { | 1180 } else { |
| 1170 // Slow case: The property is not in the FixedArray part of the context. | 1181 // Slow case: The property is not in the FixedArray part of the context. |
| 1171 Handle<JSObject> context_ext = Handle<JSObject>::cast(holder); | 1182 Handle<JSObject> context_ext = Handle<JSObject>::cast(holder); |
| 1172 RETURN_IF_EMPTY_HANDLE( | 1183 RETURN_IF_EMPTY_HANDLE( |
| 1173 SetProperty(context_ext, name, initial_value, mode)); | 1184 // TODO(mmaly): Runtime_DeclareContextSlot. Needs strict mode? |
| 1185 SetProperty(context_ext, name, initial_value, |
| 1186 mode, kNonStrictMode)); |
| 1174 } | 1187 } |
| 1175 } | 1188 } |
| 1176 | 1189 |
| 1177 } else { | 1190 } else { |
| 1178 // The property is not in the function context. It needs to be | 1191 // The property is not in the function context. It needs to be |
| 1179 // "declared" in the function context's extension context, or in the | 1192 // "declared" in the function context's extension context, or in the |
| 1180 // global context. | 1193 // global context. |
| 1181 Handle<JSObject> context_ext; | 1194 Handle<JSObject> context_ext; |
| 1182 if (context->has_extension()) { | 1195 if (context->has_extension()) { |
| 1183 // The function context's extension context exists - use it. | 1196 // The function context's extension context exists - use it. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1204 // SetProperty and no setters are invoked for those since they are | 1217 // SetProperty and no setters are invoked for those since they are |
| 1205 // not real JSObjects. | 1218 // not real JSObjects. |
| 1206 if (initial_value->IsTheHole() && | 1219 if (initial_value->IsTheHole() && |
| 1207 !context_ext->IsJSContextExtensionObject()) { | 1220 !context_ext->IsJSContextExtensionObject()) { |
| 1208 LookupResult lookup; | 1221 LookupResult lookup; |
| 1209 context_ext->Lookup(*name, &lookup); | 1222 context_ext->Lookup(*name, &lookup); |
| 1210 if (lookup.IsProperty() && (lookup.type() == CALLBACKS)) { | 1223 if (lookup.IsProperty() && (lookup.type() == CALLBACKS)) { |
| 1211 return ThrowRedeclarationError("const", name); | 1224 return ThrowRedeclarationError("const", name); |
| 1212 } | 1225 } |
| 1213 } | 1226 } |
| 1214 RETURN_IF_EMPTY_HANDLE(SetProperty(context_ext, name, value, mode)); | 1227 // TODO(mmaly): Runtime_DeclareContextSlot. Needs strict mode? |
| 1228 RETURN_IF_EMPTY_HANDLE(SetProperty(context_ext, name, value, mode, |
| 1229 kNonStrictMode)); |
| 1215 } | 1230 } |
| 1216 | 1231 |
| 1217 return Heap::undefined_value(); | 1232 return Heap::undefined_value(); |
| 1218 } | 1233 } |
| 1219 | 1234 |
| 1220 | 1235 |
| 1221 static MaybeObject* Runtime_InitializeVarGlobal(Arguments args) { | 1236 static MaybeObject* Runtime_InitializeVarGlobal(Arguments args) { |
| 1222 NoHandleAllocation nha; | 1237 NoHandleAllocation nha; |
| 1238 // args[0] == name |
| 1239 // args[1] == strict_mode |
| 1240 // args[2] == value |
| 1223 | 1241 |
| 1224 // Determine if we need to assign to the variable if it already | 1242 // Determine if we need to assign to the variable if it already |
| 1225 // exists (based on the number of arguments). | 1243 // exists (based on the number of arguments). |
| 1226 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); | 1244 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); |
| 1227 bool assign = args.length() == 2; | 1245 bool assign = args.length() == 3; |
| 1228 | 1246 |
| 1229 CONVERT_ARG_CHECKED(String, name, 0); | 1247 CONVERT_ARG_CHECKED(String, name, 0); |
| 1230 GlobalObject* global = Top::context()->global(); | 1248 GlobalObject* global = Top::context()->global(); |
| 1249 RUNTIME_ASSERT(args[1]->IsSmi()); |
| 1250 StrictModeFlag strict_mode = |
| 1251 static_cast<StrictModeFlag>(Smi::cast(args[1])->value()); |
| 1252 ASSERT(strict_mode == kStrictMode || strict_mode == kNonStrictMode); |
| 1231 | 1253 |
| 1232 // According to ECMA-262, section 12.2, page 62, the property must | 1254 // According to ECMA-262, section 12.2, page 62, the property must |
| 1233 // not be deletable. | 1255 // not be deletable. |
| 1234 PropertyAttributes attributes = DONT_DELETE; | 1256 PropertyAttributes attributes = DONT_DELETE; |
| 1235 | 1257 |
| 1236 // Lookup the property locally in the global object. If it isn't | 1258 // Lookup the property locally in the global object. If it isn't |
| 1237 // there, there is a property with this name in the prototype chain. | 1259 // there, there is a property with this name in the prototype chain. |
| 1238 // We follow Safari and Firefox behavior and only set the property | 1260 // We follow Safari and Firefox behavior and only set the property |
| 1239 // locally if there is an explicit initialization value that we have | 1261 // locally if there is an explicit initialization value that we have |
| 1240 // to assign to the property. | 1262 // to assign to the property. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1276 } | 1298 } |
| 1277 } | 1299 } |
| 1278 | 1300 |
| 1279 if (found && !assign) { | 1301 if (found && !assign) { |
| 1280 // The global property is there and we're not assigning any value | 1302 // The global property is there and we're not assigning any value |
| 1281 // to it. Just return. | 1303 // to it. Just return. |
| 1282 return Heap::undefined_value(); | 1304 return Heap::undefined_value(); |
| 1283 } | 1305 } |
| 1284 | 1306 |
| 1285 // Assign the value (or undefined) to the property. | 1307 // Assign the value (or undefined) to the property. |
| 1286 Object* value = (assign) ? args[1] : Heap::undefined_value(); | 1308 Object* value = (assign) ? args[2] : Heap::undefined_value(); |
| 1287 return real_holder->SetProperty(&lookup, *name, value, attributes); | 1309 return real_holder->SetProperty( |
| 1310 &lookup, *name, value, attributes, strict_mode); |
| 1288 } | 1311 } |
| 1289 | 1312 |
| 1290 Object* proto = real_holder->GetPrototype(); | 1313 Object* proto = real_holder->GetPrototype(); |
| 1291 if (!proto->IsJSObject()) | 1314 if (!proto->IsJSObject()) |
| 1292 break; | 1315 break; |
| 1293 | 1316 |
| 1294 if (!JSObject::cast(proto)->map()->is_hidden_prototype()) | 1317 if (!JSObject::cast(proto)->map()->is_hidden_prototype()) |
| 1295 break; | 1318 break; |
| 1296 | 1319 |
| 1297 real_holder = JSObject::cast(proto); | 1320 real_holder = JSObject::cast(proto); |
| 1298 } | 1321 } |
| 1299 | 1322 |
| 1300 global = Top::context()->global(); | 1323 global = Top::context()->global(); |
| 1301 if (assign) return global->SetProperty(*name, args[1], attributes); | 1324 if (assign) { |
| 1325 return global->SetProperty(*name, args[2], attributes, strict_mode); |
| 1326 } |
| 1302 return Heap::undefined_value(); | 1327 return Heap::undefined_value(); |
| 1303 } | 1328 } |
| 1304 | 1329 |
| 1305 | 1330 |
| 1306 static MaybeObject* Runtime_InitializeConstGlobal(Arguments args) { | 1331 static MaybeObject* Runtime_InitializeConstGlobal(Arguments args) { |
| 1307 // All constants are declared with an initial value. The name | 1332 // All constants are declared with an initial value. The name |
| 1308 // of the constant is the first argument and the initial value | 1333 // of the constant is the first argument and the initial value |
| 1309 // is the second. | 1334 // is the second. |
| 1310 RUNTIME_ASSERT(args.length() == 2); | 1335 RUNTIME_ASSERT(args.length() == 2); |
| 1311 CONVERT_ARG_CHECKED(String, name, 0); | 1336 CONVERT_ARG_CHECKED(String, name, 0); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1350 | 1375 |
| 1351 // Restore global object from context (in case of GC) and continue | 1376 // Restore global object from context (in case of GC) and continue |
| 1352 // with setting the value because the property is either absent or | 1377 // with setting the value because the property is either absent or |
| 1353 // read-only. We also have to do redo the lookup. | 1378 // read-only. We also have to do redo the lookup. |
| 1354 HandleScope handle_scope; | 1379 HandleScope handle_scope; |
| 1355 Handle<GlobalObject> global(Top::context()->global()); | 1380 Handle<GlobalObject> global(Top::context()->global()); |
| 1356 | 1381 |
| 1357 // BUG 1213575: Handle the case where we have to set a read-only | 1382 // BUG 1213575: Handle the case where we have to set a read-only |
| 1358 // property through an interceptor and only do it if it's | 1383 // property through an interceptor and only do it if it's |
| 1359 // uninitialized, e.g. the hole. Nirk... | 1384 // uninitialized, e.g. the hole. Nirk... |
| 1360 RETURN_IF_EMPTY_HANDLE(SetProperty(global, name, value, attributes)); | 1385 // Passing non-strict mode because the property is writable. |
| 1386 RETURN_IF_EMPTY_HANDLE(SetProperty(global, |
| 1387 name, |
| 1388 value, |
| 1389 attributes, |
| 1390 kNonStrictMode)); |
| 1361 return *value; | 1391 return *value; |
| 1362 } | 1392 } |
| 1363 | 1393 |
| 1364 // Set the value, but only we're assigning the initial value to a | 1394 // Set the value, but only we're assigning the initial value to a |
| 1365 // constant. For now, we determine this by checking if the | 1395 // constant. For now, we determine this by checking if the |
| 1366 // current value is the hole. | 1396 // current value is the hole. |
| 1397 // TODO(mmaly): Strict mode not needed (const disallowed). |
| 1367 PropertyType type = lookup.type(); | 1398 PropertyType type = lookup.type(); |
| 1368 if (type == FIELD) { | 1399 if (type == FIELD) { |
| 1369 FixedArray* properties = global->properties(); | 1400 FixedArray* properties = global->properties(); |
| 1370 int index = lookup.GetFieldIndex(); | 1401 int index = lookup.GetFieldIndex(); |
| 1371 if (properties->get(index)->IsTheHole()) { | 1402 if (properties->get(index)->IsTheHole()) { |
| 1372 properties->set(index, *value); | 1403 properties->set(index, *value); |
| 1373 } | 1404 } |
| 1374 } else if (type == NORMAL) { | 1405 } else if (type == NORMAL) { |
| 1375 if (global->GetNormalizedProperty(&lookup)->IsTheHole()) { | 1406 if (global->GetNormalizedProperty(&lookup)->IsTheHole()) { |
| 1376 global->SetNormalizedProperty(&lookup, *value); | 1407 global->SetNormalizedProperty(&lookup, *value); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1432 Handle<JSObject> arguments(Handle<JSObject>::cast(holder)); | 1463 Handle<JSObject> arguments(Handle<JSObject>::cast(holder)); |
| 1433 SetElement(arguments, index, value); | 1464 SetElement(arguments, index, value); |
| 1434 } | 1465 } |
| 1435 return *value; | 1466 return *value; |
| 1436 } | 1467 } |
| 1437 | 1468 |
| 1438 // The property could not be found, we introduce it in the global | 1469 // The property could not be found, we introduce it in the global |
| 1439 // context. | 1470 // context. |
| 1440 if (attributes == ABSENT) { | 1471 if (attributes == ABSENT) { |
| 1441 Handle<JSObject> global = Handle<JSObject>(Top::context()->global()); | 1472 Handle<JSObject> global = Handle<JSObject>(Top::context()->global()); |
| 1442 RETURN_IF_EMPTY_HANDLE(SetProperty(global, name, value, NONE)); | 1473 // TODO(mmaly): Strict mode not needed (const disallowed). |
| 1474 RETURN_IF_EMPTY_HANDLE( |
| 1475 SetProperty(global, name, value, NONE, kNonStrictMode)); |
| 1443 return *value; | 1476 return *value; |
| 1444 } | 1477 } |
| 1445 | 1478 |
| 1446 // The property was present in a context extension object. | 1479 // The property was present in a context extension object. |
| 1447 Handle<JSObject> context_ext = Handle<JSObject>::cast(holder); | 1480 Handle<JSObject> context_ext = Handle<JSObject>::cast(holder); |
| 1448 | 1481 |
| 1449 if (*context_ext == context->extension()) { | 1482 if (*context_ext == context->extension()) { |
| 1450 // This is the property that was introduced by the const | 1483 // This is the property that was introduced by the const |
| 1451 // declaration. Set it if it hasn't been set before. NOTE: We | 1484 // declaration. Set it if it hasn't been set before. NOTE: We |
| 1452 // cannot use GetProperty() to get the current value as it | 1485 // cannot use GetProperty() to get the current value as it |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1469 } | 1502 } |
| 1470 } else { | 1503 } else { |
| 1471 // We should not reach here. Any real, named property should be | 1504 // We should not reach here. Any real, named property should be |
| 1472 // either a field or a dictionary slot. | 1505 // either a field or a dictionary slot. |
| 1473 UNREACHABLE(); | 1506 UNREACHABLE(); |
| 1474 } | 1507 } |
| 1475 } else { | 1508 } else { |
| 1476 // The property was found in a different context extension object. | 1509 // The property was found in a different context extension object. |
| 1477 // Set it if it is not a read-only property. | 1510 // Set it if it is not a read-only property. |
| 1478 if ((attributes & READ_ONLY) == 0) { | 1511 if ((attributes & READ_ONLY) == 0) { |
| 1512 // TODO(mmaly): Strict mode not needed (const disallowed). |
| 1479 RETURN_IF_EMPTY_HANDLE( | 1513 RETURN_IF_EMPTY_HANDLE( |
| 1480 SetProperty(context_ext, name, value, attributes)); | 1514 SetProperty(context_ext, name, value, attributes, kNonStrictMode)); |
| 1481 } | 1515 } |
| 1482 } | 1516 } |
| 1483 | 1517 |
| 1484 return *value; | 1518 return *value; |
| 1485 } | 1519 } |
| 1486 | 1520 |
| 1487 | 1521 |
| 1488 static MaybeObject* Runtime_OptimizeObjectForAddingMultipleProperties( | 1522 static MaybeObject* Runtime_OptimizeObjectForAddingMultipleProperties( |
| 1489 Arguments args) { | 1523 Arguments args) { |
| 1490 HandleScope scope; | 1524 HandleScope scope; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1636 const char* name, | 1670 const char* name, |
| 1637 Builtins::Name builtin_name) { | 1671 Builtins::Name builtin_name) { |
| 1638 Handle<String> key = Factory::LookupAsciiSymbol(name); | 1672 Handle<String> key = Factory::LookupAsciiSymbol(name); |
| 1639 Handle<Code> code(Builtins::builtin(builtin_name)); | 1673 Handle<Code> code(Builtins::builtin(builtin_name)); |
| 1640 Handle<JSFunction> optimized = Factory::NewFunction(key, | 1674 Handle<JSFunction> optimized = Factory::NewFunction(key, |
| 1641 JS_OBJECT_TYPE, | 1675 JS_OBJECT_TYPE, |
| 1642 JSObject::kHeaderSize, | 1676 JSObject::kHeaderSize, |
| 1643 code, | 1677 code, |
| 1644 false); | 1678 false); |
| 1645 optimized->shared()->DontAdaptArguments(); | 1679 optimized->shared()->DontAdaptArguments(); |
| 1646 SetProperty(holder, key, optimized, NONE); | 1680 // No need for strict mode here. Called from SetupArray (array.js). |
| 1681 SetProperty(holder, key, optimized, NONE, kNonStrictMode); |
| 1647 return optimized; | 1682 return optimized; |
| 1648 } | 1683 } |
| 1649 | 1684 |
| 1650 | 1685 |
| 1651 static MaybeObject* Runtime_SpecialArrayFunctions(Arguments args) { | 1686 static MaybeObject* Runtime_SpecialArrayFunctions(Arguments args) { |
| 1652 HandleScope scope; | 1687 HandleScope scope; |
| 1653 ASSERT(args.length() == 1); | 1688 ASSERT(args.length() == 1); |
| 1654 CONVERT_ARG_CHECKED(JSObject, holder, 0); | 1689 CONVERT_ARG_CHECKED(JSObject, holder, 0); |
| 1655 | 1690 |
| 1656 InstallBuiltin(holder, "pop", Builtins::ArrayPop); | 1691 InstallBuiltin(holder, "pop", Builtins::ArrayPop); |
| (...skipping 2075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3732 attr); | 3767 attr); |
| 3733 } | 3768 } |
| 3734 | 3769 |
| 3735 return Runtime::ForceSetObjectProperty(js_object, name, obj_value, attr); | 3770 return Runtime::ForceSetObjectProperty(js_object, name, obj_value, attr); |
| 3736 } | 3771 } |
| 3737 | 3772 |
| 3738 | 3773 |
| 3739 MaybeObject* Runtime::SetObjectProperty(Handle<Object> object, | 3774 MaybeObject* Runtime::SetObjectProperty(Handle<Object> object, |
| 3740 Handle<Object> key, | 3775 Handle<Object> key, |
| 3741 Handle<Object> value, | 3776 Handle<Object> value, |
| 3742 PropertyAttributes attr) { | 3777 PropertyAttributes attr, |
| 3778 StrictModeFlag strict) { |
| 3743 HandleScope scope; | 3779 HandleScope scope; |
| 3744 | 3780 |
| 3745 if (object->IsUndefined() || object->IsNull()) { | 3781 if (object->IsUndefined() || object->IsNull()) { |
| 3746 Handle<Object> args[2] = { key, object }; | 3782 Handle<Object> args[2] = { key, object }; |
| 3747 Handle<Object> error = | 3783 Handle<Object> error = |
| 3748 Factory::NewTypeError("non_object_property_store", | 3784 Factory::NewTypeError("non_object_property_store", |
| 3749 HandleVector(args, 2)); | 3785 HandleVector(args, 2)); |
| 3750 return Top::Throw(*error); | 3786 return Top::Throw(*error); |
| 3751 } | 3787 } |
| 3752 | 3788 |
| 3753 // If the object isn't a JavaScript object, we ignore the store. | 3789 // If the object isn't a JavaScript object, we ignore the store. |
| 3754 if (!object->IsJSObject()) return *value; | 3790 if (!object->IsJSObject()) return *value; |
| 3755 | 3791 |
| 3756 Handle<JSObject> js_object = Handle<JSObject>::cast(object); | 3792 Handle<JSObject> js_object = Handle<JSObject>::cast(object); |
| 3757 | 3793 |
| 3758 // Check if the given key is an array index. | 3794 // Check if the given key is an array index. |
| 3759 uint32_t index; | 3795 uint32_t index; |
| 3760 if (key->ToArrayIndex(&index)) { | 3796 if (key->ToArrayIndex(&index)) { |
| 3761 // In Firefox/SpiderMonkey, Safari and Opera you can access the characters | 3797 // In Firefox/SpiderMonkey, Safari and Opera you can access the characters |
| 3762 // of a string using [] notation. We need to support this too in | 3798 // of a string using [] notation. We need to support this too in |
| 3763 // JavaScript. | 3799 // JavaScript. |
| 3764 // In the case of a String object we just need to redirect the assignment to | 3800 // In the case of a String object we just need to redirect the assignment to |
| 3765 // the underlying string if the index is in range. Since the underlying | 3801 // the underlying string if the index is in range. Since the underlying |
| 3766 // string does nothing with the assignment then we can ignore such | 3802 // string does nothing with the assignment then we can ignore such |
| 3767 // assignments. | 3803 // assignments. |
| 3768 if (js_object->IsStringObjectWithCharacterAt(index)) { | 3804 if (js_object->IsStringObjectWithCharacterAt(index)) { |
| 3769 return *value; | 3805 return *value; |
| 3770 } | 3806 } |
| 3771 | 3807 |
| 3808 // TODO(mmaly): Implement SetElement strict mode. |
| 3772 Handle<Object> result = SetElement(js_object, index, value); | 3809 Handle<Object> result = SetElement(js_object, index, value); |
| 3773 if (result.is_null()) return Failure::Exception(); | 3810 if (result.is_null()) return Failure::Exception(); |
| 3774 return *value; | 3811 return *value; |
| 3775 } | 3812 } |
| 3776 | 3813 |
| 3777 if (key->IsString()) { | 3814 if (key->IsString()) { |
| 3778 Handle<Object> result; | 3815 Handle<Object> result; |
| 3779 if (Handle<String>::cast(key)->AsArrayIndex(&index)) { | 3816 if (Handle<String>::cast(key)->AsArrayIndex(&index)) { |
| 3780 result = SetElement(js_object, index, value); | 3817 result = SetElement(js_object, index, value); |
| 3781 } else { | 3818 } else { |
| 3782 Handle<String> key_string = Handle<String>::cast(key); | 3819 Handle<String> key_string = Handle<String>::cast(key); |
| 3783 key_string->TryFlatten(); | 3820 key_string->TryFlatten(); |
| 3784 result = SetProperty(js_object, key_string, value, attr); | 3821 result = SetProperty(js_object, key_string, value, attr, strict); |
| 3785 } | 3822 } |
| 3786 if (result.is_null()) return Failure::Exception(); | 3823 if (result.is_null()) return Failure::Exception(); |
| 3787 return *value; | 3824 return *value; |
| 3788 } | 3825 } |
| 3789 | 3826 |
| 3790 // Call-back into JavaScript to convert the key to a string. | 3827 // Call-back into JavaScript to convert the key to a string. |
| 3791 bool has_pending_exception = false; | 3828 bool has_pending_exception = false; |
| 3792 Handle<Object> converted = Execution::ToString(key, &has_pending_exception); | 3829 Handle<Object> converted = Execution::ToString(key, &has_pending_exception); |
| 3793 if (has_pending_exception) return Failure::Exception(); | 3830 if (has_pending_exception) return Failure::Exception(); |
| 3794 Handle<String> name = Handle<String>::cast(converted); | 3831 Handle<String> name = Handle<String>::cast(converted); |
| 3795 | 3832 |
| 3796 if (name->AsArrayIndex(&index)) { | 3833 if (name->AsArrayIndex(&index)) { |
| 3834 // TODO(mmaly): Implement SetElement strict mode. |
| 3797 return js_object->SetElement(index, *value); | 3835 return js_object->SetElement(index, *value); |
| 3798 } else { | 3836 } else { |
| 3799 return js_object->SetProperty(*name, *value, attr); | 3837 return js_object->SetProperty(*name, *value, attr, strict); |
| 3800 } | 3838 } |
| 3801 } | 3839 } |
| 3802 | 3840 |
| 3803 | 3841 |
| 3804 MaybeObject* Runtime::ForceSetObjectProperty(Handle<JSObject> js_object, | 3842 MaybeObject* Runtime::ForceSetObjectProperty(Handle<JSObject> js_object, |
| 3805 Handle<Object> key, | 3843 Handle<Object> key, |
| 3806 Handle<Object> value, | 3844 Handle<Object> value, |
| 3807 PropertyAttributes attr) { | 3845 PropertyAttributes attr) { |
| 3808 HandleScope scope; | 3846 HandleScope scope; |
| 3809 | 3847 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3881 key_string = Handle<String>::cast(converted); | 3919 key_string = Handle<String>::cast(converted); |
| 3882 } | 3920 } |
| 3883 | 3921 |
| 3884 key_string->TryFlatten(); | 3922 key_string->TryFlatten(); |
| 3885 return js_object->DeleteProperty(*key_string, JSObject::FORCE_DELETION); | 3923 return js_object->DeleteProperty(*key_string, JSObject::FORCE_DELETION); |
| 3886 } | 3924 } |
| 3887 | 3925 |
| 3888 | 3926 |
| 3889 static MaybeObject* Runtime_SetProperty(Arguments args) { | 3927 static MaybeObject* Runtime_SetProperty(Arguments args) { |
| 3890 NoHandleAllocation ha; | 3928 NoHandleAllocation ha; |
| 3891 RUNTIME_ASSERT(args.length() == 3 || args.length() == 4); | 3929 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); |
| 3892 | 3930 |
| 3893 Handle<Object> object = args.at<Object>(0); | 3931 Handle<Object> object = args.at<Object>(0); |
| 3894 Handle<Object> key = args.at<Object>(1); | 3932 Handle<Object> key = args.at<Object>(1); |
| 3895 Handle<Object> value = args.at<Object>(2); | 3933 Handle<Object> value = args.at<Object>(2); |
| 3934 CONVERT_SMI_CHECKED(unchecked_attributes, args[3]); |
| 3935 RUNTIME_ASSERT( |
| 3936 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
| 3937 // Compute attributes. |
| 3938 PropertyAttributes attributes = |
| 3939 static_cast<PropertyAttributes>(unchecked_attributes); |
| 3896 | 3940 |
| 3897 // Compute attributes. | 3941 StrictModeFlag strict = kNonStrictMode; |
| 3898 PropertyAttributes attributes = NONE; | 3942 if (args.length() == 5) { |
| 3899 if (args.length() == 4) { | 3943 CONVERT_SMI_CHECKED(strict_unchecked, args[4]); |
| 3900 CONVERT_CHECKED(Smi, value_obj, args[3]); | 3944 RUNTIME_ASSERT(strict_unchecked == kStrictMode || |
| 3901 int unchecked_value = value_obj->value(); | 3945 strict_unchecked == kNonStrictMode); |
| 3902 // Only attribute bits should be set. | 3946 strict = static_cast<StrictModeFlag>(strict_unchecked); |
| 3903 RUNTIME_ASSERT( | |
| 3904 (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | |
| 3905 attributes = static_cast<PropertyAttributes>(unchecked_value); | |
| 3906 } | 3947 } |
| 3907 return Runtime::SetObjectProperty(object, key, value, attributes); | 3948 |
| 3949 return Runtime::SetObjectProperty(object, key, value, attributes, strict); |
| 3908 } | 3950 } |
| 3909 | 3951 |
| 3910 | 3952 |
| 3911 // Set a local property, even if it is READ_ONLY. If the property does not | 3953 // Set a local property, even if it is READ_ONLY. If the property does not |
| 3912 // exist, it will be added with attributes NONE. | 3954 // exist, it will be added with attributes NONE. |
| 3913 static MaybeObject* Runtime_IgnoreAttributesAndSetProperty(Arguments args) { | 3955 static MaybeObject* Runtime_IgnoreAttributesAndSetProperty(Arguments args) { |
| 3914 NoHandleAllocation ha; | 3956 NoHandleAllocation ha; |
| 3915 RUNTIME_ASSERT(args.length() == 3 || args.length() == 4); | 3957 RUNTIME_ASSERT(args.length() == 3 || args.length() == 4); |
| 3916 CONVERT_CHECKED(JSObject, object, args[0]); | 3958 CONVERT_CHECKED(JSObject, object, args[0]); |
| 3917 CONVERT_CHECKED(String, name, args[1]); | 3959 CONVERT_CHECKED(String, name, args[1]); |
| (...skipping 3561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7479 } | 7521 } |
| 7480 | 7522 |
| 7481 | 7523 |
| 7482 static ObjectPair Runtime_LoadContextSlotNoReferenceError(Arguments args) { | 7524 static ObjectPair Runtime_LoadContextSlotNoReferenceError(Arguments args) { |
| 7483 return LoadContextSlotHelper(args, false); | 7525 return LoadContextSlotHelper(args, false); |
| 7484 } | 7526 } |
| 7485 | 7527 |
| 7486 | 7528 |
| 7487 static MaybeObject* Runtime_StoreContextSlot(Arguments args) { | 7529 static MaybeObject* Runtime_StoreContextSlot(Arguments args) { |
| 7488 HandleScope scope; | 7530 HandleScope scope; |
| 7489 ASSERT(args.length() == 3); | 7531 ASSERT(args.length() == 4); |
| 7490 | 7532 |
| 7491 Handle<Object> value(args[0]); | 7533 Handle<Object> value(args[0]); |
| 7492 CONVERT_ARG_CHECKED(Context, context, 1); | 7534 CONVERT_ARG_CHECKED(Context, context, 1); |
| 7493 CONVERT_ARG_CHECKED(String, name, 2); | 7535 CONVERT_ARG_CHECKED(String, name, 2); |
| 7536 CONVERT_SMI_CHECKED(strict_unchecked, args[3]); |
| 7537 RUNTIME_ASSERT(strict_unchecked == kStrictMode || |
| 7538 strict_unchecked == kNonStrictMode); |
| 7539 StrictModeFlag strict = static_cast<StrictModeFlag>(strict_unchecked); |
| 7540 |
| 7494 | 7541 |
| 7495 int index; | 7542 int index; |
| 7496 PropertyAttributes attributes; | 7543 PropertyAttributes attributes; |
| 7497 ContextLookupFlags flags = FOLLOW_CHAINS; | 7544 ContextLookupFlags flags = FOLLOW_CHAINS; |
| 7498 Handle<Object> holder = context->Lookup(name, flags, &index, &attributes); | 7545 Handle<Object> holder = context->Lookup(name, flags, &index, &attributes); |
| 7499 | 7546 |
| 7500 if (index >= 0) { | 7547 if (index >= 0) { |
| 7501 if (holder->IsContext()) { | 7548 if (holder->IsContext()) { |
| 7502 // Ignore if read_only variable. | 7549 // Ignore if read_only variable. |
| 7503 if ((attributes & READ_ONLY) == 0) { | 7550 if ((attributes & READ_ONLY) == 0) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 7527 // The property was not found. It needs to be stored in the global context. | 7574 // The property was not found. It needs to be stored in the global context. |
| 7528 ASSERT(attributes == ABSENT); | 7575 ASSERT(attributes == ABSENT); |
| 7529 attributes = NONE; | 7576 attributes = NONE; |
| 7530 context_ext = Handle<JSObject>(Top::context()->global()); | 7577 context_ext = Handle<JSObject>(Top::context()->global()); |
| 7531 } | 7578 } |
| 7532 | 7579 |
| 7533 // Set the property, but ignore if read_only variable on the context | 7580 // Set the property, but ignore if read_only variable on the context |
| 7534 // extension object itself. | 7581 // extension object itself. |
| 7535 if ((attributes & READ_ONLY) == 0 || | 7582 if ((attributes & READ_ONLY) == 0 || |
| 7536 (context_ext->GetLocalPropertyAttribute(*name) == ABSENT)) { | 7583 (context_ext->GetLocalPropertyAttribute(*name) == ABSENT)) { |
| 7537 RETURN_IF_EMPTY_HANDLE(SetProperty(context_ext, name, value, NONE)); | 7584 RETURN_IF_EMPTY_HANDLE(SetProperty(context_ext, name, value, NONE, strict)); |
| 7585 } else if (strict == kStrictMode && (attributes & READ_ONLY) != 0) { |
| 7586 // Setting read only property in strict mode. |
| 7587 Handle<Object> error = |
| 7588 Factory::NewTypeError("strict_cannot_assign", HandleVector(&name, 1)); |
| 7589 return Top::Throw(*error); |
| 7538 } | 7590 } |
| 7539 return *value; | 7591 return *value; |
| 7540 } | 7592 } |
| 7541 | 7593 |
| 7542 | 7594 |
| 7543 static MaybeObject* Runtime_Throw(Arguments args) { | 7595 static MaybeObject* Runtime_Throw(Arguments args) { |
| 7544 HandleScope scope; | 7596 HandleScope scope; |
| 7545 ASSERT(args.length() == 1); | 7597 ASSERT(args.length() == 1); |
| 7546 | 7598 |
| 7547 return Top::Throw(args[0]); | 7599 return Top::Throw(args[0]); |
| (...skipping 1712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9260 i < scope_info.number_of_context_slots(); | 9312 i < scope_info.number_of_context_slots(); |
| 9261 i++) { | 9313 i++) { |
| 9262 int context_index = serialized_scope_info->ContextSlotIndex( | 9314 int context_index = serialized_scope_info->ContextSlotIndex( |
| 9263 *scope_info.context_slot_name(i), NULL); | 9315 *scope_info.context_slot_name(i), NULL); |
| 9264 | 9316 |
| 9265 // Don't include the arguments shadow (.arguments) context variable. | 9317 // Don't include the arguments shadow (.arguments) context variable. |
| 9266 if (*scope_info.context_slot_name(i) != Heap::arguments_shadow_symbol()) { | 9318 if (*scope_info.context_slot_name(i) != Heap::arguments_shadow_symbol()) { |
| 9267 RETURN_IF_EMPTY_HANDLE_VALUE( | 9319 RETURN_IF_EMPTY_HANDLE_VALUE( |
| 9268 SetProperty(scope_object, | 9320 SetProperty(scope_object, |
| 9269 scope_info.context_slot_name(i), | 9321 scope_info.context_slot_name(i), |
| 9270 Handle<Object>(context->get(context_index)), NONE), | 9322 Handle<Object>(context->get(context_index)), |
| 9323 NONE, |
| 9324 kNonStrictMode), |
| 9271 false); | 9325 false); |
| 9272 } | 9326 } |
| 9273 } | 9327 } |
| 9274 | 9328 |
| 9275 return true; | 9329 return true; |
| 9276 } | 9330 } |
| 9277 | 9331 |
| 9278 | 9332 |
| 9279 // Create a plain JSObject which materializes the local scope for the specified | 9333 // Create a plain JSObject which materializes the local scope for the specified |
| 9280 // frame. | 9334 // frame. |
| 9281 static Handle<JSObject> MaterializeLocalScope(JavaScriptFrame* frame) { | 9335 static Handle<JSObject> MaterializeLocalScope(JavaScriptFrame* frame) { |
| 9282 Handle<JSFunction> function(JSFunction::cast(frame->function())); | 9336 Handle<JSFunction> function(JSFunction::cast(frame->function())); |
| 9283 Handle<SharedFunctionInfo> shared(function->shared()); | 9337 Handle<SharedFunctionInfo> shared(function->shared()); |
| 9284 Handle<SerializedScopeInfo> serialized_scope_info(shared->scope_info()); | 9338 Handle<SerializedScopeInfo> serialized_scope_info(shared->scope_info()); |
| 9285 ScopeInfo<> scope_info(*serialized_scope_info); | 9339 ScopeInfo<> scope_info(*serialized_scope_info); |
| 9286 | 9340 |
| 9287 // Allocate and initialize a JSObject with all the arguments, stack locals | 9341 // Allocate and initialize a JSObject with all the arguments, stack locals |
| 9288 // heap locals and extension properties of the debugged function. | 9342 // heap locals and extension properties of the debugged function. |
| 9289 Handle<JSObject> local_scope = Factory::NewJSObject(Top::object_function()); | 9343 Handle<JSObject> local_scope = Factory::NewJSObject(Top::object_function()); |
| 9290 | 9344 |
| 9291 // First fill all parameters. | 9345 // First fill all parameters. |
| 9292 for (int i = 0; i < scope_info.number_of_parameters(); ++i) { | 9346 for (int i = 0; i < scope_info.number_of_parameters(); ++i) { |
| 9293 RETURN_IF_EMPTY_HANDLE_VALUE( | 9347 RETURN_IF_EMPTY_HANDLE_VALUE( |
| 9294 SetProperty(local_scope, | 9348 SetProperty(local_scope, |
| 9295 scope_info.parameter_name(i), | 9349 scope_info.parameter_name(i), |
| 9296 Handle<Object>(frame->GetParameter(i)), NONE), | 9350 Handle<Object>(frame->GetParameter(i)), |
| 9351 NONE, |
| 9352 kNonStrictMode), |
| 9297 Handle<JSObject>()); | 9353 Handle<JSObject>()); |
| 9298 } | 9354 } |
| 9299 | 9355 |
| 9300 // Second fill all stack locals. | 9356 // Second fill all stack locals. |
| 9301 for (int i = 0; i < scope_info.number_of_stack_slots(); i++) { | 9357 for (int i = 0; i < scope_info.number_of_stack_slots(); i++) { |
| 9302 RETURN_IF_EMPTY_HANDLE_VALUE( | 9358 RETURN_IF_EMPTY_HANDLE_VALUE( |
| 9303 SetProperty(local_scope, | 9359 SetProperty(local_scope, |
| 9304 scope_info.stack_slot_name(i), | 9360 scope_info.stack_slot_name(i), |
| 9305 Handle<Object>(frame->GetExpression(i)), NONE), | 9361 Handle<Object>(frame->GetExpression(i)), |
| 9362 NONE, |
| 9363 kNonStrictMode), |
| 9306 Handle<JSObject>()); | 9364 Handle<JSObject>()); |
| 9307 } | 9365 } |
| 9308 | 9366 |
| 9309 // Third fill all context locals. | 9367 // Third fill all context locals. |
| 9310 Handle<Context> frame_context(Context::cast(frame->context())); | 9368 Handle<Context> frame_context(Context::cast(frame->context())); |
| 9311 Handle<Context> function_context(frame_context->fcontext()); | 9369 Handle<Context> function_context(frame_context->fcontext()); |
| 9312 if (!CopyContextLocalsToScopeObject(serialized_scope_info, scope_info, | 9370 if (!CopyContextLocalsToScopeObject(serialized_scope_info, scope_info, |
| 9313 function_context, local_scope)) { | 9371 function_context, local_scope)) { |
| 9314 return Handle<JSObject>(); | 9372 return Handle<JSObject>(); |
| 9315 } | 9373 } |
| 9316 | 9374 |
| 9317 // Finally copy any properties from the function context extension. This will | 9375 // Finally copy any properties from the function context extension. This will |
| 9318 // be variables introduced by eval. | 9376 // be variables introduced by eval. |
| 9319 if (function_context->closure() == *function) { | 9377 if (function_context->closure() == *function) { |
| 9320 if (function_context->has_extension() && | 9378 if (function_context->has_extension() && |
| 9321 !function_context->IsGlobalContext()) { | 9379 !function_context->IsGlobalContext()) { |
| 9322 Handle<JSObject> ext(JSObject::cast(function_context->extension())); | 9380 Handle<JSObject> ext(JSObject::cast(function_context->extension())); |
| 9323 Handle<FixedArray> keys = GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS); | 9381 Handle<FixedArray> keys = GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS); |
| 9324 for (int i = 0; i < keys->length(); i++) { | 9382 for (int i = 0; i < keys->length(); i++) { |
| 9325 // Names of variables introduced by eval are strings. | 9383 // Names of variables introduced by eval are strings. |
| 9326 ASSERT(keys->get(i)->IsString()); | 9384 ASSERT(keys->get(i)->IsString()); |
| 9327 Handle<String> key(String::cast(keys->get(i))); | 9385 Handle<String> key(String::cast(keys->get(i))); |
| 9328 RETURN_IF_EMPTY_HANDLE_VALUE( | 9386 RETURN_IF_EMPTY_HANDLE_VALUE( |
| 9329 SetProperty(local_scope, key, GetProperty(ext, key), NONE), | 9387 SetProperty(local_scope, |
| 9388 key, |
| 9389 GetProperty(ext, key), |
| 9390 NONE, |
| 9391 kNonStrictMode), |
| 9330 Handle<JSObject>()); | 9392 Handle<JSObject>()); |
| 9331 } | 9393 } |
| 9332 } | 9394 } |
| 9333 } | 9395 } |
| 9334 return local_scope; | 9396 return local_scope; |
| 9335 } | 9397 } |
| 9336 | 9398 |
| 9337 | 9399 |
| 9338 // Create a plain JSObject which materializes the closure content for the | 9400 // Create a plain JSObject which materializes the closure content for the |
| 9339 // context. | 9401 // context. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 9357 // object. | 9419 // object. |
| 9358 Handle<JSObject> arguments_shadow( | 9420 Handle<JSObject> arguments_shadow( |
| 9359 JSObject::cast(context->get(arguments_shadow_index))); | 9421 JSObject::cast(context->get(arguments_shadow_index))); |
| 9360 for (int i = 0; i < scope_info.number_of_parameters(); ++i) { | 9422 for (int i = 0; i < scope_info.number_of_parameters(); ++i) { |
| 9361 // We don't expect exception-throwing getters on the arguments shadow. | 9423 // We don't expect exception-throwing getters on the arguments shadow. |
| 9362 Object* element = arguments_shadow->GetElement(i)->ToObjectUnchecked(); | 9424 Object* element = arguments_shadow->GetElement(i)->ToObjectUnchecked(); |
| 9363 RETURN_IF_EMPTY_HANDLE_VALUE( | 9425 RETURN_IF_EMPTY_HANDLE_VALUE( |
| 9364 SetProperty(closure_scope, | 9426 SetProperty(closure_scope, |
| 9365 scope_info.parameter_name(i), | 9427 scope_info.parameter_name(i), |
| 9366 Handle<Object>(element), | 9428 Handle<Object>(element), |
| 9367 NONE), | 9429 NONE, |
| 9430 kNonStrictMode), |
| 9368 Handle<JSObject>()); | 9431 Handle<JSObject>()); |
| 9369 } | 9432 } |
| 9370 } | 9433 } |
| 9371 | 9434 |
| 9372 // Fill all context locals to the context extension. | 9435 // Fill all context locals to the context extension. |
| 9373 if (!CopyContextLocalsToScopeObject(serialized_scope_info, scope_info, | 9436 if (!CopyContextLocalsToScopeObject(serialized_scope_info, scope_info, |
| 9374 context, closure_scope)) { | 9437 context, closure_scope)) { |
| 9375 return Handle<JSObject>(); | 9438 return Handle<JSObject>(); |
| 9376 } | 9439 } |
| 9377 | 9440 |
| 9378 // Finally copy any properties from the function context extension. This will | 9441 // Finally copy any properties from the function context extension. This will |
| 9379 // be variables introduced by eval. | 9442 // be variables introduced by eval. |
| 9380 if (context->has_extension()) { | 9443 if (context->has_extension()) { |
| 9381 Handle<JSObject> ext(JSObject::cast(context->extension())); | 9444 Handle<JSObject> ext(JSObject::cast(context->extension())); |
| 9382 Handle<FixedArray> keys = GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS); | 9445 Handle<FixedArray> keys = GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS); |
| 9383 for (int i = 0; i < keys->length(); i++) { | 9446 for (int i = 0; i < keys->length(); i++) { |
| 9384 // Names of variables introduced by eval are strings. | 9447 // Names of variables introduced by eval are strings. |
| 9385 ASSERT(keys->get(i)->IsString()); | 9448 ASSERT(keys->get(i)->IsString()); |
| 9386 Handle<String> key(String::cast(keys->get(i))); | 9449 Handle<String> key(String::cast(keys->get(i))); |
| 9387 RETURN_IF_EMPTY_HANDLE_VALUE( | 9450 RETURN_IF_EMPTY_HANDLE_VALUE( |
| 9388 SetProperty(closure_scope, key, GetProperty(ext, key), NONE), | 9451 SetProperty(closure_scope, |
| 9452 key, |
| 9453 GetProperty(ext, key), |
| 9454 NONE, |
| 9455 kNonStrictMode), |
| 9389 Handle<JSObject>()); | 9456 Handle<JSObject>()); |
| 9390 } | 9457 } |
| 9391 } | 9458 } |
| 9392 | 9459 |
| 9393 return closure_scope; | 9460 return closure_scope; |
| 9394 } | 9461 } |
| 9395 | 9462 |
| 9396 | 9463 |
| 9397 // Iterate over the actual scopes visible from a stack frame. All scopes are | 9464 // Iterate over the actual scopes visible from a stack frame. All scopes are |
| 9398 // backed by an actual context except the local scope, which is inserted | 9465 // backed by an actual context except the local scope, which is inserted |
| (...skipping 1897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11296 } else { | 11363 } else { |
| 11297 // Handle last resort GC and make sure to allow future allocations | 11364 // Handle last resort GC and make sure to allow future allocations |
| 11298 // to grow the heap without causing GCs (if possible). | 11365 // to grow the heap without causing GCs (if possible). |
| 11299 Counters::gc_last_resort_from_js.Increment(); | 11366 Counters::gc_last_resort_from_js.Increment(); |
| 11300 Heap::CollectAllGarbage(false); | 11367 Heap::CollectAllGarbage(false); |
| 11301 } | 11368 } |
| 11302 } | 11369 } |
| 11303 | 11370 |
| 11304 | 11371 |
| 11305 } } // namespace v8::internal | 11372 } } // namespace v8::internal |
| OLD | NEW |