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

Side by Side Diff: src/macro-assembler-ia32.cc

Issue 39336: Refactored the code for comparing the type of an object with a constant.... Base URL: http://v8.googlecode.com/svn/branches/experimental/global/
Patch Set: Created 11 years, 9 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
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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 } else { 298 } else {
299 mov(dst, x); 299 mov(dst, x);
300 } 300 }
301 } 301 }
302 302
303 303
304 void MacroAssembler::Set(const Operand& dst, const Immediate& x) { 304 void MacroAssembler::Set(const Operand& dst, const Immediate& x) {
305 mov(dst, x); 305 mov(dst, x);
306 } 306 }
307 307
308 void MacroAssembler::CmpObjectType(Register heap_object,
309 InstanceType type,
310 Register map) {
311 mov(map, FieldOperand(heap_object, HeapObject::kMapOffset));
312 CmpInstanceType(map, type);
313 }
314
315
316 void MacroAssembler::CmpInstanceType(Register map, InstanceType type) {
317 cmpb(FieldOperand(map, Map::kInstanceTypeOffset),
318 static_cast<int8_t>(type));
319 }
320
308 321
309 void MacroAssembler::FCmp() { 322 void MacroAssembler::FCmp() {
310 fcompp(); 323 fcompp();
311 push(eax); 324 push(eax);
312 fnstsw_ax(); 325 fnstsw_ax();
313 sahf(); 326 sahf();
314 pop(eax); 327 pop(eax);
315 } 328 }
316 329
317 330
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 663
651 void MacroAssembler::TryGetFunctionPrototype(Register function, 664 void MacroAssembler::TryGetFunctionPrototype(Register function,
652 Register result, 665 Register result,
653 Register scratch, 666 Register scratch,
654 Label* miss) { 667 Label* miss) {
655 // Check that the receiver isn't a smi. 668 // Check that the receiver isn't a smi.
656 test(function, Immediate(kSmiTagMask)); 669 test(function, Immediate(kSmiTagMask));
657 j(zero, miss, not_taken); 670 j(zero, miss, not_taken);
658 671
659 // Check that the function really is a function. 672 // Check that the function really is a function.
660 mov(result, FieldOperand(function, HeapObject::kMapOffset)); 673 CmpObjectType(function, JS_FUNCTION_TYPE, result);
661 movzx_b(scratch, FieldOperand(result, Map::kInstanceTypeOffset));
662 cmp(scratch, JS_FUNCTION_TYPE);
663 j(not_equal, miss, not_taken); 674 j(not_equal, miss, not_taken);
664 675
665 // Make sure that the function has an instance prototype. 676 // Make sure that the function has an instance prototype.
666 Label non_instance; 677 Label non_instance;
667 movzx_b(scratch, FieldOperand(result, Map::kBitFieldOffset)); 678 movzx_b(scratch, FieldOperand(result, Map::kBitFieldOffset));
668 test(scratch, Immediate(1 << Map::kHasNonInstancePrototype)); 679 test(scratch, Immediate(1 << Map::kHasNonInstancePrototype));
669 j(not_zero, &non_instance, not_taken); 680 j(not_zero, &non_instance, not_taken);
670 681
671 // Get the prototype or initial map from the function. 682 // Get the prototype or initial map from the function.
672 mov(result, 683 mov(result,
673 FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); 684 FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset));
674 685
675 // If the prototype or initial map is the hole, don't return it and 686 // If the prototype or initial map is the hole, don't return it and
676 // simply miss the cache instead. This will allow us to allocate a 687 // simply miss the cache instead. This will allow us to allocate a
677 // prototype object on-demand in the runtime system. 688 // prototype object on-demand in the runtime system.
678 cmp(Operand(result), Immediate(Factory::the_hole_value())); 689 cmp(Operand(result), Immediate(Factory::the_hole_value()));
679 j(equal, miss, not_taken); 690 j(equal, miss, not_taken);
680 691
681 // If the function does not have an initial map, we're done. 692 // If the function does not have an initial map, we're done.
682 Label done; 693 Label done;
683 mov(scratch, FieldOperand(result, HeapObject::kMapOffset)); 694 CmpObjectType(result, MAP_TYPE, scratch);
684 movzx_b(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset));
685 cmp(scratch, MAP_TYPE);
686 j(not_equal, &done); 695 j(not_equal, &done);
687 696
688 // Get the prototype from the initial map. 697 // Get the prototype from the initial map.
689 mov(result, FieldOperand(result, Map::kPrototypeOffset)); 698 mov(result, FieldOperand(result, Map::kPrototypeOffset));
690 jmp(&done); 699 jmp(&done);
691 700
692 // Non-instance prototype: Fetch prototype from constructor field 701 // Non-instance prototype: Fetch prototype from constructor field
693 // in initial map. 702 // in initial map.
694 bind(&non_instance); 703 bind(&non_instance);
695 mov(result, FieldOperand(result, Map::kConstructorOffset)); 704 mov(result, FieldOperand(result, Map::kConstructorOffset));
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 // Indicate that code has changed. 1036 // Indicate that code has changed.
1028 CPU::FlushICache(address_, size_); 1037 CPU::FlushICache(address_, size_);
1029 1038
1030 // Check that the code was patched as expected. 1039 // Check that the code was patched as expected.
1031 ASSERT(masm_.pc_ == address_ + size_); 1040 ASSERT(masm_.pc_ == address_ + size_);
1032 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); 1041 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
1033 } 1042 }
1034 1043
1035 1044
1036 } } // namespace v8::internal 1045 } } // namespace v8::internal
OLDNEW
« src/builtins-ia32.cc ('K') | « src/macro-assembler-ia32.h ('k') | src/stub-cache-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698