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 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1266 | 1266 |
1267 if (compile_followup_inline) { | 1267 if (compile_followup_inline) { |
1268 // Compile the interceptor call, followed by inline code to load the | 1268 // Compile the interceptor call, followed by inline code to load the |
1269 // property from further up the prototype chain if the call fails. | 1269 // property from further up the prototype chain if the call fails. |
1270 // Check that the maps haven't changed. | 1270 // Check that the maps haven't changed. |
1271 Register holder_reg = CheckPrototypes(object, receiver, interceptor_holder, | 1271 Register holder_reg = CheckPrototypes(object, receiver, interceptor_holder, |
1272 scratch1, scratch2, scratch3, | 1272 scratch1, scratch2, scratch3, |
1273 name, miss); | 1273 name, miss); |
1274 ASSERT(holder_reg.is(receiver) || holder_reg.is(scratch1)); | 1274 ASSERT(holder_reg.is(receiver) || holder_reg.is(scratch1)); |
1275 | 1275 |
| 1276 // Preserve the receiver register explicitly whenever it is different from |
| 1277 // the holder and it is needed should the interceptor return without any |
| 1278 // result. The CALLBACKS case needs the receiver to be passed into C++ code, |
| 1279 // the FIELD case might cause a miss during the prototype check. |
| 1280 bool must_perfrom_prototype_check = *interceptor_holder != lookup->holder(); |
| 1281 bool must_preserve_receiver_reg = !receiver.is(holder_reg) && |
| 1282 (lookup->type() == CALLBACKS || must_perfrom_prototype_check); |
| 1283 |
1276 // Save necessary data before invoking an interceptor. | 1284 // Save necessary data before invoking an interceptor. |
1277 // Requires a frame to make GC aware of pushed pointers. | 1285 // Requires a frame to make GC aware of pushed pointers. |
1278 { | 1286 { |
1279 FrameScope frame_scope(masm(), StackFrame::INTERNAL); | 1287 FrameScope frame_scope(masm(), StackFrame::INTERNAL); |
1280 if (lookup->type() == CALLBACKS && !receiver.is(holder_reg)) { | 1288 if (must_preserve_receiver_reg) { |
1281 // CALLBACKS case needs a receiver to be passed into C++ callback. | |
1282 __ Push(receiver, holder_reg, name_reg); | 1289 __ Push(receiver, holder_reg, name_reg); |
1283 } else { | 1290 } else { |
1284 __ Push(holder_reg, name_reg); | 1291 __ Push(holder_reg, name_reg); |
1285 } | 1292 } |
1286 // Invoke an interceptor. Note: map checks from receiver to | 1293 // Invoke an interceptor. Note: map checks from receiver to |
1287 // interceptor's holder has been compiled before (see a caller | 1294 // interceptor's holder has been compiled before (see a caller |
1288 // of this method.) | 1295 // of this method.) |
1289 CompileCallLoadPropertyWithInterceptor(masm(), | 1296 CompileCallLoadPropertyWithInterceptor(masm(), |
1290 receiver, | 1297 receiver, |
1291 holder_reg, | 1298 holder_reg, |
1292 name_reg, | 1299 name_reg, |
1293 interceptor_holder); | 1300 interceptor_holder); |
1294 // Check if interceptor provided a value for property. If it's | 1301 // Check if interceptor provided a value for property. If it's |
1295 // the case, return immediately. | 1302 // the case, return immediately. |
1296 Label interceptor_failed; | 1303 Label interceptor_failed; |
1297 __ LoadRoot(scratch1, Heap::kNoInterceptorResultSentinelRootIndex); | 1304 __ LoadRoot(scratch1, Heap::kNoInterceptorResultSentinelRootIndex); |
1298 __ cmp(r0, scratch1); | 1305 __ cmp(r0, scratch1); |
1299 __ b(eq, &interceptor_failed); | 1306 __ b(eq, &interceptor_failed); |
1300 frame_scope.GenerateLeaveFrame(); | 1307 frame_scope.GenerateLeaveFrame(); |
1301 __ Ret(); | 1308 __ Ret(); |
1302 | 1309 |
1303 __ bind(&interceptor_failed); | 1310 __ bind(&interceptor_failed); |
1304 __ pop(name_reg); | 1311 __ pop(name_reg); |
1305 __ pop(holder_reg); | 1312 __ pop(holder_reg); |
1306 if (lookup->type() == CALLBACKS && !receiver.is(holder_reg)) { | 1313 if (must_preserve_receiver_reg) { |
1307 __ pop(receiver); | 1314 __ pop(receiver); |
1308 } | 1315 } |
1309 // Leave the internal frame. | 1316 // Leave the internal frame. |
1310 } | 1317 } |
1311 // Check that the maps from interceptor's holder to lookup's holder | 1318 // Check that the maps from interceptor's holder to lookup's holder |
1312 // haven't changed. And load lookup's holder into |holder| register. | 1319 // haven't changed. And load lookup's holder into |holder| register. |
1313 if (*interceptor_holder != lookup->holder()) { | 1320 if (must_perfrom_prototype_check) { |
1314 holder_reg = CheckPrototypes(interceptor_holder, | 1321 holder_reg = CheckPrototypes(interceptor_holder, |
1315 holder_reg, | 1322 holder_reg, |
1316 Handle<JSObject>(lookup->holder()), | 1323 Handle<JSObject>(lookup->holder()), |
1317 scratch1, | 1324 scratch1, |
1318 scratch2, | 1325 scratch2, |
1319 scratch3, | 1326 scratch3, |
1320 name, | 1327 name, |
1321 miss); | 1328 miss); |
1322 } | 1329 } |
1323 | 1330 |
(...skipping 3172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4496 __ Jump(ic_slow, RelocInfo::CODE_TARGET); | 4503 __ Jump(ic_slow, RelocInfo::CODE_TARGET); |
4497 } | 4504 } |
4498 } | 4505 } |
4499 | 4506 |
4500 | 4507 |
4501 #undef __ | 4508 #undef __ |
4502 | 4509 |
4503 } } // namespace v8::internal | 4510 } } // namespace v8::internal |
4504 | 4511 |
4505 #endif // V8_TARGET_ARCH_ARM | 4512 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |