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

Side by Side Diff: src/x64/stub-cache-x64.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/ia32/stub-cache-ia32.cc ('k') | test/cctest/test-api.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 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 1107
1108 if (compile_followup_inline) { 1108 if (compile_followup_inline) {
1109 // Compile the interceptor call, followed by inline code to load the 1109 // Compile the interceptor call, followed by inline code to load the
1110 // property from further up the prototype chain if the call fails. 1110 // property from further up the prototype chain if the call fails.
1111 // Check that the maps haven't changed. 1111 // Check that the maps haven't changed.
1112 Register holder_reg = CheckPrototypes(object, receiver, interceptor_holder, 1112 Register holder_reg = CheckPrototypes(object, receiver, interceptor_holder,
1113 scratch1, scratch2, scratch3, 1113 scratch1, scratch2, scratch3,
1114 name, miss); 1114 name, miss);
1115 ASSERT(holder_reg.is(receiver) || holder_reg.is(scratch1)); 1115 ASSERT(holder_reg.is(receiver) || holder_reg.is(scratch1));
1116 1116
1117 // Preserve the receiver register explicitly whenever it is different from
1118 // the holder and it is needed should the interceptor return without any
1119 // result. The CALLBACKS case needs the receiver to be passed into C++ code,
1120 // the FIELD case might cause a miss during the prototype check.
1121 bool must_perfrom_prototype_check = *interceptor_holder != lookup->holder();
1122 bool must_preserve_receiver_reg = !receiver.is(holder_reg) &&
1123 (lookup->type() == CALLBACKS || must_perfrom_prototype_check);
1124
1117 // Save necessary data before invoking an interceptor. 1125 // Save necessary data before invoking an interceptor.
1118 // Requires a frame to make GC aware of pushed pointers. 1126 // Requires a frame to make GC aware of pushed pointers.
1119 { 1127 {
1120 FrameScope frame_scope(masm(), StackFrame::INTERNAL); 1128 FrameScope frame_scope(masm(), StackFrame::INTERNAL);
1121 1129
1122 if (lookup->type() == CALLBACKS && !receiver.is(holder_reg)) { 1130 if (must_preserve_receiver_reg) {
1123 // CALLBACKS case needs a receiver to be passed into C++ callback.
1124 __ push(receiver); 1131 __ push(receiver);
1125 } 1132 }
1126 __ push(holder_reg); 1133 __ push(holder_reg);
1127 __ push(name_reg); 1134 __ push(name_reg);
1128 1135
1129 // Invoke an interceptor. Note: map checks from receiver to 1136 // Invoke an interceptor. Note: map checks from receiver to
1130 // interceptor's holder has been compiled before (see a caller 1137 // interceptor's holder has been compiled before (see a caller
1131 // of this method.) 1138 // of this method.)
1132 CompileCallLoadPropertyWithInterceptor(masm(), 1139 CompileCallLoadPropertyWithInterceptor(masm(),
1133 receiver, 1140 receiver,
1134 holder_reg, 1141 holder_reg,
1135 name_reg, 1142 name_reg,
1136 interceptor_holder); 1143 interceptor_holder);
1137 1144
1138 // Check if interceptor provided a value for property. If it's 1145 // Check if interceptor provided a value for property. If it's
1139 // the case, return immediately. 1146 // the case, return immediately.
1140 Label interceptor_failed; 1147 Label interceptor_failed;
1141 __ CompareRoot(rax, Heap::kNoInterceptorResultSentinelRootIndex); 1148 __ CompareRoot(rax, Heap::kNoInterceptorResultSentinelRootIndex);
1142 __ j(equal, &interceptor_failed); 1149 __ j(equal, &interceptor_failed);
1143 frame_scope.GenerateLeaveFrame(); 1150 frame_scope.GenerateLeaveFrame();
1144 __ ret(0); 1151 __ ret(0);
1145 1152
1146 __ bind(&interceptor_failed); 1153 __ bind(&interceptor_failed);
1147 __ pop(name_reg); 1154 __ pop(name_reg);
1148 __ pop(holder_reg); 1155 __ pop(holder_reg);
1149 if (lookup->type() == CALLBACKS && !receiver.is(holder_reg)) { 1156 if (must_preserve_receiver_reg) {
1150 __ pop(receiver); 1157 __ pop(receiver);
1151 } 1158 }
1152 1159
1153 // Leave the internal frame. 1160 // Leave the internal frame.
1154 } 1161 }
1155 1162
1156 // Check that the maps from interceptor's holder to lookup's holder 1163 // Check that the maps from interceptor's holder to lookup's holder
1157 // haven't changed. And load lookup's holder into |holder| register. 1164 // haven't changed. And load lookup's holder into |holder| register.
1158 if (*interceptor_holder != lookup->holder()) { 1165 if (must_perfrom_prototype_check) {
1159 holder_reg = CheckPrototypes(interceptor_holder, 1166 holder_reg = CheckPrototypes(interceptor_holder,
1160 holder_reg, 1167 holder_reg,
1161 Handle<JSObject>(lookup->holder()), 1168 Handle<JSObject>(lookup->holder()),
1162 scratch1, 1169 scratch1,
1163 scratch2, 1170 scratch2,
1164 scratch3, 1171 scratch3,
1165 name, 1172 name,
1166 miss); 1173 miss);
1167 } 1174 }
1168 1175
(...skipping 2655 matching lines...) Expand 10 before | Expand all | Expand 10 after
3824 __ jmp(ic_slow, RelocInfo::CODE_TARGET); 3831 __ jmp(ic_slow, RelocInfo::CODE_TARGET);
3825 } 3832 }
3826 } 3833 }
3827 3834
3828 3835
3829 #undef __ 3836 #undef __
3830 3837
3831 } } // namespace v8::internal 3838 } } // namespace v8::internal
3832 3839
3833 #endif // V8_TARGET_ARCH_X64 3840 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/ia32/stub-cache-ia32.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698