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