| 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 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1133 holder = Handle<JSObject>(lookup->holder(), lookup->isolate()); | 1133 holder = Handle<JSObject>(lookup->holder(), lookup->isolate()); |
| 1134 } | 1134 } |
| 1135 | 1135 |
| 1136 // While normally LookupTransition gets passed the receiver, in this case we | 1136 // While normally LookupTransition gets passed the receiver, in this case we |
| 1137 // pass the holder of the property that we overwrite. This keeps the holder in | 1137 // pass the holder of the property that we overwrite. This keeps the holder in |
| 1138 // the LookupResult intact so we can later use it to generate a prototype | 1138 // the LookupResult intact so we can later use it to generate a prototype |
| 1139 // chain check. This avoids a double lookup, but requires us to pass in the | 1139 // chain check. This avoids a double lookup, but requires us to pass in the |
| 1140 // receiver when trying to fetch extra information from the transition. | 1140 // receiver when trying to fetch extra information from the transition. |
| 1141 receiver->map()->LookupTransition(*holder, *name, lookup); | 1141 receiver->map()->LookupTransition(*holder, *name, lookup); |
| 1142 if (!lookup->IsTransition()) return false; | 1142 if (!lookup->IsTransition()) return false; |
| 1143 PropertyDetails target_details = | 1143 PropertyDetails target_details = lookup->GetTransitionDetails(); |
| 1144 lookup->GetTransitionDetails(receiver->map()); | |
| 1145 if (target_details.IsReadOnly()) return false; | 1144 if (target_details.IsReadOnly()) return false; |
| 1146 | 1145 |
| 1147 // If the value that's being stored does not fit in the field that the | 1146 // If the value that's being stored does not fit in the field that the |
| 1148 // instance would transition to, create a new transition that fits the value. | 1147 // instance would transition to, create a new transition that fits the value. |
| 1149 // This has to be done before generating the IC, since that IC will embed the | 1148 // This has to be done before generating the IC, since that IC will embed the |
| 1150 // transition target. | 1149 // transition target. |
| 1151 // Ensure the instance and its map were migrated before trying to update the | 1150 // Ensure the instance and its map were migrated before trying to update the |
| 1152 // transition target. | 1151 // transition target. |
| 1153 ASSERT(!receiver->map()->is_deprecated()); | 1152 ASSERT(!receiver->map()->is_deprecated()); |
| 1154 if (!value->FitsRepresentation(target_details.representation())) { | 1153 if (!value->FitsRepresentation(target_details.representation())) { |
| 1155 Handle<Map> target(lookup->GetTransitionMapFromMap(receiver->map())); | 1154 Handle<Map> target(lookup->GetTransitionTarget()); |
| 1156 Map::GeneralizeRepresentation( | 1155 Map::GeneralizeRepresentation( |
| 1157 target, target->LastAdded(), | 1156 target, target->LastAdded(), |
| 1158 value->OptimalRepresentation(), FORCE_FIELD); | 1157 value->OptimalRepresentation(), FORCE_FIELD); |
| 1159 // Lookup the transition again since the transition tree may have changed | 1158 // Lookup the transition again since the transition tree may have changed |
| 1160 // entirely by the migration above. | 1159 // entirely by the migration above. |
| 1161 receiver->map()->LookupTransition(*holder, *name, lookup); | 1160 receiver->map()->LookupTransition(*holder, *name, lookup); |
| 1162 if (!lookup->IsTransition()) return false; | 1161 if (!lookup->IsTransition()) return false; |
| 1163 ic->MarkMonomorphicPrototypeFailure(); | 1162 ic->MarkMonomorphicPrototypeFailure(); |
| 1164 } | 1163 } |
| 1165 return true; | 1164 return true; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1318 | 1317 |
| 1319 Handle<JSObject> holder(lookup->holder()); | 1318 Handle<JSObject> holder(lookup->holder()); |
| 1320 // Handlers do not use strict mode. | 1319 // Handlers do not use strict mode. |
| 1321 StoreStubCompiler compiler(isolate(), kNonStrictMode, kind()); | 1320 StoreStubCompiler compiler(isolate(), kNonStrictMode, kind()); |
| 1322 switch (lookup->type()) { | 1321 switch (lookup->type()) { |
| 1323 case FIELD: | 1322 case FIELD: |
| 1324 return compiler.CompileStoreField(receiver, lookup, name); | 1323 return compiler.CompileStoreField(receiver, lookup, name); |
| 1325 case TRANSITION: { | 1324 case TRANSITION: { |
| 1326 // Explicitly pass in the receiver map since LookupForWrite may have | 1325 // Explicitly pass in the receiver map since LookupForWrite may have |
| 1327 // stored something else than the receiver in the holder. | 1326 // stored something else than the receiver in the holder. |
| 1328 Handle<Map> transition( | 1327 Handle<Map> transition(lookup->GetTransitionTarget()); |
| 1329 lookup->GetTransitionTarget(receiver->map()), isolate()); | 1328 PropertyDetails details = transition->GetLastDescriptorDetails(); |
| 1330 int descriptor = transition->LastAdded(); | |
| 1331 | |
| 1332 DescriptorArray* target_descriptors = transition->instance_descriptors(); | |
| 1333 PropertyDetails details = target_descriptors->GetDetails(descriptor); | |
| 1334 | 1329 |
| 1335 if (details.type() == CALLBACKS || details.attributes() != NONE) break; | 1330 if (details.type() == CALLBACKS || details.attributes() != NONE) break; |
| 1336 | 1331 |
| 1337 return compiler.CompileStoreTransition( | 1332 return compiler.CompileStoreTransition( |
| 1338 receiver, lookup, transition, name); | 1333 receiver, lookup, transition, name); |
| 1339 } | 1334 } |
| 1340 case NORMAL: | 1335 case NORMAL: |
| 1341 if (kind() == Code::KEYED_STORE_IC) break; | 1336 if (kind() == Code::KEYED_STORE_IC) break; |
| 1342 if (receiver->IsGlobalObject()) { | 1337 if (receiver->IsGlobalObject()) { |
| 1343 // The stub generated for the global object picks the value directly | 1338 // The stub generated for the global object picks the value directly |
| (...skipping 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2817 #undef ADDR | 2812 #undef ADDR |
| 2818 }; | 2813 }; |
| 2819 | 2814 |
| 2820 | 2815 |
| 2821 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2816 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 2822 return IC_utilities[id]; | 2817 return IC_utilities[id]; |
| 2823 } | 2818 } |
| 2824 | 2819 |
| 2825 | 2820 |
| 2826 } } // namespace v8::internal | 2821 } } // namespace v8::internal |
| OLD | NEW |