| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1297 | 1297 |
| 1298 | 1298 |
| 1299 static bool StoreICableLookup(LookupResult* lookup) { | 1299 static bool StoreICableLookup(LookupResult* lookup) { |
| 1300 // Bail out if we didn't find a result. | 1300 // Bail out if we didn't find a result. |
| 1301 if (!lookup->IsFound()) return false; | 1301 if (!lookup->IsFound()) return false; |
| 1302 | 1302 |
| 1303 // Bail out if inline caching is not allowed. | 1303 // Bail out if inline caching is not allowed. |
| 1304 if (!lookup->IsCacheable()) return false; | 1304 if (!lookup->IsCacheable()) return false; |
| 1305 | 1305 |
| 1306 // If the property is read-only, we leave the IC in its current state. | 1306 // If the property is read-only, we leave the IC in its current state. |
| 1307 if (lookup->IsReadOnly()) return false; | 1307 if (lookup->IsTransition()) { |
| 1308 | 1308 return !lookup->GetTransitionDetails().IsReadOnly(); |
| 1309 return true; | 1309 } |
| 1310 return !lookup->IsReadOnly(); |
| 1310 } | 1311 } |
| 1311 | 1312 |
| 1312 | 1313 |
| 1313 static bool LookupForWrite(Handle<JSObject> receiver, | 1314 static bool LookupForWrite(Handle<JSObject> receiver, |
| 1314 Handle<String> name, | 1315 Handle<String> name, |
| 1315 LookupResult* lookup) { | 1316 LookupResult* lookup) { |
| 1316 receiver->LocalLookup(*name, lookup); | 1317 receiver->LocalLookup(*name, lookup); |
| 1317 if (!StoreICableLookup(lookup)) { | 1318 if (!StoreICableLookup(lookup)) { |
| 1318 return false; | 1319 return false; |
| 1319 } | 1320 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 Handle<JSObject> holder(lookup->holder()); | 1452 Handle<JSObject> holder(lookup->holder()); |
| 1452 Handle<Code> code; | 1453 Handle<Code> code; |
| 1453 switch (type) { | 1454 switch (type) { |
| 1454 case FIELD: | 1455 case FIELD: |
| 1455 code = isolate()->stub_cache()->ComputeStoreField(name, | 1456 code = isolate()->stub_cache()->ComputeStoreField(name, |
| 1456 receiver, | 1457 receiver, |
| 1457 lookup->GetFieldIndex(), | 1458 lookup->GetFieldIndex(), |
| 1458 Handle<Map>::null(), | 1459 Handle<Map>::null(), |
| 1459 strict_mode); | 1460 strict_mode); |
| 1460 break; | 1461 break; |
| 1461 case MAP_TRANSITION: { | |
| 1462 if (lookup->GetAttributes() != NONE) return; | |
| 1463 Handle<Map> transition(lookup->GetTransitionMap()); | |
| 1464 int index = transition->PropertyIndexFor(*name); | |
| 1465 code = isolate()->stub_cache()->ComputeStoreField( | |
| 1466 name, receiver, index, transition, strict_mode); | |
| 1467 break; | |
| 1468 } | |
| 1469 case NORMAL: | 1462 case NORMAL: |
| 1470 if (receiver->IsGlobalObject()) { | 1463 if (receiver->IsGlobalObject()) { |
| 1471 // The stub generated for the global object picks the value directly | 1464 // The stub generated for the global object picks the value directly |
| 1472 // from the property cell. So the property must be directly on the | 1465 // from the property cell. So the property must be directly on the |
| 1473 // global object. | 1466 // global object. |
| 1474 Handle<GlobalObject> global = Handle<GlobalObject>::cast(receiver); | 1467 Handle<GlobalObject> global = Handle<GlobalObject>::cast(receiver); |
| 1475 Handle<JSGlobalPropertyCell> cell(global->GetPropertyCell(lookup)); | 1468 Handle<JSGlobalPropertyCell> cell(global->GetPropertyCell(lookup)); |
| 1476 code = isolate()->stub_cache()->ComputeStoreGlobal( | 1469 code = isolate()->stub_cache()->ComputeStoreGlobal( |
| 1477 name, global, cell, strict_mode); | 1470 name, global, cell, strict_mode); |
| 1478 } else { | 1471 } else { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1501 return; | 1494 return; |
| 1502 } | 1495 } |
| 1503 break; | 1496 break; |
| 1504 } | 1497 } |
| 1505 case INTERCEPTOR: | 1498 case INTERCEPTOR: |
| 1506 ASSERT(!receiver->GetNamedInterceptor()->setter()->IsUndefined()); | 1499 ASSERT(!receiver->GetNamedInterceptor()->setter()->IsUndefined()); |
| 1507 code = isolate()->stub_cache()->ComputeStoreInterceptor( | 1500 code = isolate()->stub_cache()->ComputeStoreInterceptor( |
| 1508 name, receiver, strict_mode); | 1501 name, receiver, strict_mode); |
| 1509 break; | 1502 break; |
| 1510 case CONSTANT_FUNCTION: | 1503 case CONSTANT_FUNCTION: |
| 1511 case CONSTANT_TRANSITION: | |
| 1512 return; | 1504 return; |
| 1505 case TRANSITION: { |
| 1506 Object* value = lookup->GetTransitionValue(); |
| 1507 // Callbacks. |
| 1508 if (value->IsAccessorPair()) return; |
| 1509 |
| 1510 Handle<Map> transition(Map::cast(value)); |
| 1511 DescriptorArray* target_descriptors = transition->instance_descriptors(); |
| 1512 int descriptor = target_descriptors->SearchWithCache(*name); |
| 1513 ASSERT(descriptor != DescriptorArray::kNotFound); |
| 1514 PropertyDetails details = target_descriptors->GetDetails(descriptor); |
| 1515 |
| 1516 if (details.type() != FIELD || details.attributes() != NONE) return; |
| 1517 |
| 1518 int field_index = target_descriptors->GetFieldIndex(descriptor); |
| 1519 code = isolate()->stub_cache()->ComputeStoreField( |
| 1520 name, receiver, field_index, transition, strict_mode); |
| 1521 |
| 1522 break; |
| 1523 } |
| 1513 case NONEXISTENT: | 1524 case NONEXISTENT: |
| 1514 case HANDLER: | 1525 case HANDLER: |
| 1515 UNREACHABLE(); | 1526 UNREACHABLE(); |
| 1516 return; | 1527 return; |
| 1517 } | 1528 } |
| 1518 | 1529 |
| 1519 // Patch the call site depending on the state of the cache. | 1530 // Patch the call site depending on the state of the cache. |
| 1520 if (state == UNINITIALIZED || state == MONOMORPHIC_PROTOTYPE_FAILURE) { | 1531 if (state == UNINITIALIZED || state == MONOMORPHIC_PROTOTYPE_FAILURE) { |
| 1521 set_target(*code); | 1532 set_target(*code); |
| 1522 } else if (state == MONOMORPHIC) { | 1533 } else if (state == MONOMORPHIC) { |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1951 // monomorphic state and making sure that the code stub is in the | 1962 // monomorphic state and making sure that the code stub is in the |
| 1952 // stub cache. | 1963 // stub cache. |
| 1953 Handle<Code> code; | 1964 Handle<Code> code; |
| 1954 | 1965 |
| 1955 switch (type) { | 1966 switch (type) { |
| 1956 case FIELD: | 1967 case FIELD: |
| 1957 code = isolate()->stub_cache()->ComputeKeyedStoreField( | 1968 code = isolate()->stub_cache()->ComputeKeyedStoreField( |
| 1958 name, receiver, lookup->GetFieldIndex(), | 1969 name, receiver, lookup->GetFieldIndex(), |
| 1959 Handle<Map>::null(), strict_mode); | 1970 Handle<Map>::null(), strict_mode); |
| 1960 break; | 1971 break; |
| 1961 case MAP_TRANSITION: | 1972 case TRANSITION: { |
| 1962 if (lookup->GetAttributes() == NONE) { | 1973 Object* value = lookup->GetTransitionValue(); |
| 1963 Handle<Map> transition(lookup->GetTransitionMap()); | 1974 // Callbacks transition. |
| 1964 int index = transition->PropertyIndexFor(*name); | 1975 if (value->IsAccessorPair()) { |
| 1976 code = (strict_mode == kStrictMode) |
| 1977 ? generic_stub_strict() |
| 1978 : generic_stub(); |
| 1979 break; |
| 1980 } |
| 1981 |
| 1982 Handle<Map> transition(Map::cast(value)); |
| 1983 DescriptorArray* target_descriptors = transition->instance_descriptors(); |
| 1984 int descriptor = target_descriptors->SearchWithCache(*name); |
| 1985 ASSERT(descriptor != DescriptorArray::kNotFound); |
| 1986 PropertyDetails details = target_descriptors->GetDetails(descriptor); |
| 1987 |
| 1988 if (details.type() == FIELD && details.attributes() == NONE) { |
| 1989 int field_index = target_descriptors->GetFieldIndex(descriptor); |
| 1965 code = isolate()->stub_cache()->ComputeKeyedStoreField( | 1990 code = isolate()->stub_cache()->ComputeKeyedStoreField( |
| 1966 name, receiver, index, transition, strict_mode); | 1991 name, receiver, field_index, transition, strict_mode); |
| 1967 break; | 1992 break; |
| 1968 } | 1993 } |
| 1969 // fall through. | 1994 // fall through. |
| 1995 } |
| 1970 case NORMAL: | 1996 case NORMAL: |
| 1971 case CONSTANT_FUNCTION: | 1997 case CONSTANT_FUNCTION: |
| 1972 case CALLBACKS: | 1998 case CALLBACKS: |
| 1973 case INTERCEPTOR: | 1999 case INTERCEPTOR: |
| 1974 case CONSTANT_TRANSITION: | |
| 1975 // Always rewrite to the generic case so that we do not | 2000 // Always rewrite to the generic case so that we do not |
| 1976 // repeatedly try to rewrite. | 2001 // repeatedly try to rewrite. |
| 1977 code = (strict_mode == kStrictMode) | 2002 code = (strict_mode == kStrictMode) |
| 1978 ? generic_stub_strict() | 2003 ? generic_stub_strict() |
| 1979 : generic_stub(); | 2004 : generic_stub(); |
| 1980 break; | 2005 break; |
| 1981 case HANDLER: | 2006 case HANDLER: |
| 1982 case NONEXISTENT: | 2007 case NONEXISTENT: |
| 1983 UNREACHABLE(); | 2008 UNREACHABLE(); |
| 1984 return; | 2009 return; |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2670 #undef ADDR | 2695 #undef ADDR |
| 2671 }; | 2696 }; |
| 2672 | 2697 |
| 2673 | 2698 |
| 2674 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2699 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 2675 return IC_utilities[id]; | 2700 return IC_utilities[id]; |
| 2676 } | 2701 } |
| 2677 | 2702 |
| 2678 | 2703 |
| 2679 } } // namespace v8::internal | 2704 } } // namespace v8::internal |
| OLD | NEW |