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