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

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

Issue 24366004: Split HCompareGeneric in a test and a branch part. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 } 910 }
911 911
912 912
913 static const char* LabelType(LLabel* label) { 913 static const char* LabelType(LLabel* label) {
914 if (label->is_loop_header()) return " (loop header)"; 914 if (label->is_loop_header()) return " (loop header)";
915 if (label->is_osr_entry()) return " (OSR entry)"; 915 if (label->is_osr_entry()) return " (OSR entry)";
916 return ""; 916 return "";
917 } 917 }
918 918
919 919
920 inline Condition LCodeGen::TokenToCondition(Token::Value op, bool is_unsigned) {
921 Condition cond = no_condition;
922 switch (op) {
923 case Token::EQ:
924 case Token::EQ_STRICT:
925 cond = equal;
926 break;
927 case Token::LT:
928 cond = is_unsigned ? below : less;
929 break;
930 case Token::GT:
931 cond = is_unsigned ? above : greater;
932 break;
933 case Token::LTE:
934 cond = is_unsigned ? below_equal : less_equal;
935 break;
936 case Token::GTE:
937 cond = is_unsigned ? above_equal : greater_equal;
938 break;
939 case Token::IN:
940 case Token::INSTANCEOF:
941 default:
942 UNREACHABLE();
943 }
944 return cond;
945 }
946
947
920 void LCodeGen::DoLabel(LLabel* label) { 948 void LCodeGen::DoLabel(LLabel* label) {
921 Comment(";;; <@%d,#%d> -------------------- B%d%s --------------------", 949 Comment(";;; <@%d,#%d> -------------------- B%d%s --------------------",
922 current_instruction_, 950 current_instruction_,
923 label->hydrogen_value()->id(), 951 label->hydrogen_value()->id(),
924 label->block_id(), 952 label->block_id(),
925 LabelType(label)); 953 LabelType(label));
926 __ bind(label->label()); 954 __ bind(label->label());
927 current_block_ = label->block_id(); 955 current_block_ = label->block_id();
928 DoGap(label); 956 DoGap(label);
929 } 957 }
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
1937 int false_block = instr->FalseDestination(chunk_); 1965 int false_block = instr->FalseDestination(chunk_);
1938 __ j(cc, chunk_->GetAssemblyLabel(false_block)); 1966 __ j(cc, chunk_->GetAssemblyLabel(false_block));
1939 } 1967 }
1940 1968
1941 1969
1942 void LCodeGen::DoDebugBreak(LDebugBreak* instr) { 1970 void LCodeGen::DoDebugBreak(LDebugBreak* instr) {
1943 __ int3(); 1971 __ int3();
1944 } 1972 }
1945 1973
1946 1974
1975 void LCodeGen::DoAndBranch(LAndBranch* instr) {
1976 Condition condition = TokenToCondition(instr->op(), false);
1977 __ testq(ToRegister(instr->value()), ToRegister(instr->value()));
1978 EmitBranch(instr, condition);
1979 }
1980
1981
1947 void LCodeGen::DoBranch(LBranch* instr) { 1982 void LCodeGen::DoBranch(LBranch* instr) {
1948 Representation r = instr->hydrogen()->value()->representation(); 1983 Representation r = instr->hydrogen()->value()->representation();
1949 if (r.IsInteger32()) { 1984 if (r.IsInteger32()) {
1950 ASSERT(!info()->IsStub()); 1985 ASSERT(!info()->IsStub());
1951 Register reg = ToRegister(instr->value()); 1986 Register reg = ToRegister(instr->value());
1952 __ testl(reg, reg); 1987 __ testl(reg, reg);
1953 EmitBranch(instr, not_zero); 1988 EmitBranch(instr, not_zero);
1954 } else if (r.IsSmi()) { 1989 } else if (r.IsSmi()) {
1955 ASSERT(!info()->IsStub()); 1990 ASSERT(!info()->IsStub());
1956 Register reg = ToRegister(instr->value()); 1991 Register reg = ToRegister(instr->value());
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2086 __ jmp(chunk_->GetAssemblyLabel(chunk_->LookupDestination(block))); 2121 __ jmp(chunk_->GetAssemblyLabel(chunk_->LookupDestination(block)));
2087 } 2122 }
2088 } 2123 }
2089 2124
2090 2125
2091 void LCodeGen::DoGoto(LGoto* instr) { 2126 void LCodeGen::DoGoto(LGoto* instr) {
2092 EmitGoto(instr->block_id()); 2127 EmitGoto(instr->block_id());
2093 } 2128 }
2094 2129
2095 2130
2096 inline Condition LCodeGen::TokenToCondition(Token::Value op, bool is_unsigned) {
2097 Condition cond = no_condition;
2098 switch (op) {
2099 case Token::EQ:
2100 case Token::EQ_STRICT:
2101 cond = equal;
2102 break;
2103 case Token::LT:
2104 cond = is_unsigned ? below : less;
2105 break;
2106 case Token::GT:
2107 cond = is_unsigned ? above : greater;
2108 break;
2109 case Token::LTE:
2110 cond = is_unsigned ? below_equal : less_equal;
2111 break;
2112 case Token::GTE:
2113 cond = is_unsigned ? above_equal : greater_equal;
2114 break;
2115 case Token::IN:
2116 case Token::INSTANCEOF:
2117 default:
2118 UNREACHABLE();
2119 }
2120 return cond;
2121 }
2122
2123
2124 void LCodeGen::DoCompareNumericAndBranch(LCompareNumericAndBranch* instr) { 2131 void LCodeGen::DoCompareNumericAndBranch(LCompareNumericAndBranch* instr) {
2125 LOperand* left = instr->left(); 2132 LOperand* left = instr->left();
2126 LOperand* right = instr->right(); 2133 LOperand* right = instr->right();
2127 Condition cc = TokenToCondition(instr->op(), instr->is_double()); 2134 Condition cc = TokenToCondition(instr->op(), instr->is_double());
2128 2135
2129 if (left->IsConstantOperand() && right->IsConstantOperand()) { 2136 if (left->IsConstantOperand() && right->IsConstantOperand()) {
2130 // We can statically evaluate the comparison. 2137 // We can statically evaluate the comparison.
2131 double left_val = ToDouble(LConstantOperand::cast(left)); 2138 double left_val = ToDouble(LConstantOperand::cast(left));
2132 double right_val = ToDouble(LConstantOperand::cast(right)); 2139 double right_val = ToDouble(LConstantOperand::cast(right));
2133 int next_block = EvalComparison(instr->op(), left_val, right_val) ? 2140 int next_block = EvalComparison(instr->op(), left_val, right_val) ?
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
2597 __ movq(result, FieldOperand(object, HeapObject::kMapOffset)); 2604 __ movq(result, FieldOperand(object, HeapObject::kMapOffset));
2598 __ movzxbq(result, FieldOperand(result, Map::kInstanceSizeOffset)); 2605 __ movzxbq(result, FieldOperand(result, Map::kInstanceSizeOffset));
2599 } 2606 }
2600 2607
2601 2608
2602 void LCodeGen::DoCmpT(LCmpT* instr) { 2609 void LCodeGen::DoCmpT(LCmpT* instr) {
2603 Token::Value op = instr->op(); 2610 Token::Value op = instr->op();
2604 2611
2605 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), op); 2612 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), op);
2606 CallCode(ic, RelocInfo::CODE_TARGET, instr); 2613 CallCode(ic, RelocInfo::CODE_TARGET, instr);
2614 __ nop();
2607 2615
2608 Condition condition = TokenToCondition(op, false); 2616 Register res = ToRegister(instr->result());
2609 Label true_value, done; 2617 if (!res.is(rax)) __ movq(res, rax);
2610 __ testq(rax, rax);
2611 __ j(condition, &true_value, Label::kNear);
2612 __ LoadRoot(ToRegister(instr->result()), Heap::kFalseValueRootIndex);
2613 __ jmp(&done, Label::kNear);
2614 __ bind(&true_value);
2615 __ LoadRoot(ToRegister(instr->result()), Heap::kTrueValueRootIndex);
2616 __ bind(&done);
2617 } 2618 }
2618 2619
2619 2620
2620 void LCodeGen::DoReturn(LReturn* instr) { 2621 void LCodeGen::DoReturn(LReturn* instr) {
2621 if (FLAG_trace && info()->IsOptimizing()) { 2622 if (FLAG_trace && info()->IsOptimizing()) {
2622 // Preserve the return value on the stack and rely on the runtime 2623 // Preserve the return value on the stack and rely on the runtime
2623 // call to return the value in the same register. 2624 // call to return the value in the same register.
2624 __ push(rax); 2625 __ push(rax);
2625 __ CallRuntime(Runtime::kTraceExit, 1); 2626 __ CallRuntime(Runtime::kTraceExit, 1);
2626 } 2627 }
(...skipping 2884 matching lines...) Expand 10 before | Expand all | Expand 10 after
5511 FixedArray::kHeaderSize - kPointerSize)); 5512 FixedArray::kHeaderSize - kPointerSize));
5512 __ bind(&done); 5513 __ bind(&done);
5513 } 5514 }
5514 5515
5515 5516
5516 #undef __ 5517 #undef __
5517 5518
5518 } } // namespace v8::internal 5519 } } // namespace v8::internal
5519 5520
5520 #endif // V8_TARGET_ARCH_X64 5521 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698