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

Side by Side Diff: src/ia32/ic-ia32.cc

Issue 573009: Change LoadIC interface on ia32 to take arguments in registers. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 10 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/full-codegen-ia32.cc ('k') | src/ia32/stub-cache-ia32.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #define __ ACCESS_MASM(masm) 43 #define __ ACCESS_MASM(masm)
44 44
45 45
46 // Helper function used to load a property from a dictionary backing storage. 46 // Helper function used to load a property from a dictionary backing storage.
47 // This function may return false negatives, so miss_label 47 // This function may return false negatives, so miss_label
48 // must always call a backup property load that is complete. 48 // must always call a backup property load that is complete.
49 // This function is safe to call if the receiver has fast properties, 49 // This function is safe to call if the receiver has fast properties,
50 // or if name is not a symbol, and will jump to the miss_label in that case. 50 // or if name is not a symbol, and will jump to the miss_label in that case.
51 static void GenerateDictionaryLoad(MacroAssembler* masm, 51 static void GenerateDictionaryLoad(MacroAssembler* masm,
52 Label* miss_label, 52 Label* miss_label,
53 Register receiver,
54 Register name,
53 Register r0, 55 Register r0,
54 Register r1, 56 Register r1,
55 Register r2, 57 Register r2,
56 Register name,
57 DictionaryCheck check_dictionary) { 58 DictionaryCheck check_dictionary) {
58 // Register use: 59 // Register use:
59 // 60 //
61 // name - holds the name of the property and is unchanged.
62 // receiver - holds the receiver and is unchanged.
63 // Scratch registers:
60 // r0 - used to hold the property dictionary. 64 // r0 - used to hold the property dictionary.
61 // 65 //
62 // r1 - initially the receiver 66 // r1 - used for the index into the property dictionary
63 // - used for the index into the property dictionary
64 // - holds the result on exit. 67 // - holds the result on exit.
65 // 68 //
66 // r2 - used to hold the capacity of the property dictionary. 69 // r2 - used to hold the capacity of the property dictionary.
67 //
68 // name - holds the name of the property and is unchanged.
69 70
70 Label done; 71 Label done;
71 72
72 // Check for the absence of an interceptor. 73 // Check for the absence of an interceptor.
73 // Load the map into r0. 74 // Load the map into r0.
74 __ mov(r0, FieldOperand(r1, JSObject::kMapOffset)); 75 __ mov(r0, FieldOperand(receiver, JSObject::kMapOffset));
75 // Test the has_named_interceptor bit in the map. 76 // Test the has_named_interceptor bit in the map.
76 __ test(FieldOperand(r0, Map::kInstanceAttributesOffset), 77 __ test(FieldOperand(r0, Map::kInstanceAttributesOffset),
77 Immediate(1 << (Map::kHasNamedInterceptor + (3 * 8)))); 78 Immediate(1 << (Map::kHasNamedInterceptor + (3 * 8))));
78 79
79 // Jump to miss if the interceptor bit is set. 80 // Jump to miss if the interceptor bit is set.
80 __ j(not_zero, miss_label, not_taken); 81 __ j(not_zero, miss_label, not_taken);
81 82
82 // Bail out if we have a JS global proxy object. 83 // Bail out if we have a JS global proxy object.
83 __ movzx_b(r0, FieldOperand(r0, Map::kInstanceTypeOffset)); 84 __ movzx_b(r0, FieldOperand(r0, Map::kInstanceTypeOffset));
84 __ cmp(r0, JS_GLOBAL_PROXY_TYPE); 85 __ cmp(r0, JS_GLOBAL_PROXY_TYPE);
85 __ j(equal, miss_label, not_taken); 86 __ j(equal, miss_label, not_taken);
86 87
87 // Possible work-around for http://crbug.com/16276. 88 // Possible work-around for http://crbug.com/16276.
88 __ cmp(r0, JS_GLOBAL_OBJECT_TYPE); 89 __ cmp(r0, JS_GLOBAL_OBJECT_TYPE);
89 __ j(equal, miss_label, not_taken); 90 __ j(equal, miss_label, not_taken);
90 __ cmp(r0, JS_BUILTINS_OBJECT_TYPE); 91 __ cmp(r0, JS_BUILTINS_OBJECT_TYPE);
91 __ j(equal, miss_label, not_taken); 92 __ j(equal, miss_label, not_taken);
92 93
93 // Load properties array. 94 // Load properties array.
94 __ mov(r0, FieldOperand(r1, JSObject::kPropertiesOffset)); 95 __ mov(r0, FieldOperand(receiver, JSObject::kPropertiesOffset));
95 96
96 // Check that the properties array is a dictionary. 97 // Check that the properties array is a dictionary.
97 if (check_dictionary == CHECK_DICTIONARY) { 98 if (check_dictionary == CHECK_DICTIONARY) {
98 __ cmp(FieldOperand(r0, HeapObject::kMapOffset), 99 __ cmp(FieldOperand(r0, HeapObject::kMapOffset),
99 Immediate(Factory::hash_table_map())); 100 Immediate(Factory::hash_table_map()));
100 __ j(not_equal, miss_label); 101 __ j(not_equal, miss_label);
101 } 102 }
102 103
103 // Compute the capacity mask. 104 // Compute the capacity mask.
104 const int kCapacityOffset = 105 const int kCapacityOffset =
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 170
170 171
171 // The offset from the inlined patch site to the start of the 172 // The offset from the inlined patch site to the start of the
172 // inlined load instruction. It is 7 bytes (test eax, imm) plus 173 // inlined load instruction. It is 7 bytes (test eax, imm) plus
173 // 6 bytes (jne slow_label). 174 // 6 bytes (jne slow_label).
174 const int LoadIC::kOffsetToLoadInstruction = 13; 175 const int LoadIC::kOffsetToLoadInstruction = 13;
175 176
176 177
177 void LoadIC::GenerateArrayLength(MacroAssembler* masm) { 178 void LoadIC::GenerateArrayLength(MacroAssembler* masm) {
178 // ----------- S t a t e ------------- 179 // ----------- S t a t e -------------
180 // -- eax : receiver
179 // -- ecx : name 181 // -- ecx : name
180 // -- esp[0] : return address 182 // -- esp[0] : return address
181 // -- esp[4] : receiver
182 // ----------------------------------- 183 // -----------------------------------
183 Label miss; 184 Label miss;
184 185
185 __ mov(eax, Operand(esp, kPointerSize));
186
187 StubCompiler::GenerateLoadArrayLength(masm, eax, edx, &miss); 186 StubCompiler::GenerateLoadArrayLength(masm, eax, edx, &miss);
188 __ bind(&miss); 187 __ bind(&miss);
189 StubCompiler::GenerateLoadMiss(masm, Code::LOAD_IC); 188 StubCompiler::GenerateLoadMiss(masm, Code::LOAD_IC);
190 } 189 }
191 190
192 191
193 void LoadIC::GenerateStringLength(MacroAssembler* masm) { 192 void LoadIC::GenerateStringLength(MacroAssembler* masm) {
194 // ----------- S t a t e ------------- 193 // ----------- S t a t e -------------
194 // -- eax : receiver
195 // -- ecx : name 195 // -- ecx : name
196 // -- esp[0] : return address 196 // -- esp[0] : return address
197 // -- esp[4] : receiver
198 // ----------------------------------- 197 // -----------------------------------
199 Label miss; 198 Label miss;
200 199
201 __ mov(eax, Operand(esp, kPointerSize));
202
203 StubCompiler::GenerateLoadStringLength(masm, eax, edx, ebx, &miss); 200 StubCompiler::GenerateLoadStringLength(masm, eax, edx, ebx, &miss);
204 __ bind(&miss); 201 __ bind(&miss);
205 StubCompiler::GenerateLoadMiss(masm, Code::LOAD_IC); 202 StubCompiler::GenerateLoadMiss(masm, Code::LOAD_IC);
206 } 203 }
207 204
208 205
209 void LoadIC::GenerateFunctionPrototype(MacroAssembler* masm) { 206 void LoadIC::GenerateFunctionPrototype(MacroAssembler* masm) {
210 // ----------- S t a t e ------------- 207 // ----------- S t a t e -------------
208 // -- eax : receiver
211 // -- ecx : name 209 // -- ecx : name
212 // -- esp[0] : return address 210 // -- esp[0] : return address
213 // -- esp[4] : receiver
214 // ----------------------------------- 211 // -----------------------------------
215 Label miss; 212 Label miss;
216 213
217 __ mov(eax, Operand(esp, kPointerSize));
218
219 StubCompiler::GenerateLoadFunctionPrototype(masm, eax, edx, ebx, &miss); 214 StubCompiler::GenerateLoadFunctionPrototype(masm, eax, edx, ebx, &miss);
220 __ bind(&miss); 215 __ bind(&miss);
221 StubCompiler::GenerateLoadMiss(masm, Code::LOAD_IC); 216 StubCompiler::GenerateLoadMiss(masm, Code::LOAD_IC);
222 } 217 }
223 218
224 219
225 void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) { 220 void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) {
226 // ----------- S t a t e ------------- 221 // ----------- S t a t e -------------
227 // -- esp[0] : return address 222 // -- esp[0] : return address
228 // -- esp[4] : name 223 // -- esp[4] : name
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 __ movzx_b(edx, FieldOperand(ebx, Map::kInstanceSizeOffset)); 352 __ movzx_b(edx, FieldOperand(ebx, Map::kInstanceSizeOffset));
358 __ add(eax, Operand(edx)); 353 __ add(eax, Operand(edx));
359 __ mov(eax, FieldOperand(ecx, eax, times_pointer_size, 0)); 354 __ mov(eax, FieldOperand(ecx, eax, times_pointer_size, 0));
360 __ ret(0); 355 __ ret(0);
361 356
362 // Do a quick inline probe of the receiver's dictionary, if it 357 // Do a quick inline probe of the receiver's dictionary, if it
363 // exists. 358 // exists.
364 __ bind(&probe_dictionary); 359 __ bind(&probe_dictionary);
365 GenerateDictionaryLoad(masm, 360 GenerateDictionaryLoad(masm,
366 &slow, 361 &slow,
362 ecx,
363 eax,
367 ebx, 364 ebx,
368 ecx,
369 edx, 365 edx,
370 eax, 366 edi,
371 DICTIONARY_CHECK_DONE); 367 DICTIONARY_CHECK_DONE);
372 GenerateCheckNonObjectOrLoaded(masm, &slow, ecx, edx); 368 GenerateCheckNonObjectOrLoaded(masm, &slow, edx, ebx);
373 __ mov(eax, Operand(ecx)); 369 __ mov(eax, Operand(edx));
374 __ IncrementCounter(&Counters::keyed_load_generic_symbol, 1); 370 __ IncrementCounter(&Counters::keyed_load_generic_symbol, 1);
375 __ ret(0); 371 __ ret(0);
376 372
377 // If the hash field contains an array index pick it out. The assert checks 373 // If the hash field contains an array index pick it out. The assert checks
378 // that the constants for the maximum number of digits for an array index 374 // that the constants for the maximum number of digits for an array index
379 // cached in the hash field and the number of bits reserved for it does not 375 // cached in the hash field and the number of bits reserved for it does not
380 // conflict. 376 // conflict.
381 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) < 377 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) <
382 (1 << String::kArrayIndexValueBits)); 378 (1 << String::kArrayIndexValueBits));
383 __ bind(&index_string); 379 __ bind(&index_string);
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 // -- ecx : name 990 // -- ecx : name
995 // -- edx : receiver 991 // -- edx : receiver
996 // -- esp[0] : return address 992 // -- esp[0] : return address
997 // -- esp[(argc - n) * 4] : arg[n] (zero-based) 993 // -- esp[(argc - n) * 4] : arg[n] (zero-based)
998 // -- ... 994 // -- ...
999 // -- esp[(argc + 1) * 4] : receiver 995 // -- esp[(argc + 1) * 4] : receiver
1000 // ----------------------------------- 996 // -----------------------------------
1001 997
1002 // Search dictionary - put result in register edi. 998 // Search dictionary - put result in register edi.
1003 __ mov(edi, edx); 999 __ mov(edi, edx);
1004 GenerateDictionaryLoad(masm, miss, eax, edi, ebx, ecx, CHECK_DICTIONARY); 1000 GenerateDictionaryLoad(masm, miss, edx, ecx, eax, edi, ebx, CHECK_DICTIONARY);
1005 1001
1006 // Check that the result is not a smi. 1002 // Check that the result is not a smi.
1007 __ test(edi, Immediate(kSmiTagMask)); 1003 __ test(edi, Immediate(kSmiTagMask));
1008 __ j(zero, miss, not_taken); 1004 __ j(zero, miss, not_taken);
1009 1005
1010 // Check that the value is a JavaScript function, fetching its map into eax. 1006 // Check that the value is a JavaScript function, fetching its map into eax.
1011 __ CmpObjectType(edi, JS_FUNCTION_TYPE, eax); 1007 __ CmpObjectType(edi, JS_FUNCTION_TYPE, eax);
1012 __ j(not_equal, miss, not_taken); 1008 __ j(not_equal, miss, not_taken);
1013 1009
1014 // Check that the function has been loaded. eax holds function's map. 1010 // Check that the function has been loaded. eax holds function's map.
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 __ bind(&invoke); 1139 __ bind(&invoke);
1144 __ InvokeFunction(edi, actual, JUMP_FUNCTION); 1140 __ InvokeFunction(edi, actual, JUMP_FUNCTION);
1145 } 1141 }
1146 1142
1147 1143
1148 // Defined in ic.cc. 1144 // Defined in ic.cc.
1149 Object* LoadIC_Miss(Arguments args); 1145 Object* LoadIC_Miss(Arguments args);
1150 1146
1151 void LoadIC::GenerateMegamorphic(MacroAssembler* masm) { 1147 void LoadIC::GenerateMegamorphic(MacroAssembler* masm) {
1152 // ----------- S t a t e ------------- 1148 // ----------- S t a t e -------------
1149 // -- eax : receiver
1153 // -- ecx : name 1150 // -- ecx : name
1154 // -- esp[0] : return address 1151 // -- esp[0] : return address
1155 // -- esp[4] : receiver
1156 // ----------------------------------- 1152 // -----------------------------------
1157 1153
1158 __ mov(eax, Operand(esp, kPointerSize));
1159
1160 // Probe the stub cache. 1154 // Probe the stub cache.
1161 Code::Flags flags = Code::ComputeFlags(Code::LOAD_IC, 1155 Code::Flags flags = Code::ComputeFlags(Code::LOAD_IC,
1162 NOT_IN_LOOP, 1156 NOT_IN_LOOP,
1163 MONOMORPHIC); 1157 MONOMORPHIC);
1164 StubCache::GenerateProbe(masm, flags, eax, ecx, ebx, edx); 1158 StubCache::GenerateProbe(masm, flags, eax, ecx, ebx, edx);
1165 1159
1166 // Cache miss: Jump to runtime. 1160 // Cache miss: Jump to runtime.
1167 GenerateMiss(masm); 1161 GenerateMiss(masm);
1168 } 1162 }
1169 1163
1170 1164
1171 void LoadIC::GenerateNormal(MacroAssembler* masm) { 1165 void LoadIC::GenerateNormal(MacroAssembler* masm) {
1172 // ----------- S t a t e ------------- 1166 // ----------- S t a t e -------------
1167 // -- eax : receiver
1173 // -- ecx : name 1168 // -- ecx : name
1174 // -- esp[0] : return address 1169 // -- esp[0] : return address
1175 // -- esp[4] : receiver
1176 // ----------------------------------- 1170 // -----------------------------------
1177 Label miss, probe, global; 1171 Label miss, probe, global;
1178 1172
1179 __ mov(eax, Operand(esp, kPointerSize));
1180
1181 // Check that the receiver isn't a smi. 1173 // Check that the receiver isn't a smi.
1182 __ test(eax, Immediate(kSmiTagMask)); 1174 __ test(eax, Immediate(kSmiTagMask));
1183 __ j(zero, &miss, not_taken); 1175 __ j(zero, &miss, not_taken);
1184 1176
1185 // Check that the receiver is a valid JS object. 1177 // Check that the receiver is a valid JS object.
1186 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); 1178 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
1187 __ movzx_b(edx, FieldOperand(ebx, Map::kInstanceTypeOffset)); 1179 __ movzx_b(edx, FieldOperand(ebx, Map::kInstanceTypeOffset));
1188 __ cmp(edx, FIRST_JS_OBJECT_TYPE); 1180 __ cmp(edx, FIRST_JS_OBJECT_TYPE);
1189 __ j(less, &miss, not_taken); 1181 __ j(less, &miss, not_taken);
1190 1182
1191 // If this assert fails, we have to check upper bound too. 1183 // If this assert fails, we have to check upper bound too.
1192 ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); 1184 ASSERT(LAST_TYPE == JS_FUNCTION_TYPE);
1193 1185
1194 // Check for access to global object (unlikely). 1186 // Check for access to global object (unlikely).
1195 __ cmp(edx, JS_GLOBAL_PROXY_TYPE); 1187 __ cmp(edx, JS_GLOBAL_PROXY_TYPE);
1196 __ j(equal, &global, not_taken); 1188 __ j(equal, &global, not_taken);
1197 1189
1198 // Check for non-global object that requires access check. 1190 // Check for non-global object that requires access check.
1199 __ movzx_b(ebx, FieldOperand(ebx, Map::kBitFieldOffset)); 1191 __ movzx_b(ebx, FieldOperand(ebx, Map::kBitFieldOffset));
1200 __ test(ebx, Immediate(1 << Map::kIsAccessCheckNeeded)); 1192 __ test(ebx, Immediate(1 << Map::kIsAccessCheckNeeded));
1201 __ j(not_zero, &miss, not_taken); 1193 __ j(not_zero, &miss, not_taken);
1202 1194
1203 // Search the dictionary placing the result in eax. 1195 // Search the dictionary placing the result in eax.
1204 __ bind(&probe); 1196 __ bind(&probe);
1205 GenerateDictionaryLoad(masm, &miss, edx, eax, ebx, ecx, CHECK_DICTIONARY); 1197 GenerateDictionaryLoad(masm,
1206 GenerateCheckNonObjectOrLoaded(masm, &miss, eax, edx); 1198 &miss,
1199 eax,
1200 ecx,
1201 edx,
1202 edi,
1203 ebx,
1204 CHECK_DICTIONARY);
1205 GenerateCheckNonObjectOrLoaded(masm, &miss, edi, edx);
1206 __ mov(eax, edi);
1207 __ ret(0); 1207 __ ret(0);
1208 1208
1209 // Global object access: Check access rights. 1209 // Global object access: Check access rights.
1210 __ bind(&global); 1210 __ bind(&global);
1211 __ CheckAccessGlobalProxy(eax, edx, &miss); 1211 __ CheckAccessGlobalProxy(eax, edx, &miss);
1212 __ jmp(&probe); 1212 __ jmp(&probe);
1213 1213
1214 // Cache miss: Restore receiver from stack and jump to runtime. 1214 // Cache miss: Restore receiver from stack and jump to runtime.
1215 __ bind(&miss); 1215 __ bind(&miss);
1216 __ mov(eax, Operand(esp, 1 * kPointerSize));
1217 GenerateMiss(masm); 1216 GenerateMiss(masm);
1218 } 1217 }
1219 1218
1220 1219
1221 void LoadIC::GenerateMiss(MacroAssembler* masm) { 1220 void LoadIC::GenerateMiss(MacroAssembler* masm) {
1222 // ----------- S t a t e ------------- 1221 // ----------- S t a t e -------------
1222 // -- eax : receiver
1223 // -- ecx : name 1223 // -- ecx : name
1224 // -- esp[0] : return address 1224 // -- esp[0] : return address
1225 // -- esp[4] : receiver
1226 // ----------------------------------- 1225 // -----------------------------------
1227 1226
1228 __ pop(ebx); 1227 __ pop(ebx);
1229 __ push(Operand(esp, 0)); // receiver 1228 __ push(eax); // receiver
1230 __ push(ecx); // name 1229 __ push(ecx); // name
1231 __ push(ebx); // return address 1230 __ push(ebx); // return address
1232 1231
1233 // Perform tail call to the entry. 1232 // Perform tail call to the entry.
1234 __ TailCallRuntime(ExternalReference(IC_Utility(kLoadIC_Miss)), 2, 1); 1233 __ TailCallRuntime(ExternalReference(IC_Utility(kLoadIC_Miss)), 2, 1);
1235 } 1234 }
1236 1235
1237 1236
1238 // One byte opcode for test eax,0xXXXXXXXX. 1237 // One byte opcode for test eax,0xXXXXXXXX.
1239 static const byte kTestEaxByte = 0xA9; 1238 static const byte kTestEaxByte = 0xA9;
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 __ push(ecx); 1440 __ push(ecx);
1442 1441
1443 // Do tail-call to runtime routine. 1442 // Do tail-call to runtime routine.
1444 __ TailCallRuntime(ExternalReference(IC_Utility(kKeyedStoreIC_Miss)), 3, 1); 1443 __ TailCallRuntime(ExternalReference(IC_Utility(kKeyedStoreIC_Miss)), 3, 1);
1445 } 1444 }
1446 1445
1447 #undef __ 1446 #undef __
1448 1447
1449 1448
1450 } } // namespace v8::internal 1449 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/ia32/stub-cache-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698