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

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

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