Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: src/ia32/stub-cache-ia32.cc

Issue 10358010: Fix register clobbering in LoadIC for interceptors. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/stub-cache-arm.cc ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 1122
1123 if (compile_followup_inline) { 1123 if (compile_followup_inline) {
1124 // Compile the interceptor call, followed by inline code to load the 1124 // Compile the interceptor call, followed by inline code to load the
1125 // property from further up the prototype chain if the call fails. 1125 // property from further up the prototype chain if the call fails.
1126 // Check that the maps haven't changed. 1126 // Check that the maps haven't changed.
1127 Register holder_reg = CheckPrototypes(object, receiver, interceptor_holder, 1127 Register holder_reg = CheckPrototypes(object, receiver, interceptor_holder,
1128 scratch1, scratch2, scratch3, 1128 scratch1, scratch2, scratch3,
1129 name, miss); 1129 name, miss);
1130 ASSERT(holder_reg.is(receiver) || holder_reg.is(scratch1)); 1130 ASSERT(holder_reg.is(receiver) || holder_reg.is(scratch1));
1131 1131
1132 // Preserve the receiver register explicitly whenever it is different from
1133 // the holder and it is needed should the interceptor return without any
1134 // result. The CALLBACKS case needs the receiver to be passed into C++ code,
1135 // the FIELD case might cause a miss during the prototype check.
1136 bool must_perfrom_prototype_check = *interceptor_holder != lookup->holder();
1137 bool must_preserve_receiver_reg = !receiver.is(holder_reg) &&
1138 (lookup->type() == CALLBACKS || must_perfrom_prototype_check);
1139
1132 // Save necessary data before invoking an interceptor. 1140 // Save necessary data before invoking an interceptor.
1133 // Requires a frame to make GC aware of pushed pointers. 1141 // Requires a frame to make GC aware of pushed pointers.
1134 { 1142 {
1135 FrameScope frame_scope(masm(), StackFrame::INTERNAL); 1143 FrameScope frame_scope(masm(), StackFrame::INTERNAL);
1136 1144
1137 if (lookup->type() == CALLBACKS && !receiver.is(holder_reg)) { 1145 if (must_preserve_receiver_reg) {
1138 // CALLBACKS case needs a receiver to be passed into C++ callback.
1139 __ push(receiver); 1146 __ push(receiver);
1140 } 1147 }
1141 __ push(holder_reg); 1148 __ push(holder_reg);
1142 __ push(name_reg); 1149 __ push(name_reg);
1143 1150
1144 // Invoke an interceptor. Note: map checks from receiver to 1151 // Invoke an interceptor. Note: map checks from receiver to
1145 // interceptor's holder has been compiled before (see a caller 1152 // interceptor's holder has been compiled before (see a caller
1146 // of this method.) 1153 // of this method.)
1147 CompileCallLoadPropertyWithInterceptor(masm(), 1154 CompileCallLoadPropertyWithInterceptor(masm(),
1148 receiver, 1155 receiver,
1149 holder_reg, 1156 holder_reg,
1150 name_reg, 1157 name_reg,
1151 interceptor_holder); 1158 interceptor_holder);
1152 1159
1153 // Check if interceptor provided a value for property. If it's 1160 // Check if interceptor provided a value for property. If it's
1154 // the case, return immediately. 1161 // the case, return immediately.
1155 Label interceptor_failed; 1162 Label interceptor_failed;
1156 __ cmp(eax, factory()->no_interceptor_result_sentinel()); 1163 __ cmp(eax, factory()->no_interceptor_result_sentinel());
1157 __ j(equal, &interceptor_failed); 1164 __ j(equal, &interceptor_failed);
1158 frame_scope.GenerateLeaveFrame(); 1165 frame_scope.GenerateLeaveFrame();
1159 __ ret(0); 1166 __ ret(0);
1160 1167
1168 // Clobber registers when generating debug-code to provoke errors.
1161 __ bind(&interceptor_failed); 1169 __ bind(&interceptor_failed);
1170 if (FLAG_debug_code) {
1171 __ mov(receiver, Immediate(BitCast<int32_t>(kZapValue)));
1172 __ mov(holder_reg, Immediate(BitCast<int32_t>(kZapValue)));
1173 __ mov(name_reg, Immediate(BitCast<int32_t>(kZapValue)));
1174 }
1175
1162 __ pop(name_reg); 1176 __ pop(name_reg);
1163 __ pop(holder_reg); 1177 __ pop(holder_reg);
1164 if (lookup->type() == CALLBACKS && !receiver.is(holder_reg)) { 1178 if (must_preserve_receiver_reg) {
1165 __ pop(receiver); 1179 __ pop(receiver);
1166 } 1180 }
1167 1181
1168 // Leave the internal frame. 1182 // Leave the internal frame.
1169 } 1183 }
1170 1184
1171 // Check that the maps from interceptor's holder to lookup's holder 1185 // Check that the maps from interceptor's holder to lookup's holder
1172 // haven't changed. And load lookup's holder into holder_reg. 1186 // haven't changed. And load lookup's holder into holder_reg.
1173 if (*interceptor_holder != lookup->holder()) { 1187 if (must_perfrom_prototype_check) {
1174 holder_reg = CheckPrototypes(interceptor_holder, 1188 holder_reg = CheckPrototypes(interceptor_holder,
1175 holder_reg, 1189 holder_reg,
1176 Handle<JSObject>(lookup->holder()), 1190 Handle<JSObject>(lookup->holder()),
1177 scratch1, 1191 scratch1,
1178 scratch2, 1192 scratch2,
1179 scratch3, 1193 scratch3,
1180 name, 1194 name,
1181 miss); 1195 miss);
1182 } 1196 }
1183 1197
(...skipping 2883 matching lines...) Expand 10 before | Expand all | Expand 10 after
4067 __ jmp(ic_slow, RelocInfo::CODE_TARGET); 4081 __ jmp(ic_slow, RelocInfo::CODE_TARGET);
4068 } 4082 }
4069 } 4083 }
4070 4084
4071 4085
4072 #undef __ 4086 #undef __
4073 4087
4074 } } // namespace v8::internal 4088 } } // namespace v8::internal
4075 4089
4076 #endif // V8_TARGET_ARCH_IA32 4090 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/arm/stub-cache-arm.cc ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698