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

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

Issue 6341: Improve the generated code for the instanceof operator. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 2 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
« src/macro-assembler-ia32.cc ('K') | « src/runtime.js ('k') | no next file » | 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 __ shl(eax, kSmiTagSize); 225 __ shl(eax, kSmiTagSize);
226 __ ret(0); 226 __ ret(0);
227 } 227 }
228 228
229 229
230 void StubCompiler::GenerateLoadFunctionPrototype(MacroAssembler* masm, 230 void StubCompiler::GenerateLoadFunctionPrototype(MacroAssembler* masm,
231 Register receiver, 231 Register receiver,
232 Register scratch1, 232 Register scratch1,
233 Register scratch2, 233 Register scratch2,
234 Label* miss_label) { 234 Label* miss_label) {
235 // Check that the receiver isn't a smi.
236 __ test(receiver, Immediate(kSmiTagMask));
237 __ j(zero, miss_label, not_taken);
238 235
239 // Check that the receiver is a function. 236 __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label);
240 __ mov(scratch1, FieldOperand(receiver, HeapObject::kMapOffset));
241 __ movzx_b(scratch2, FieldOperand(scratch1, Map::kInstanceTypeOffset));
242 __ cmp(scratch2, JS_FUNCTION_TYPE);
243 __ j(not_equal, miss_label, not_taken);
244
245 // Make sure that the function has an instance prototype.
246 Label non_instance;
247 __ movzx_b(scratch2, FieldOperand(scratch1, Map::kBitFieldOffset));
248 __ test(scratch2, Immediate(1 << Map::kHasNonInstancePrototype));
249 __ j(not_zero, &non_instance, not_taken);
250
251 // Get the prototype or initial map from the function.
252 __ mov(scratch1,
253 FieldOperand(receiver, JSFunction::kPrototypeOrInitialMapOffset));
254
255 // If the prototype or initial map is the hole, don't return it and
256 // simply miss the cache instead. This will allow us to allocate a
257 // prototype object on-demand in the runtime system.
258 __ cmp(Operand(scratch1), Immediate(Factory::the_hole_value()));
259 __ j(equal, miss_label, not_taken);
260 __ mov(eax, Operand(scratch1)); 237 __ mov(eax, Operand(scratch1));
261
262 // If the function does not have an initial map, we're done.
263 Label done;
264 __ mov(scratch1, FieldOperand(eax, HeapObject::kMapOffset));
265 __ movzx_b(scratch2, FieldOperand(scratch1, Map::kInstanceTypeOffset));
266 __ cmp(scratch2, MAP_TYPE);
267 __ j(not_equal, &done);
268
269 // Get the prototype from the initial map.
270 __ mov(eax, FieldOperand(eax, Map::kPrototypeOffset));
271
272 // All done: Return the prototype.
273 __ bind(&done);
274 __ ret(0);
275
276 // Non-instance prototype: Fetch prototype from constructor field
277 // in initial map.
278 __ bind(&non_instance);
279 __ mov(eax, FieldOperand(scratch1, Map::kConstructorOffset));
280 __ ret(0); 238 __ ret(0);
281 } 239 }
282 240
283 241
284 void StubCompiler::GenerateLoadField(MacroAssembler* masm, 242 void StubCompiler::GenerateLoadField(MacroAssembler* masm,
285 JSObject* object, 243 JSObject* object,
286 JSObject* holder, 244 JSObject* holder,
287 Register receiver, 245 Register receiver,
288 Register scratch1, 246 Register scratch1,
289 Register scratch2, 247 Register scratch2,
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); 1212 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
1255 1213
1256 // Return the generated code. 1214 // Return the generated code.
1257 return GetCode(CALLBACKS); 1215 return GetCode(CALLBACKS);
1258 } 1216 }
1259 1217
1260 1218
1261 #undef __ 1219 #undef __
1262 1220
1263 } } // namespace v8::internal 1221 } } // namespace v8::internal
OLDNEW
« src/macro-assembler-ia32.cc ('K') | « src/runtime.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698