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

Unified 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 side-by-side diff with in-line comments
Download patch
« src/macro-assembler-ia32.cc ('K') | « src/runtime.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/stub-cache-ia32.cc
===================================================================
--- src/stub-cache-ia32.cc (revision 469)
+++ src/stub-cache-ia32.cc (working copy)
@@ -232,52 +232,10 @@
Register scratch1,
Register scratch2,
Label* miss_label) {
- // Check that the receiver isn't a smi.
- __ test(receiver, Immediate(kSmiTagMask));
- __ j(zero, miss_label, not_taken);
- // Check that the receiver is a function.
- __ mov(scratch1, FieldOperand(receiver, HeapObject::kMapOffset));
- __ movzx_b(scratch2, FieldOperand(scratch1, Map::kInstanceTypeOffset));
- __ cmp(scratch2, JS_FUNCTION_TYPE);
- __ j(not_equal, miss_label, not_taken);
-
- // Make sure that the function has an instance prototype.
- Label non_instance;
- __ movzx_b(scratch2, FieldOperand(scratch1, Map::kBitFieldOffset));
- __ test(scratch2, Immediate(1 << Map::kHasNonInstancePrototype));
- __ j(not_zero, &non_instance, not_taken);
-
- // Get the prototype or initial map from the function.
- __ mov(scratch1,
- FieldOperand(receiver, JSFunction::kPrototypeOrInitialMapOffset));
-
- // If the prototype or initial map is the hole, don't return it and
- // simply miss the cache instead. This will allow us to allocate a
- // prototype object on-demand in the runtime system.
- __ cmp(Operand(scratch1), Immediate(Factory::the_hole_value()));
- __ j(equal, miss_label, not_taken);
+ __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label);
__ mov(eax, Operand(scratch1));
-
- // If the function does not have an initial map, we're done.
- Label done;
- __ mov(scratch1, FieldOperand(eax, HeapObject::kMapOffset));
- __ movzx_b(scratch2, FieldOperand(scratch1, Map::kInstanceTypeOffset));
- __ cmp(scratch2, MAP_TYPE);
- __ j(not_equal, &done);
-
- // Get the prototype from the initial map.
- __ mov(eax, FieldOperand(eax, Map::kPrototypeOffset));
-
- // All done: Return the prototype.
- __ bind(&done);
__ ret(0);
-
- // Non-instance prototype: Fetch prototype from constructor field
- // in initial map.
- __ bind(&non_instance);
- __ mov(eax, FieldOperand(scratch1, Map::kConstructorOffset));
- __ ret(0);
}
« 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