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

Side by Side Diff: src/x64/codegen-x64.cc

Issue 155132: X64: Use CmpObjectType macro everywhere, fix problem with sign of instance ty... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 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 | « no previous file | src/x64/ic-x64.cc » ('j') | src/x64/ic-x64.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 3126 matching lines...) Expand 10 before | Expand all | Expand 10 after
3137 destination()->false_target()->Branch(zero); 3137 destination()->false_target()->Branch(zero);
3138 __ Cmp(answer.reg(), Factory::null_value()); 3138 __ Cmp(answer.reg(), Factory::null_value());
3139 destination()->true_target()->Branch(equal); 3139 destination()->true_target()->Branch(equal);
3140 3140
3141 // It can be an undetectable object. 3141 // It can be an undetectable object.
3142 __ movq(kScratchRegister, 3142 __ movq(kScratchRegister,
3143 FieldOperand(answer.reg(), HeapObject::kMapOffset)); 3143 FieldOperand(answer.reg(), HeapObject::kMapOffset));
3144 __ testb(FieldOperand(kScratchRegister, Map::kBitFieldOffset), 3144 __ testb(FieldOperand(kScratchRegister, Map::kBitFieldOffset),
3145 Immediate(1 << Map::kIsUndetectable)); 3145 Immediate(1 << Map::kIsUndetectable));
3146 destination()->false_target()->Branch(not_zero); 3146 destination()->false_target()->Branch(not_zero);
3147 __ movb(kScratchRegister, 3147 __ CmpInstanceType(kScratchRegister, FIRST_JS_OBJECT_TYPE);
3148 FieldOperand(kScratchRegister, Map::kInstanceTypeOffset));
3149 __ cmpb(kScratchRegister, Immediate(FIRST_JS_OBJECT_TYPE));
3150 destination()->false_target()->Branch(below); 3148 destination()->false_target()->Branch(below);
3151 __ cmpb(kScratchRegister, Immediate(LAST_JS_OBJECT_TYPE)); 3149 __ CmpInstanceType(kScratchRegister, LAST_JS_OBJECT_TYPE);
3152 answer.Unuse(); 3150 answer.Unuse();
3153 destination()->Split(below_equal); 3151 destination()->Split(below_equal);
3154 } else { 3152 } else {
3155 // Uncommon case: typeof testing against a string literal that is 3153 // Uncommon case: typeof testing against a string literal that is
3156 // never returned from the typeof operator. 3154 // never returned from the typeof operator.
3157 answer.Unuse(); 3155 answer.Unuse();
3158 destination()->Goto(false); 3156 destination()->Goto(false);
3159 } 3157 }
3160 return; 3158 return;
3161 } 3159 }
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
3386 Result obj = frame_->Pop(); 3384 Result obj = frame_->Pop();
3387 obj.ToRegister(); 3385 obj.ToRegister();
3388 frame_->Spill(obj.reg()); 3386 frame_->Spill(obj.reg());
3389 3387
3390 // If the object is a smi, we return null. 3388 // If the object is a smi, we return null.
3391 __ testl(obj.reg(), Immediate(kSmiTagMask)); 3389 __ testl(obj.reg(), Immediate(kSmiTagMask));
3392 null.Branch(zero); 3390 null.Branch(zero);
3393 3391
3394 // Check that the object is a JS object but take special care of JS 3392 // Check that the object is a JS object but take special care of JS
3395 // functions to make sure they have 'Function' as their class. 3393 // functions to make sure they have 'Function' as their class.
3396 { Result tmp = allocator()->Allocate();
3397 __ movq(obj.reg(), FieldOperand(obj.reg(), HeapObject::kMapOffset));
3398 __ movb(tmp.reg(), FieldOperand(obj.reg(), Map::kInstanceTypeOffset));
3399 __ cmpb(tmp.reg(), Immediate(FIRST_JS_OBJECT_TYPE));
3400 null.Branch(less);
3401 3394
3402 // As long as JS_FUNCTION_TYPE is the last instance type and it is 3395 __ CmpObjectType(obj.reg(), FIRST_JS_OBJECT_TYPE, obj.reg());
3403 // right after LAST_JS_OBJECT_TYPE, we can avoid checking for 3396 null.Branch(less);
3404 // LAST_JS_OBJECT_TYPE. 3397
3405 ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); 3398 // As long as JS_FUNCTION_TYPE is the last instance type and it is
3406 ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1); 3399 // right after LAST_JS_OBJECT_TYPE, we can avoid checking for
3407 __ cmpb(tmp.reg(), Immediate(JS_FUNCTION_TYPE)); 3400 // LAST_JS_OBJECT_TYPE.
3408 function.Branch(equal); 3401 ASSERT(LAST_TYPE == JS_FUNCTION_TYPE);
3409 } 3402 ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1);
3403 __ CmpInstanceType(obj.reg(), JS_FUNCTION_TYPE);
3404 function.Branch(equal);
3410 3405
3411 // Check if the constructor in the map is a function. 3406 // Check if the constructor in the map is a function.
3412 { Result tmp = allocator()->Allocate(); 3407 __ movq(obj.reg(), FieldOperand(obj.reg(), Map::kConstructorOffset));
3413 __ movq(obj.reg(), FieldOperand(obj.reg(), Map::kConstructorOffset)); 3408 __ CmpObjectType(obj.reg(), JS_FUNCTION_TYPE, kScratchRegister);
3414 __ CmpObjectType(obj.reg(), JS_FUNCTION_TYPE, tmp.reg()); 3409 non_function_constructor.Branch(not_equal);
3415 non_function_constructor.Branch(not_equal);
3416 }
3417 3410
3418 // The obj register now contains the constructor function. Grab the 3411 // The obj register now contains the constructor function. Grab the
3419 // instance class name from there. 3412 // instance class name from there.
3420 __ movq(obj.reg(), 3413 __ movq(obj.reg(),
3421 FieldOperand(obj.reg(), JSFunction::kSharedFunctionInfoOffset)); 3414 FieldOperand(obj.reg(), JSFunction::kSharedFunctionInfoOffset));
3422 __ movq(obj.reg(), 3415 __ movq(obj.reg(),
3423 FieldOperand(obj.reg(), 3416 FieldOperand(obj.reg(),
3424 SharedFunctionInfo::kInstanceClassNameOffset)); 3417 SharedFunctionInfo::kInstanceClassNameOffset));
3425 frame_->Push(&obj); 3418 frame_->Push(&obj);
3426 leave.Jump(); 3419 leave.Jump();
(...skipping 1994 matching lines...) Expand 10 before | Expand all | Expand 10 after
5421 5414
5422 void ToBooleanStub::Generate(MacroAssembler* masm) { 5415 void ToBooleanStub::Generate(MacroAssembler* masm) {
5423 Label false_result, true_result, not_string; 5416 Label false_result, true_result, not_string;
5424 __ movq(rax, Operand(rsp, 1 * kPointerSize)); 5417 __ movq(rax, Operand(rsp, 1 * kPointerSize));
5425 5418
5426 // 'null' => false. 5419 // 'null' => false.
5427 __ Cmp(rax, Factory::null_value()); 5420 __ Cmp(rax, Factory::null_value());
5428 __ j(equal, &false_result); 5421 __ j(equal, &false_result);
5429 5422
5430 // Get the map and type of the heap object. 5423 // Get the map and type of the heap object.
5424 // We don't use CmpObjectType because we manipulate the type field.
5431 __ movq(rdx, FieldOperand(rax, HeapObject::kMapOffset)); 5425 __ movq(rdx, FieldOperand(rax, HeapObject::kMapOffset));
5432 __ movzxbq(rcx, FieldOperand(rdx, Map::kInstanceTypeOffset)); 5426 __ movzxbq(rcx, FieldOperand(rdx, Map::kInstanceTypeOffset));
5433 5427
5434 // Undetectable => false. 5428 // Undetectable => false.
5435 __ movzxbq(rbx, FieldOperand(rdx, Map::kBitFieldOffset)); 5429 __ movzxbq(rbx, FieldOperand(rdx, Map::kBitFieldOffset));
5436 __ and_(rbx, Immediate(1 << Map::kIsUndetectable)); 5430 __ and_(rbx, Immediate(1 << Map::kIsUndetectable));
5437 __ j(not_zero, &false_result); 5431 __ j(not_zero, &false_result);
5438 5432
5439 // JavaScript object => true. 5433 // JavaScript object => true.
5440 __ cmpq(rcx, Immediate(FIRST_JS_OBJECT_TYPE)); 5434 __ cmpq(rcx, Immediate(FIRST_JS_OBJECT_TYPE));
(...skipping 1506 matching lines...) Expand 10 before | Expand all | Expand 10 after
6947 int CompareStub::MinorKey() { 6941 int CompareStub::MinorKey() {
6948 // Encode the two parameters in a unique 16 bit value. 6942 // Encode the two parameters in a unique 16 bit value.
6949 ASSERT(static_cast<unsigned>(cc_) < (1 << 15)); 6943 ASSERT(static_cast<unsigned>(cc_) < (1 << 15));
6950 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0); 6944 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0);
6951 } 6945 }
6952 6946
6953 6947
6954 #undef __ 6948 #undef __
6955 6949
6956 } } // namespace v8::internal 6950 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/x64/ic-x64.cc » ('j') | src/x64/ic-x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698