| 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 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 | 1117 |
| 1118 if (compile_followup_inline) { | 1118 if (compile_followup_inline) { |
| 1119 // Compile the interceptor call, followed by inline code to load the | 1119 // Compile the interceptor call, followed by inline code to load the |
| 1120 // property from further up the prototype chain if the call fails. | 1120 // property from further up the prototype chain if the call fails. |
| 1121 // Check that the maps haven't changed. | 1121 // Check that the maps haven't changed. |
| 1122 Register holder_reg = CheckPrototypes(object, receiver, interceptor_holder, | 1122 Register holder_reg = CheckPrototypes(object, receiver, interceptor_holder, |
| 1123 scratch1, scratch2, scratch3, | 1123 scratch1, scratch2, scratch3, |
| 1124 name, miss); | 1124 name, miss); |
| 1125 ASSERT(holder_reg.is(receiver) || holder_reg.is(scratch1)); | 1125 ASSERT(holder_reg.is(receiver) || holder_reg.is(scratch1)); |
| 1126 | 1126 |
| 1127 // Preserve the receiver register explicitly whenever it is different from |
| 1128 // the holder and it is needed should the interceptor return without any |
| 1129 // result. The CALLBACKS case needs the receiver to be passed into C++ code, |
| 1130 // the FIELD case might cause a miss during the prototype check. |
| 1131 bool must_perfrom_prototype_check = *interceptor_holder != lookup->holder(); |
| 1132 bool must_preserve_receiver_reg = !receiver.is(holder_reg) && |
| 1133 (lookup->type() == CALLBACKS || must_perfrom_prototype_check); |
| 1134 |
| 1127 // Save necessary data before invoking an interceptor. | 1135 // Save necessary data before invoking an interceptor. |
| 1128 // Requires a frame to make GC aware of pushed pointers. | 1136 // Requires a frame to make GC aware of pushed pointers. |
| 1129 { | 1137 { |
| 1130 FrameScope frame_scope(masm(), StackFrame::INTERNAL); | 1138 FrameScope frame_scope(masm(), StackFrame::INTERNAL); |
| 1131 | 1139 |
| 1132 if (lookup->type() == CALLBACKS && !receiver.is(holder_reg)) { | 1140 if (must_preserve_receiver_reg) { |
| 1133 // CALLBACKS case needs a receiver to be passed into C++ callback. | |
| 1134 __ push(receiver); | 1141 __ push(receiver); |
| 1135 } | 1142 } |
| 1136 __ push(holder_reg); | 1143 __ push(holder_reg); |
| 1137 __ push(name_reg); | 1144 __ push(name_reg); |
| 1138 | 1145 |
| 1139 // Invoke an interceptor. Note: map checks from receiver to | 1146 // Invoke an interceptor. Note: map checks from receiver to |
| 1140 // interceptor's holder has been compiled before (see a caller | 1147 // interceptor's holder has been compiled before (see a caller |
| 1141 // of this method.) | 1148 // of this method.) |
| 1142 CompileCallLoadPropertyWithInterceptor(masm(), | 1149 CompileCallLoadPropertyWithInterceptor(masm(), |
| 1143 receiver, | 1150 receiver, |
| 1144 holder_reg, | 1151 holder_reg, |
| 1145 name_reg, | 1152 name_reg, |
| 1146 interceptor_holder); | 1153 interceptor_holder); |
| 1147 | 1154 |
| 1148 // Check if interceptor provided a value for property. If it's | 1155 // Check if interceptor provided a value for property. If it's |
| 1149 // the case, return immediately. | 1156 // the case, return immediately. |
| 1150 Label interceptor_failed; | 1157 Label interceptor_failed; |
| 1151 __ cmp(eax, factory()->no_interceptor_result_sentinel()); | 1158 __ cmp(eax, factory()->no_interceptor_result_sentinel()); |
| 1152 __ j(equal, &interceptor_failed); | 1159 __ j(equal, &interceptor_failed); |
| 1153 frame_scope.GenerateLeaveFrame(); | 1160 frame_scope.GenerateLeaveFrame(); |
| 1154 __ ret(0); | 1161 __ ret(0); |
| 1155 | 1162 |
| 1163 // Clobber registers when generating debug-code to provoke errors. |
| 1156 __ bind(&interceptor_failed); | 1164 __ bind(&interceptor_failed); |
| 1165 if (FLAG_debug_code) { |
| 1166 __ mov(receiver, Immediate(BitCast<int32_t>(kZapValue))); |
| 1167 __ mov(holder_reg, Immediate(BitCast<int32_t>(kZapValue))); |
| 1168 __ mov(name_reg, Immediate(BitCast<int32_t>(kZapValue))); |
| 1169 } |
| 1170 |
| 1157 __ pop(name_reg); | 1171 __ pop(name_reg); |
| 1158 __ pop(holder_reg); | 1172 __ pop(holder_reg); |
| 1159 if (lookup->type() == CALLBACKS && !receiver.is(holder_reg)) { | 1173 if (must_preserve_receiver_reg) { |
| 1160 __ pop(receiver); | 1174 __ pop(receiver); |
| 1161 } | 1175 } |
| 1162 | 1176 |
| 1163 // Leave the internal frame. | 1177 // Leave the internal frame. |
| 1164 } | 1178 } |
| 1165 | 1179 |
| 1166 // Check that the maps from interceptor's holder to lookup's holder | 1180 // Check that the maps from interceptor's holder to lookup's holder |
| 1167 // haven't changed. And load lookup's holder into holder_reg. | 1181 // haven't changed. And load lookup's holder into holder_reg. |
| 1168 if (*interceptor_holder != lookup->holder()) { | 1182 if (must_perfrom_prototype_check) { |
| 1169 holder_reg = CheckPrototypes(interceptor_holder, | 1183 holder_reg = CheckPrototypes(interceptor_holder, |
| 1170 holder_reg, | 1184 holder_reg, |
| 1171 Handle<JSObject>(lookup->holder()), | 1185 Handle<JSObject>(lookup->holder()), |
| 1172 scratch1, | 1186 scratch1, |
| 1173 scratch2, | 1187 scratch2, |
| 1174 scratch3, | 1188 scratch3, |
| 1175 name, | 1189 name, |
| 1176 miss); | 1190 miss); |
| 1177 } | 1191 } |
| 1178 | 1192 |
| (...skipping 2859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4038 __ jmp(ic_slow, RelocInfo::CODE_TARGET); | 4052 __ jmp(ic_slow, RelocInfo::CODE_TARGET); |
| 4039 } | 4053 } |
| 4040 } | 4054 } |
| 4041 | 4055 |
| 4042 | 4056 |
| 4043 #undef __ | 4057 #undef __ |
| 4044 | 4058 |
| 4045 } } // namespace v8::internal | 4059 } } // namespace v8::internal |
| 4046 | 4060 |
| 4047 #endif // V8_TARGET_ARCH_IA32 | 4061 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |