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

Side by Side Diff: runtime/vm/assembler_ia32.cc

Issue 383443002: Removes branches from LoadTaggedClassIdMayBeSmi. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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 | « runtime/vm/assembler_ia32.h ('k') | runtime/vm/assembler_ia32_test.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 (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/code_generator.h" 9 #include "vm/code_generator.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 } 266 }
267 267
268 268
269 void Assembler::leal(Register dst, const Address& src) { 269 void Assembler::leal(Register dst, const Address& src) {
270 AssemblerBuffer::EnsureCapacity ensured(&buffer_); 270 AssemblerBuffer::EnsureCapacity ensured(&buffer_);
271 EmitUint8(0x8D); 271 EmitUint8(0x8D);
272 EmitOperand(dst, src); 272 EmitOperand(dst, src);
273 } 273 }
274 274
275 275
276 void Assembler::cmove(Register dst, Register src) {
277 AssemblerBuffer::EnsureCapacity ensured(&buffer_);
278 EmitUint8(0x0F);
279 EmitUint8(0x44);
280 EmitRegisterOperand(dst, src);
281 }
282
283
276 void Assembler::cmovs(Register dst, Register src) { 284 void Assembler::cmovs(Register dst, Register src) {
277 AssemblerBuffer::EnsureCapacity ensured(&buffer_); 285 AssemblerBuffer::EnsureCapacity ensured(&buffer_);
278 EmitUint8(0x0F); 286 EmitUint8(0x0F);
279 EmitUint8(0x48); 287 EmitUint8(0x48);
280 EmitRegisterOperand(dst, src); 288 EmitRegisterOperand(dst, src);
281 } 289 }
282 290
283 291
284 void Assembler::cmovns(Register dst, Register src) { 292 void Assembler::cmovns(Register dst, Register src) {
285 AssemblerBuffer::EnsureCapacity ensured(&buffer_); 293 AssemblerBuffer::EnsureCapacity ensured(&buffer_);
(...skipping 2365 matching lines...) Expand 10 before | Expand all | Expand 10 after
2651 2659
2652 2660
2653 void Assembler::CompareClassId(Register object, 2661 void Assembler::CompareClassId(Register object,
2654 intptr_t class_id, 2662 intptr_t class_id,
2655 Register scratch) { 2663 Register scratch) {
2656 LoadClassId(scratch, object); 2664 LoadClassId(scratch, object);
2657 cmpl(scratch, Immediate(class_id)); 2665 cmpl(scratch, Immediate(class_id));
2658 } 2666 }
2659 2667
2660 2668
2661 void Assembler::LoadTaggedClassIdMayBeSmi(Register result, Register object) { 2669 void Assembler::LoadTaggedClassIdMayBeSmi(
2662 testl(object, Immediate(kSmiTagMask)); 2670 Register result, Register object, Register tmp) {
2663 Label not_smi, done; 2671 ASSERT(object != tmp);
2664 j(NOT_ZERO, &not_smi, Assembler::kNearJump); 2672 ASSERT(result != tmp);
2665 movl(result, Immediate(Smi::RawValue(kSmiCid))); 2673
2666 jmp(&done, Assembler::kNearJump); 2674 // Make a copy of object since result and object can be the same register.
2667 Bind(&not_smi); 2675 movl(tmp, object);
2668 LoadClassId(result, object); 2676 // Load up a null object. We only need it so we can use LoadClassId on it in
2677 // the case that object is a Smi.
2678 movl(result, Immediate(reinterpret_cast<intptr_t>(Object::null())));
2679 // Check if the object is a Smi.
2680 testl(tmp, Immediate(kSmiTagMask));
2681 // If the object *is* a Smi, load the null object into tmp. o/w leave alone.
2682 cmove(tmp, result);
2683 // Loads either the cid of the object if it isn't a Smi, or the cid of null
2684 // if it is a Smi, which will be ignored.
2685 LoadClassId(result, tmp);
2686
2687 movl(tmp, Immediate(kSmiCid));
2688 // If object is a Smi, move the Smi cid into result. o/w leave alone.
2689 cmove(result, tmp);
2690 // Finally, tag the result.
2669 SmiTag(result); 2691 SmiTag(result);
2670 Bind(&done);
2671 } 2692 }
2672 2693
2673 2694
2674 static const char* cpu_reg_names[kNumberOfCpuRegisters] = { 2695 static const char* cpu_reg_names[kNumberOfCpuRegisters] = {
2675 "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi" 2696 "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi"
2676 }; 2697 };
2677 2698
2678 2699
2679 const char* Assembler::RegisterName(Register reg) { 2700 const char* Assembler::RegisterName(Register reg) {
2680 ASSERT((0 <= reg) && (reg < kNumberOfCpuRegisters)); 2701 ASSERT((0 <= reg) && (reg < kNumberOfCpuRegisters));
2681 return cpu_reg_names[reg]; 2702 return cpu_reg_names[reg];
2682 } 2703 }
2683 2704
2684 2705
2685 static const char* xmm_reg_names[kNumberOfXmmRegisters] = { 2706 static const char* xmm_reg_names[kNumberOfXmmRegisters] = {
2686 "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" 2707 "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7"
2687 }; 2708 };
2688 2709
2689 2710
2690 const char* Assembler::FpuRegisterName(FpuRegister reg) { 2711 const char* Assembler::FpuRegisterName(FpuRegister reg) {
2691 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); 2712 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters));
2692 return xmm_reg_names[reg]; 2713 return xmm_reg_names[reg];
2693 } 2714 }
2694 2715
2695 2716
2696 } // namespace dart 2717 } // namespace dart
2697 2718
2698 #endif // defined TARGET_ARCH_IA32 2719 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/assembler_ia32.h ('k') | runtime/vm/assembler_ia32_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698