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 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1280 | 1280 |
1281 if (compile_followup_inline) { | 1281 if (compile_followup_inline) { |
1282 // Compile the interceptor call, followed by inline code to load the | 1282 // Compile the interceptor call, followed by inline code to load the |
1283 // property from further up the prototype chain if the call fails. | 1283 // property from further up the prototype chain if the call fails. |
1284 // Check that the maps haven't changed. | 1284 // Check that the maps haven't changed. |
1285 Register holder_reg = CheckPrototypes(object, receiver, interceptor_holder, | 1285 Register holder_reg = CheckPrototypes(object, receiver, interceptor_holder, |
1286 scratch1, scratch2, scratch3, | 1286 scratch1, scratch2, scratch3, |
1287 name, miss); | 1287 name, miss); |
1288 ASSERT(holder_reg.is(receiver) || holder_reg.is(scratch1)); | 1288 ASSERT(holder_reg.is(receiver) || holder_reg.is(scratch1)); |
1289 | 1289 |
| 1290 // Preserve the receiver register explicitly whenever it is different from |
| 1291 // the holder and it is needed should the interceptor return without any |
| 1292 // result. The CALLBACKS case needs the receiver to be passed into C++ code, |
| 1293 // the FIELD case might cause a miss during the prototype check. |
| 1294 bool must_perfrom_prototype_check = *interceptor_holder != lookup->holder(); |
| 1295 bool must_preserve_receiver_reg = !receiver.is(holder_reg) && |
| 1296 (lookup->type() == CALLBACKS || must_perfrom_prototype_check); |
| 1297 |
1290 // Save necessary data before invoking an interceptor. | 1298 // Save necessary data before invoking an interceptor. |
1291 // Requires a frame to make GC aware of pushed pointers. | 1299 // Requires a frame to make GC aware of pushed pointers. |
1292 { | 1300 { |
1293 FrameScope frame_scope(masm(), StackFrame::INTERNAL); | 1301 FrameScope frame_scope(masm(), StackFrame::INTERNAL); |
1294 if (lookup->type() == CALLBACKS && !receiver.is(holder_reg)) { | 1302 if (must_preserve_receiver_reg) { |
1295 // CALLBACKS case needs a receiver to be passed into C++ callback. | |
1296 __ Push(receiver, holder_reg, name_reg); | 1303 __ Push(receiver, holder_reg, name_reg); |
1297 } else { | 1304 } else { |
1298 __ Push(holder_reg, name_reg); | 1305 __ Push(holder_reg, name_reg); |
1299 } | 1306 } |
1300 // Invoke an interceptor. Note: map checks from receiver to | 1307 // Invoke an interceptor. Note: map checks from receiver to |
1301 // interceptor's holder has been compiled before (see a caller | 1308 // interceptor's holder has been compiled before (see a caller |
1302 // of this method). | 1309 // of this method). |
1303 CompileCallLoadPropertyWithInterceptor(masm(), | 1310 CompileCallLoadPropertyWithInterceptor(masm(), |
1304 receiver, | 1311 receiver, |
1305 holder_reg, | 1312 holder_reg, |
1306 name_reg, | 1313 name_reg, |
1307 interceptor_holder); | 1314 interceptor_holder); |
1308 // Check if interceptor provided a value for property. If it's | 1315 // Check if interceptor provided a value for property. If it's |
1309 // the case, return immediately. | 1316 // the case, return immediately. |
1310 Label interceptor_failed; | 1317 Label interceptor_failed; |
1311 __ LoadRoot(scratch1, Heap::kNoInterceptorResultSentinelRootIndex); | 1318 __ LoadRoot(scratch1, Heap::kNoInterceptorResultSentinelRootIndex); |
1312 __ Branch(&interceptor_failed, eq, v0, Operand(scratch1)); | 1319 __ Branch(&interceptor_failed, eq, v0, Operand(scratch1)); |
1313 frame_scope.GenerateLeaveFrame(); | 1320 frame_scope.GenerateLeaveFrame(); |
1314 __ Ret(); | 1321 __ Ret(); |
1315 | 1322 |
1316 __ bind(&interceptor_failed); | 1323 __ bind(&interceptor_failed); |
1317 __ pop(name_reg); | 1324 __ pop(name_reg); |
1318 __ pop(holder_reg); | 1325 __ pop(holder_reg); |
1319 if (lookup->type() == CALLBACKS && !receiver.is(holder_reg)) { | 1326 if (must_preserve_receiver_reg) { |
1320 __ pop(receiver); | 1327 __ pop(receiver); |
1321 } | 1328 } |
1322 // Leave the internal frame. | 1329 // Leave the internal frame. |
1323 } | 1330 } |
1324 // Check that the maps from interceptor's holder to lookup's holder | 1331 // Check that the maps from interceptor's holder to lookup's holder |
1325 // haven't changed. And load lookup's holder into |holder| register. | 1332 // haven't changed. And load lookup's holder into |holder| register. |
1326 if (*interceptor_holder != lookup->holder()) { | 1333 if (must_perfrom_prototype_check) { |
1327 holder_reg = CheckPrototypes(interceptor_holder, | 1334 holder_reg = CheckPrototypes(interceptor_holder, |
1328 holder_reg, | 1335 holder_reg, |
1329 Handle<JSObject>(lookup->holder()), | 1336 Handle<JSObject>(lookup->holder()), |
1330 scratch1, | 1337 scratch1, |
1331 scratch2, | 1338 scratch2, |
1332 scratch3, | 1339 scratch3, |
1333 name, | 1340 name, |
1334 miss); | 1341 miss); |
1335 } | 1342 } |
1336 | 1343 |
(...skipping 3218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4555 __ Jump(ic_slow, RelocInfo::CODE_TARGET); | 4562 __ Jump(ic_slow, RelocInfo::CODE_TARGET); |
4556 } | 4563 } |
4557 } | 4564 } |
4558 | 4565 |
4559 | 4566 |
4560 #undef __ | 4567 #undef __ |
4561 | 4568 |
4562 } } // namespace v8::internal | 4569 } } // namespace v8::internal |
4563 | 4570 |
4564 #endif // V8_TARGET_ARCH_MIPS | 4571 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |